Skip to content

Commit

Permalink
Skip ahead to re-run only Cypress (#1885)
Browse files Browse the repository at this point in the history
* use the run_id and run_attempt as the ID

* add cypress workaround?

* cypress re-run

* docs on how to use
  • Loading branch information
mojotalantikite authored Aug 24, 2023
1 parent 6639ff6 commit 8d77257
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down
8 changes: 8 additions & 0 deletions scripts/get-changed-services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8d77257

Please sign in to comment.