Skip to content

Commit

Permalink
Pivot from previous email path
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpaige committed Jan 3, 2025
1 parent 291db79 commit e034324
Show file tree
Hide file tree
Showing 50 changed files with 606 additions and 434 deletions.
2 changes: 1 addition & 1 deletion .bun-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.40
1.1.20
72 changes: 47 additions & 25 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Deploy

on:
push:
branches:
- "*"
- "!skipci*"

concurrency:
group: ${{ startsWith(github.ref_name, 'snyk-') && 'snyk' || github.ref_name }}-group

Expand Down Expand Up @@ -77,7 +79,6 @@ jobs:
environment:
name: ${{ startsWith(github.ref_name, 'snyk-') && 'snyk' || github.ref_name }}-app
url: ${{ needs.deploy.outputs.app-url }}

steps:
- name: Display App URL
run: |
Expand All @@ -94,6 +95,7 @@ jobs:
- name: Display Kibana URL
run: |
echo "Kibana URL: ${{ needs.deploy.outputs.kibana-url }}"
test:
runs-on: ubuntu-20.04
needs:
Expand All @@ -113,10 +115,6 @@ jobs:
aws-region: us-east-1
role-duration-seconds: 10800

- name: Install dependencies
run: bun install
- name: Add Node.js bin to PATH
run: echo "PATH=$(pwd)/node_modules/.bin:\$PATH" >> $GITHUB_ENV
- name: Test
run: run test --coverage
- name: Upload Coverage
Expand All @@ -129,48 +127,35 @@ jobs:
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
coverageLocations: "coverage/lcov.info:lcov"
coverageLocations: coverage/lcov.info:lcov

e2e:
runs-on: ubuntu-20.04
needs:
- deploy
- application-url
- kibana-url
environment:
name: ${{ startsWith(github.ref_name, 'snyk-') && 'snyk' || github.ref_name }}
if: ${{ github.ref != 'refs/heads/production' }}
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: ./.github/actions/setup

- name: Setup
uses: ./.github/actions/setup
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-east-1
role-duration-seconds: 10800
- name: Install dependencies
run: bun install
- name: Run e2e test
working-directory: test
run: |
bun install
bun e2e
env:
VITE_BASE_URL: ${{ needs.deploy.outputs.app-url }}
VITE_E2E_PASSWORD: ${{ secrets.VITE_E2E_PASSWORD }}
- name: Upload Playwright Report
uses: actions/upload-artifact@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run e2e tests
run: run e2e
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: test/e2e/playwright-report/index.html
retention-days: 30

cfn-nag:
runs-on: ubuntu-20.04
needs:
Expand Down Expand Up @@ -203,6 +188,42 @@ jobs:
uses: stelligent/[email protected]
with:
input_path: cftemplates
resources:
runs-on: ubuntu-20.04
needs:
- deploy
environment:
name: ${{ startsWith(github.ref_name, 'snyk-') && 'snyk' || github.ref_name }}
steps:
- name: Checkout
uses: actions/checkout@v3

- uses: ./.github/actions/setup

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_OIDC_ROLE_TO_ASSUME }}
aws-region: us-east-1
role-duration-seconds: 10800

- name: Get AWS Stage Resources
id: stage-resources
run: |
mkdir -p resources
resourceData=()
stackList=(`aws cloudformation describe-stacks --query "Stacks[?Tags[?Key=='STAGE' && Value=='$STAGE_NAME'] && Tags[?Key=='PROJECT' && Value=='$PROJECT']].StackName" --output text`)
for stack in "${stackList[@]}"; do
resources=$(aws cloudformation list-stack-resources --stack-name "$stack" --query "StackResourceSummaries[].{PhysicalResourceId:PhysicalResourceId, ResourceType:ResourceType, ResourceStatus:ResourceStatus, LogicalResourceId:LogicalResourceId, LastUpdatedTimestamp:LastUpdatedTimestamp}" --output json)
resourceData+=( $(echo "$resources" | jq -c --arg stack_name "$stack" '.[] + { StackName: $stack_name }') )
done
join_by() { local IFS="$1"; shift; echo "$*"; }
echo "["$(join_by "," "${resourceData[@]}")"]" > "resources/aws-resources.json"
- name: Archive stage resources
uses: actions/upload-artifact@v3
with:
name: aws-resources-${{ startsWith(github.ref_name, 'snyk-') && 'snyk' || github.ref_name }}
path: resources/aws-resources.json

release:
runs-on: ubuntu-20.04
Expand All @@ -218,6 +239,7 @@ jobs:

- name: Install
run: bun install

- name: Release
run: bun semantic-release
env:
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/pr-coverage-annotation.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
name: PR - coverage annotation

on:
pull_request:
branches:
- main

jobs:
coverage-report:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/checkout@v3
- uses: ./.github/actions/setup
- name: Test
run: run test --coverage
- name: Report Coverage
if: always()
uses: davelosert/vitest-coverage-report-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
coverage-file: coverage/coverage-final.json
coverage-threshold: 80
coverage-threshold-type: lines
coverage-threshold-color: green
9 changes: 7 additions & 2 deletions bin/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import * as cdk from "aws-cdk-lib";
import { ParentStack } from "../lib/stacks/parent";
import { DeploymentConfig } from "../lib/config/deployment-config";
import { getSecret, validateEnvVariable } from "shared-utils";
import { IamPathAspect, IamPermissionsBoundaryAspect } from "../lib/local-aspects";
import {
IamPathAspect,
IamPermissionsBoundaryAspect,
} from "../lib/local-aspects";

