diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 76bb02f5ab..921775d1a3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -405,10 +405,6 @@ jobs: echo $endpoint echo "storybook-endpoint=$endpoint" >> "$GITHUB_OUTPUT" - - name: Generate unique ID for Cypress - id: uuid - run: echo "value=sha-$GITHUB_SHA-time-$(date +"%s")" >> "$GITHUB_OUTPUT" - end-deployment: needs: [begin-deployment, deploy-app, finishing-prep] if: always() && needs.begin-deployment.result == 'success' @@ -491,7 +487,7 @@ jobs: parallel: true browser: chrome group: 'Chrome' - ci-build-id: ${{ needs.finishing-prep.outputs.cypress-uuid }} + ci-build-id: ${{ github.run_id }}-${{ github.run_attempt }} # Point to the cypress config file from root config-file: services/cypress/cypress.config.ts env: diff --git a/README.md b/README.md index 299ce1ce7e..79ec2b60f7 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,7 @@ If you are going to need to modify the migration that prisma generates you can u Whenever you run `./dev postgres` we start a new postgres docker container and run `prisma migrate reset --force` to clean it out and run all of our checked in migrations there. After that you should be ready to develop. -## Build & Deploy +## Build & Deploy in CI See main build/deploy [here](https://github.com/Enterprise-CMCS/managed-care-review/actions/workflows/promote.yml?query=branch%3Amain) @@ -184,7 +184,9 @@ This application is deployed into three different AWS accounts: Dev, Val, and Pr In the Dev account, in addition to deploying the main branch, we deploy a full version of the app on every branch that is pushed that is not the main branch. We call these deployments "review apps" since they host all the changes for a PR in a full deployment. These review apps are differentiated by their Serverless "stack" name. This is set to the branch name and all infra ends up being prefixed with it to keep from there being any overlapping. -We have a script (`getChangedServices`) that runs in CI to check if a service needs to be re-deployed due to your most recent commit or if a service can be skipped in order to save CI deploy time. For example, if you're just making changes to `app-web`, it's likely that you won't need to re-deploy any infra services, such as postgres, after an initial branch deploy. However, if you do need your branch to be fully re-deployed, you can add the string `force-ci-run` to your commit message and the entire deploy workflow will be run. +#### CI stage skipping script + +We have a script (`getChangedServices`) that runs in CI to check if a service needs to be re-deployed due to your most recent commit or if a service can be skipped in order to save CI deploy time. For example, if you're just making changes to `app-web`, it's likely that you won't need to re-deploy any infra services, such as postgres, after an initial branch deploy. However, if you do need your branch to be fully re-deployed, you can add the string `force-ci-run` to your commit message and the entire deploy workflow will be run. If you have a failing Cypress container and want to skip over deploying infra and the application, use the string `cypress re-run` in a commit message and the `getChangedServices` script will skip you to the Cypress run (unit tests will still run, but it still saves time). You can see the deploys for review apps [here](https://github.com/Enterprise-CMCS/managed-care-review/actions/workflows/deploy.yml) diff --git a/scripts/get-changed-services/index.ts b/scripts/get-changed-services/index.ts index 7ad4b6ca2e..65241561a7 100644 --- a/scripts/get-changed-services/index.ts +++ b/scripts/get-changed-services/index.ts @@ -28,11 +28,19 @@ async function main() { // get the latest commit in the branch to see if we are forcing a run const latestCommit = await getLatestCommitSHA() const commitMessage = await getLatestCommitMessage(latestCommit) + + // force a complete CI run if (commitMessage.includes('ci-force-run')) { core.setOutput('changed-services', deployAllServices) return } + // force just a cypress re-run + if (commitMessage.includes('cypress re-run')) { + core.setOutput('changed-services', []) + return + } + // if we haven't had a run on this branch, we need to deploy everything if (allWorkflowRuns.data.total_count === 0) { core.setOutput('changed-services', deployAllServices)