Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MCR] Upgrade to Serverless V4 #12023

Merged
merged 14 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .env.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,16 @@ TEST_STATE_USER_EMAIL=op://mdct_devs/mcr_secrets/CYPRESS_STATE_USER_EMAIL
TEST_STATE_USER_PASSWORD=op://mdct_devs/mcr_secrets/CYPRESS_STATE_USER_PASSWORD # pragma: allowlist secret
TEST_STATE=DC
TEST_STATE_NAME="District of Columbia"

SERVERLESS_LICENSE_KEY=op://mdct_devs/mcr_secrets/SERVERLESS_LICENSE_KEY

WP_FORM_BUCKET=WP_FORM_BUCKET
WP_REPORT_TABLE_NAME=WP_REPORT_TABLE_NAME
WP_REPORT_TABLE_STREAM_ARN=WP_REPORT_TABLE_STREAM_ARN
SAR_FORM_BUCKET=SAR_FORM_BUCKET
SAR_REPORT_TABLE_NAME=SAR_REPORT_TABLE_NAME
SAR_REPORT_TABLE_STREAM_ARN=SAR_REPORT_TABLE_STREAM_ARN
JonHolman marked this conversation as resolved.
Show resolved Hide resolved
AWS_ACCESS_KEY_ID=dummy_access_key
AWS_SECRET_ACCESS_KEY=dummy_secret_key # pragma: allowlist secret
AWS_SESSION_TOKEN=dummy_session_token
AWS_REGION=us-east-1
JonHolman marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 8 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ permissions:
pages: write
actions: read

env:
SERVERLESS_LICENSE_KEY: ${{ secrets.SERVERLESS_LICENSE_KEY }}

jobs:
unit-tests:
name: Unit Tests
Expand Down Expand Up @@ -201,12 +204,11 @@ jobs:

outputs:
ipset_name: ${{ steps.fetch-ip-set-info.outputs.IPSET_NAME }}
ipset_id: ${{ steps.fetch-ip-set-info.outputs.IPSET_ID }}

ipset_id: ${{ steps.fetch-ip-set-info.outputs.IPSET_ID }}

e2e-test:
name: E2E Integration Tests
needs:
needs:
- deploy
- register-runner
if: ${{ always() && !cancelled() && needs.deploy.result == 'success' && github.ref_name != 'production' }}
Expand Down Expand Up @@ -243,10 +245,9 @@ jobs:
${{github.workspace}}/tests/cypress/videos/
retention-days: 14


a11y-tests:
name: E2E A11y Tests
needs:
needs:
- deploy
- register-runner
if: ${{ always() && !cancelled() && needs.deploy.result == 'success' && github.ref_name != 'production' }}
Expand Down Expand Up @@ -279,7 +280,7 @@ jobs:
${{github.workspace}}/tests/cypress/screenshots/
${{github.workspace}}/tests/cypress/videos/
retention-days: 14

test:
name: Playwright Tests
needs:
Expand Down Expand Up @@ -404,4 +405,4 @@ jobs:
run: ./.github/waf-controller.sh set ${{ needs.register-runner.outputs.ipset_name }} ${{ needs.register-runner.outputs.ipset_id }} '[]'
env:
AWS_RETRY_MODE: adaptive
AWS_MAX_ATTEMPTS: 10
AWS_MAX_ATTEMPTS: 10
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ tests/test-results/
tests/playwright-report/
tests/playwright/.cache/
.auth/
/.serverless
14 changes: 7 additions & 7 deletions logs/launchdarkly-flags.log
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

# LaunchDarkly flags in components
./services/ui-src/src/components/app/AppRoutes.tsx:30:useFlags()?.naaarReport;
./services/ui-src/src/components/cards/TemplateCard.tsx:33:useFlags()?.naaarReport;
./services/ui-src/src/components/cards/TemplateCard.tsx:34:useFlags()?.naaarReport;
./services/ui-src/src/components/forms/AdminDashSelector.tsx:40:useFlags()?.naaarReport;
./services/ui-src/src/components/modals/AddEditReportModal.tsx:43:useFlags()?.naaarReport;
./services/ui-src/src/components/pages/Dashboard/DashboardPage.tsx:213:useFlags()?.sortableDashboardTable;

