mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-02-23 10:04:18 -08:00
Modify staging GHA to run cypress in parallel
This commit is contained in:
parent
29d5b52f84
commit
65e2ccfe82
2 changed files with 62 additions and 13 deletions
73
.github/workflows/deploy_staging.yml
vendored
73
.github/workflows/deploy_staging.yml
vendored
|
@ -10,7 +10,10 @@ on:
|
|||
env:
|
||||
PR_NUMBER: ${{github.event.pull_request.number}}
|
||||
WORKING_DIRECTORY: ./client
|
||||
|
||||
jobs:
|
||||
|
||||
# This job will install, build, lint, run unit tests and upload the application artifact
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
|
@ -21,16 +24,20 @@ jobs:
|
|||
node-version: [14.x]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Set DESTINATION_FOLDER for branch
|
||||
run: |
|
||||
echo "DESTINATION_FOLDER=$(echo $PR_NUMBER-$GITHUB_SHA | cut -c 1-11)" >> $GITHUB_ENV
|
||||
- name: Install
|
||||
|
||||
- name: Install app
|
||||
run: npm ci
|
||||
- name: Build
|
||||
|
||||
- name: Build app
|
||||
run: npm run build --if-present
|
||||
env:
|
||||
# See the client readme for more info on environment variables:
|
||||
|
@ -38,23 +45,23 @@ jobs:
|
|||
DATA_SOURCE: cdn
|
||||
SITE_URL: "http://usds-geoplatform-justice40-website.s3-website-us-east-1.amazonaws.com/"
|
||||
PATH_PREFIX: "/justice40-tool/${{env.DESTINATION_FOLDER}}"
|
||||
|
||||
- name: Get directory contents
|
||||
run: ls -la public
|
||||
- name: Lint
|
||||
|
||||
- name: Lint app
|
||||
run: npm run lint
|
||||
# Disabling for now due to jsonlint - TODO: put this back
|
||||
|
||||
# Disabling for now due to jsonlint - TODO: put this back
|
||||
# - name: License Check
|
||||
# run: npm run licenses
|
||||
- name: Test
|
||||
|
||||
- name: Run unit tests on app
|
||||
run: npm test
|
||||
|
||||
- name: Check for security vulnerabilities
|
||||
run: npm audit --production
|
||||
- name: Cypress / Gherkin integration tests 🌃
|
||||
uses: cypress-io/github-action@v2
|
||||
with:
|
||||
working-directory: ${{env.WORKING_DIRECTORY}}
|
||||
start: npm start
|
||||
wait-on: 'http://localhost:8000'
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
|
@ -62,20 +69,58 @@ jobs:
|
|||
# Upload-artifact does not support the default working directory
|
||||
# See more: https://github.com/actions/upload-artifact/issues/87
|
||||
path: ./client/public
|
||||
deploy:
|
||||
|
||||
# This job will run the end-to-end cypress/gherkin tests in parallel
|
||||
e2e-tests:
|
||||
runs-on: ubuntu-latest
|
||||
container: cypress/browsers:node12.18.3-chrome87-ff82
|
||||
needs: build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# run copies of the current job in parallel
|
||||
containers: [1, 2, 3, 4, 5]
|
||||
steps:
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Download Artifacts
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: J40Static
|
||||
path: ./public
|
||||
|
||||
- name: Cypress / Gherkin integration tests 🌃
|
||||
uses: cypress-io/github-action@v2
|
||||
with:
|
||||
working-directory: ${{env.WORKING_DIRECTORY}}
|
||||
start: npm start
|
||||
wait-on: 'http://localhost:8000'
|
||||
env:
|
||||
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS.PROJECT_ID}}
|
||||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
||||
# Recommended: pass the GitHub token lets this action correctly
|
||||
# determine the unique run id necessary to re-run the checks
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# This job will download artifacts, deploy to GH pages and deploy to AWS
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: e2e-tests
|
||||
steps:
|
||||
- name: Checkout source
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Download Artifacts
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: J40Static
|
||||
path: ./public
|
||||
|
||||
- name: Set DESTINATION_FOLDER for branch
|
||||
run: |
|
||||
echo "DESTINATION_FOLDER=$(echo $PR_NUMBER-$GITHUB_SHA | cut -c 1-11)" >> $GITHUB_ENV
|
||||
|
||||
- name: Deploy to Github Pages
|
||||
uses: JamesIves/github-pages-deploy-action@4.1.0
|
||||
with:
|
||||
|
@ -83,14 +128,17 @@ jobs:
|
|||
FOLDER: public # The folder the action should deploy.
|
||||
TARGET-FOLDER: ${{env.DESTINATION_FOLDER}} # If we're on a PR branch, merge to PR folder
|
||||
CLEAN: true
|
||||
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-access-key-id: ${{ secrets.CLIENT_DEV_AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.CLIENT_DEV_AWS_SECRET_ACCESS_KEY }}
|
||||
aws-region: us-east-1
|
||||
|
||||
- name: Deploy to Geoplatform AWS
|
||||
run: aws s3 sync ./public/ s3://usds-geoplatform-justice40-website/justice40-tool/${{env.DESTINATION_FOLDER}} --acl public-read --delete
|
||||
|
||||
- name: Update PR with deployed URL
|
||||
uses: mshick/add-pr-comment@v1
|
||||
with:
|
||||
|
@ -101,6 +149,7 @@ jobs:
|
|||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
repo-token-user-login: "github-actions[bot]" # The user.login for temporary GitHub tokens
|
||||
allow-repeats: false # This is the default
|
||||
|
||||
- name: Printing deployment URLs
|
||||
run: |
|
||||
echo "Github pages: https://usds.github.io/justice40-tool/$DESTINATION_FOLDER/en"
|
||||
|
|
|
@ -7,6 +7,6 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<!-- your content here... adding comment to trigger build-->
|
||||
<!-- your content here...-->
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Reference in a new issue