Skip to content

Commit

Permalink
split out actions into two directions
Browse files Browse the repository at this point in the history
  • Loading branch information
fzhao99 committed Dec 13, 2023
1 parent f9d3d83 commit e4f9211
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 66 deletions.
33 changes: 33 additions & 0 deletions .github/actions/post-deploy-smoke-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Smoke test post deploy
description: Ping a backend health endpoint that reaches into the db and return a status message to a frontend status page. Visit that page and ensure things are healthy
inputs:
deploy-env:
description: The environment being deployed (e.g. "prod" or "test")
required: true

smoke-test-front-and-back-end:
runs-on: ubuntu-latest
steps:
- name: create env file
working-directory: frontend
run: |
touch .env
echo REACT_APP_BASE_URL=https://${{ inputs.deploy_env }}.simplereport.gov/ >> .env.production.local
- name: Run smoke test script
working-directory: frontend
run: yarn smoke:prod:deploy:ci

# slack_alert:
# runs-on: ubuntu-latest
# if: failure()
# needs: [ smoke-test-front-and-back-end ]
# steps:
# - uses: actions/checkout@v4
# - name: Send alert to Slack
# uses: ./.github/actions/slack-message
# with:
# username: ${{ github.actor }}
# description: |
# :siren-gif: Post-deploy smoke test couldn't verify that the frontend is talking to the backend. ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} :siren-gif:
# webhook_url: ${{ secrets.SR_ALERTS_SLACK_WEBHOOK_URL }}
# user_map: $${{ secrets.SR_ALERTS_GITHUB_SLACK_MAP }}
65 changes: 0 additions & 65 deletions .github/workflows/smokeTestDeploy.yml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/smokeTestDeployDev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Smoke test deploy
run-name: Smoke test the deploy for ${{ inputs.deploy_env }} by @${{ github.actor }}

on:
# DELETE ME WHEN MERGING
push:
workflow_dispatch:
inputs:
deploy_env:
description: 'The environment to smoke test'
required: true
type: choice
options:
- ""
- dev
- dev2
- dev3
- dev4
- dev5
- dev6
- dev7
- pentest

env:
NODE_VERSION: 18

jobs:
smoke-test-front-and-back-end:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Cache yarn
uses: actions/[email protected]
with:
path: ~/.cache/yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Set up dependencies
working-directory: frontend
run: yarn install --prefer-offline
- name: Smoke test the env
uses: ./.github/actions/post-deploy-smoke-test
with:
# REPLACE ME WITH deploy-env: ${{inputs.deploy_env}}
deploy-env: dev7

34 changes: 34 additions & 0 deletions .github/workflows/smokeTestDeployProd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Smoke test deploy
run-name: Smoke test the deploy for ${{ inputs.deploy_env }} by @${{ github.actor }}

on:
# DELETE ME WHEN MERGING
push:
workflow_run:
workflows: [ " Deploy Prod" ]
types:
- completed

env:
NODE_VERSION: 18
DEPLOY_ENV: prod

jobs:
smoke-test-front-and-back-end:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Cache yarn
uses: actions/[email protected]
with:
path: ~/.cache/yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
- name: Set up dependencies
working-directory: frontend
run: yarn install --prefer-offline
- name: Smoke test the env
uses: ./.github/actions/post-deploy-smoke-test
with:
deploy-env: ${{env.DEPLOY_ENV}}
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"maintenance:start": "[ -z \"$MAINTENANCE_MESSAGE\" ] && echo \"MAINTENANCE_MESSAGE must be set!\" || (echo $MAINTENANCE_MESSAGE > maintenance.json && yarn maintenance:deploy && rm maintenance.json)",
"maintenance:deploy": "[ -z \"$MAINTENANCE_ENV\" ] && echo \"MAINTENANCE_ENV must be set!\" || az storage blob upload -f maintenance.json -n maintenance.json -c '$web' --account-name simplereport${MAINTENANCE_ENV}app --overwrite",
"smoke:prod:deploy": "node prod-smoke.js",
"smoke:prod:deploy:ci": "node -r dotenv/config prod-smoke.js dotenv_config_path=.env.production dotenv_config_debug=true"
"smoke:prod:deploy:ci": "node -r dotenv/config prod-smoke.js dotenv_config_path=.env.production.local dotenv_config_debug=true"
},
"prettier": {
"singleQuote": false
Expand Down

0 comments on commit e4f9211

Please sign in to comment.