# LaunchDarkly flags in tests
./services/ui-src/src/components/app/AppRoutes.test.tsx:138:mockLDFlags.set({ naaarReport: true });
./services/ui-src/src/components/app/AppRoutes.test.tsx:150:mockLDFlags.set({ naaarReport: false });
./services/ui-src/src/components/app/AppRoutes.test.tsx:141:mockLDFlags.set({ naaarReport: true });
./services/ui-src/src/components/app/AppRoutes.test.tsx:155:mockLDFlags.set({ naaarReport: false });
./services/ui-src/src/components/app/AppRoutes.test.tsx:25:mockLDFlags.setDefault({ naaarReport: false });
./services/ui-src/src/components/cards/TemplateCard.test.tsx:140:mockLDFlags.set({ naaarReport: true });
./services/ui-src/src/components/cards/TemplateCard.test.tsx:150:mockLDFlags.set({ naaarReport: false });
./services/ui-src/src/components/cards/TemplateCard.test.tsx:145:mockLDFlags.set({ naaarReport: true });
./services/ui-src/src/components/cards/TemplateCard.test.tsx:157:mockLDFlags.set({ naaarReport: false });
./services/ui-src/src/components/cards/TemplateCard.test.tsx:60:mockLDFlags.setDefault({ naaarReport: true });
./services/ui-src/src/components/forms/AdminDashSelector.test.tsx:32:mockLDFlags.setDefault({ naaarReport: true });
./services/ui-src/src/components/forms/AdminDashSelector.test.tsx:62:mockLDFlags.set({ naaarReport: true });
./services/ui-src/src/components/forms/AdminDashSelector.test.tsx:72:mockLDFlags.set({ naaarReport: false });
./services/ui-src/src/components/forms/AdminDashSelector.test.tsx:63:mockLDFlags.set({ naaarReport: true });
./services/ui-src/src/components/forms/AdminDashSelector.test.tsx:73:mockLDFlags.set({ naaarReport: false });
./services/ui-src/src/components/pages/Dashboard/SortableDashboardTable.test.tsx:143:mockLDFlags.set({ sortableDashboardTable: true });
./services/ui-src/src/components/pages/Dashboard/SortableDashboardTable.test.tsx:279:mockLDFlags.set({ sortableDashboardTable: true });
./services/ui-src/src/components/pages/Dashboard/SortableDashboardTable.test.tsx:297:mockLDFlags.set({ sortableDashboardTable: true });
Expand Down
4 changes: 2 additions & 2 deletions logs/todos.log
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

./services/app-api/handlers/reports/fetch.ts:69: TODO: strict typing
./services/app-api/handlers/reports/fetch.ts:80: TODO: strict typing
./services/ui-src/src/components/layout/Timeout.tsx:33: TODO: When autosave is implemented, set up a callback function to listen to calls to update in authLifecycle
./services/ui-src/src/components/reports/ModalOverlayReportPage.test.tsx:148:todo Write a test to make sure admins can't click/change details?
./services/ui-src/src/components/layout/Timeout.tsx:36: TODO: When autosave is implemented, set up a callback function to listen to calls to update in authLifecycle
./services/ui-src/src/components/reports/ModalOverlayReportPage.test.tsx:149:todo Write a test to make sure admins can't click/change details?
./services/ui-src/src/components/tables/EntityRow.tsx:26: TODO: refactor to handle NAAAR analysis methods
./services/ui-src/src/components/tables/SortableTable.tsx:196: TODO: add additional styling for two-column dynamic field tables if needed
./services/ui-src/src/components/tables/Table.tsx:135: TODO: add additional styling for two-column dynamic field tables if needed
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@
"eslint-plugin-react-hooks": "^4.6.0",
"jest-environment-jsdom": "^29.7.0",
"prettier": "^2.4.1",
"serverless": "^3.39.0",
"serverless-bundle": "^6.0.0",
"serverless": "^4.4.18",
"serverless-cloudfront-invalidate": "^1.11.0",
"serverless-dotenv-plugin": "^3.0.0",
"serverless-iam-helper": "github:Enterprise-CMCS/serverless-iam-helper",
"serverless-offline": "^13.5.0",
"serverless-offline": "^14.4.0",
"serverless-plugin-scripts": "^1.0.2",
"serverless-s3-bucket-helper": "github:Enterprise-CMCS/serverless-s3-bucket-helper#master",
"serverless-s3-sync": "^3.2.0",
"serverless-stack-termination-protection": "^2.0.2",
"typescript": "^4.6.3",
Expand Down
6 changes: 3 additions & 3 deletions run
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ if ! which yarn > /dev/null ; then
fi