async function main() {
try {
Expand Down Expand Up @@ -33,7 +36,9 @@ async function main() {
});

cdk.Aspects.of(app).add(
new IamPermissionsBoundaryAspect(deploymentConfig.config.iamPermissionsBoundary),
new IamPermissionsBoundaryAspect(
deploymentConfig.config.iamPermissionsBoundary,
),
);
cdk.Aspects.of(app).add(new IamPathAspect(deploymentConfig.config.iamPath));
} catch (error) {
Expand Down
37 changes: 30 additions & 7 deletions bin/cli/src/commands/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { Argv } from "yargs";
import { checkIfAuthenticated, runCommand, project, region, writeUiEnvFile } from "../lib";
import * as path from "path";
import {
checkIfAuthenticated,
runCommand,
project,
region,
writeUiEnvFile,
} from "../lib/";
import path from "path";
import { execSync } from "child_process";
import { CloudFrontClient, CreateInvalidationCommand } from "@aws-sdk/client-cloudfront";
import {
CloudFrontClient,
CreateInvalidationCommand,
} from "@aws-sdk/client-cloudfront";
import { GetParameterCommand, SSMClient } from "@aws-sdk/client-ssm";

export const deploy = {
Expand All @@ -13,7 +22,11 @@ export const deploy = {
},
handler: async (options: { stage: string; stack?: string }) => {
await checkIfAuthenticated();
await runCommand("cdk", ["deploy", "-c", `stage=${options.stage}`, "--all"], ".");
await runCommand(
"cdk",
["deploy", "-c", `stage=${options.stage}`, "--all"],
".",
);

await writeUiEnvFile(options.stage);

Expand Down Expand Up @@ -44,8 +57,16 @@ export const deploy = {
// There's a mime type issue when aws s3 syncing files up
// Empirically, this issue never presents itself if the bucket is cleared just before.
// Until we have a neat way of ensuring correct mime types, we'll remove all files from the bucket.
await runCommand("aws", ["s3", "rm", `s3://${s3BucketName}/`, "--recursive"], ".");
await runCommand("aws", ["s3", "sync", buildDir, `s3://${s3BucketName}/`], ".");
await runCommand(
"aws",
["s3", "rm", `s3://${s3BucketName}/`, "--recursive"],
".",
);
await runCommand(
"aws",
["s3", "sync", buildDir, `s3://${s3BucketName}/`],
".",
);

const cloudfrontClient = new CloudFrontClient({
region,
Expand All @@ -61,7 +82,9 @@ export const deploy = {
},
};

await cloudfrontClient.send(new CreateInvalidationCommand(invalidationParams));
await cloudfrontClient.send(
new CreateInvalidationCommand(invalidationParams),
);

console.log(
`Deployed UI to S3 bucket ${s3BucketName} and invalidated CloudFront distribution ${cloudfrontDistributionId}`,
Expand Down
2 changes: 1 addition & 1 deletion bin/cli/src/commands/emails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export const emails = {
command: "emails",
handler: async () => {
await checkIfAuthenticated();
await runCommand("bun", ["emails"], ".");
await runCommand("bun", ["email-dev"], "./lib/libs/email");
},
};
Binary file modified bun.lockb
Binary file not shown.
Binary file removed lib/bun.lockb
Binary file not shown.
10 changes: 7 additions & 3 deletions lib/lambda/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "lambda",
"name": "y",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {},
"author": "",
"license": "ISC",
Expand All @@ -11,12 +12,15 @@
"@aws-sdk/client-s3": "^3.600.0",
"@aws-sdk/client-sfn": "^3.600.0",
"@aws-sdk/s3-request-presigner": "^3.600.0",
"@haftahave/serverless-ses-template": "^6.1.0",
"base-64": "^1.0.0",
"cfn-response-async": "^1.0.0",
"mssql": "^11.0.0"
"mssql": "^11.0.0",
"uuid": "^10.0.0"
},
"devDependencies": {
"@types/base-64": "^1.0.2",
"@types/mssql": "^9.1.5"
"@types/mssql": "^9.1.5",
"@types/uuid": "^10.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Initial Submission CMS Email Snapshot Test > renders a AppkCMSEmail Preview Template 1`] = `
<AppKCMSEmail
variables={
{
"actionType": "Amend",
"additionalInformation": "This submission includes necessary documentation for requested updates to the state’s Medicaid plan, in alignment with CMS requirements.",
"appkParentId": null,
"applicationEndpointUrl": "https://mako-dev.cms.gov/",
"attachments": {
"appk": {
"files": [],
"label": "AppK",
},
"other": {
"files": [],
"label": "Other",
},
},
"authority": "1915(c)",
"event": "app-k",
"id": "CO-1234.R21.00",
"origin": "mako",
"proposedEffectiveDate": 1728495789885,
"submitterEmail": "[email protected]",
"submitterName": "George Harrison",
"territory": "CO",
"timestamp": 1728495786285,
"title": "A Perfect Appendix K Amendment Title",
}
}
/>
`;
26 changes: 0 additions & 26 deletions lib/libs/email/package.json

This file was deleted.

Loading

0 comments on commit e034324

Please sign in to comment.