# check serverless is installed globally.
if ! which serverless > /dev/null ; then
echo "installing serverless globally"
yarn global add serverless@3.38.0
if ! which serverless > /dev/null || [[ "$(serverless --version | cut -d'.' -f1)" != "4" ]]; then
echo "installing serverless v4 globally"
yarn global add serverless@4.4.18
fi

# have to ensure that yarn install is up to date.
Expand Down
4 changes: 1 addition & 3 deletions services/app-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"scripts": {
"coverage": "jest --coverage",
"test": "jest",
"test-watch": "jest --watch",
"test-serverless": "serverless-bundle test"
"test-watch": "jest --watch"
},
"author": "",
"license": "CC0-1.0",
Expand All @@ -26,7 +25,6 @@
"serverless-associate-waf": "^1.2.1",
"serverless-plugin-common-excludes": "^4.0.0",
"serverless-plugin-include-dependencies": "^5.1.0",
"serverless-plugin-typescript": "^2.1.4",
"ts-jest": "^27.1.3",
"typescript": "^4.5.4"
},
Expand Down
22 changes: 8 additions & 14 deletions services/app-api/serverless.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
# Refer to the README.md file in within this service directory to configure all ssm parameters required for this service.
service: app-api

frameworkVersion: "3"
frameworkVersion: "4"

package:
individually: true
patterns:
- node_modules/**

build:
esbuild:
packages: external

plugins:
- serverless-plugin-typescript
- serverless-dotenv-plugin
- serverless-associate-waf
- "@enterprise-cmcs/serverless-waf-plugin"
- serverless-stack-termination-protection
- serverless-iam-helper
- serverless-s3-bucket-helper
- serverless-offline
- serverless-plugin-common-excludes # this should go before serverless-plugin-include-dependencies
- serverless-plugin-include-dependencies

s3BucketHelper:
loggingConfiguration:
destinationBucketName: ${env:LOGGING_BUCKET, ssm:/configuration/${self:custom.stage}/s3/accessLogsBucket, ssm:/configuration/default/s3/accessLogsBucket}
logFilePrefix: ${env:LOGGING_BUCKET, ssm:/configuration/${self:custom.stage}/s3/accessLogsPrefix, ssm:/configuration/default/s3/accessLogsPrefix}

custom:
project: "mcr"
Expand Down Expand Up @@ -80,15 +74,15 @@ provider:
region: us-east-1
stackTags:
PROJECT: ${self:custom.project}
SERVICE: ${self:service}
SERVICE: ${self:service}
tracing:
apiGateway: true
logs:
restApi: true
iam:
role:
path: ${env:IAM_PATH, ssm:/configuration/${self:custom.stage}/iam/path, ssm:/configuration/default/iam/path, "/"}
permissionsBoundary: ${env:IAM_PERMISSIONS_BOUNDARY, ssm:/configuration/${self:custom.stage}/iam/permissionsBoundaryPolicy, ssm:/configuration/default/iam/permissionsBoundaryPolicy, ""}
path: /delegatedadmin/developer/
permissionsBoundary: !Sub arn:aws:iam::${AWS::AccountId}:policy/cms-cloud-admin/developer-boundary-policy
statements:
- Effect: "Allow"
Action:
Expand Down
65 changes: 4 additions & 61 deletions services/app-api/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1911,14 +1911,6 @@
dependencies:
"@types/trusted-types" "*"

"@types/glob@^7.1.1":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb"
integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==
dependencies:
"@types/minimatch" "*"
"@types/node" "*"

"@types/graceful-fs@^4.1.2":
version "4.1.9"
resolved "https://registry.yarnpkg.com/@types/graceful-fs/-/graceful-fs-4.1.9.tgz#2a06bc0f68a20ab37b3e36aa238be6abdf49e8b4"
Expand Down Expand Up @@ -1977,11 +1969,6 @@
resolved "https://registry.yarnpkg.com/@types/md5/-/md5-2.3.5.tgz#481cef0a896e3a5dcbfc5a8a8b02c05958af48a5"
integrity sha512-/i42wjYNgE6wf0j2bcTX6kuowmdL/6PE4IVitMpm2eYKBUuYCprdcWVK+xEF0gcV6ufMCRhtxmReGfc6hIK7Jw==

"@types/minimatch@*":
version "5.1.2"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-5.1.2.tgz#07508b45797cb81ec3f273011b054cd0755eddca"
integrity sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==

"@types/node@*":
version "20.14.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.14.2.tgz#a5f4d2bcb4b6a87bffcaa717718c5a0f208f4a18"
Expand Down Expand Up @@ -2748,7 +2735,7 @@ expect@^27.5.1:
jest-matcher-utils "^27.5.1"
jest-message-util "^27.5.1"

fast-glob@^3.0.3, fast-glob@^3.2.9:
fast-glob@^3.2.9:
version "3.3.2"
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.2.tgz#a904501e57cfdd2ffcded45e99a54fef55e46129"
integrity sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==
Expand Down Expand Up @@ -2823,15 +2810,6 @@ form-data@^4.0.0:
combined-stream "^1.0.8"
mime-types "^2.1.12"

fs-extra@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"
integrity sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==
dependencies:
graceful-fs "^4.1.2"
jsonfile "^4.0.0"
universalify "^0.1.0"

fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
Expand Down Expand Up @@ -2899,20 +2877,6 @@ globals@^11.1.0:
resolved "https://registry.yarnpkg.com/globals/-/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e"
integrity sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==

globby@^10.0.2:
version "10.0.2"
resolved "https://registry.yarnpkg.com/globby/-/globby-10.0.2.tgz#277593e745acaa4646c3ab411289ec47a0392543"
integrity sha512-7dUi7RvCoT/xast/o/dLN53oqND4yk0nsHkhRgn9w65C4PofCLOoJ39iSOg+qVDdWQPIEj+eszMHQ+aLVwwQSg==
dependencies:
"@types/glob" "^7.1.1"
array-union "^2.1.0"
dir-glob "^3.0.1"
fast-glob "^3.0.3"
glob "^7.1.3"
ignore "^5.1.1"
merge2 "^1.2.3"
slash "^3.0.0"

globby@^11.0.3:
version "11.1.0"
resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b"
Expand All @@ -2932,7 +2896,7 @@ gonzales-pe@^4.2.3, gonzales-pe@^4.3.0:
dependencies:
minimist "^1.2.5"

graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.9:
graceful-fs@^4.2.9:
version "4.2.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3"
integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==
Expand Down Expand Up @@ -3030,7 +2994,7 @@ [email protected]:
dependencies:
safer-buffer ">= 2.1.2 < 3.0.0"

ignore@^5.1.1, ignore@^5.2.0:
ignore@^5.2.0:
version "5.3.1"
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.3.1.tgz#5073e554cd42c5b33b394375f538b8593e34d4ef"
integrity sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==
Expand Down Expand Up @@ -3665,13 +3629,6 @@ [email protected], json5@^2.2.3:
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==

jsonfile@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
integrity sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==
optionalDependencies:
graceful-fs "^4.1.6"

just-extend@^6.2.0:
version "6.2.0"
resolved "https://registry.yarnpkg.com/just-extend/-/just-extend-6.2.0.tgz#b816abfb3d67ee860482e7401564672558163947"
Expand Down Expand Up @@ -3774,7 +3731,7 @@ merge-stream@^2.0.0:
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==

merge2@^1.2.3, merge2@^1.3.0, merge2@^1.4.1:
merge2@^1.3.0, merge2@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==
Expand Down Expand Up @@ -4279,15 +4236,6 @@ serverless-plugin-include-dependencies@^5.1.0:
resolve "^1.15.0"
semver "^7.1.1"

serverless-plugin-typescript@^2.1.4:
version "2.1.5"
resolved "https://registry.yarnpkg.com/serverless-plugin-typescript/-/serverless-plugin-typescript-2.1.5.tgz#d4c4636ee6e4803d2fe773ce2bb8bf52362c836d"
integrity sha512-7OO6eJzv57dvfz0v9huU1JVBgdzgvvz+6GCwwkR2bfdVHKs1tifx+fSgjbQcBpXNNHf8Dx2Mo7evtYTkA/TDDA==
dependencies:
fs-extra "^7.0.1"
globby "^10.0.2"
lodash "^4.17.21"

shebang-command@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea"
Expand Down Expand Up @@ -4622,11 +4570,6 @@ uniq@^1.0.1:
resolved "https://registry.yarnpkg.com/uniq/-/uniq-1.0.1.tgz#b31c5ae8254844a3a8281541ce2b04b865a734ff"
integrity sha512-Gw+zz50YNKPDKXs+9d+aKAjVwpjNwqzvNpLigIruT4HA9lMZNdMqs9x07kKHB/L9WRzqp4+DlTU5s4wG2esdoA==

universalify@^0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==

universalify@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.2.0.tgz#6451760566fa857534745ab1dde952d1b1761be0"
Expand Down
Loading
Loading