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:
|
env:
|
||||||
PR_NUMBER: ${{github.event.pull_request.number}}
|
PR_NUMBER: ${{github.event.pull_request.number}}
|
||||||
WORKING_DIRECTORY: ./client
|
WORKING_DIRECTORY: ./client
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
|
||||||
|
# This job will install, build, lint, run unit tests and upload the application artifact
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
defaults:
|
defaults:
|
||||||
|
@ -21,16 +24,20 @@ jobs:
|
||||||
node-version: [14.x]
|
node-version: [14.x]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
|
|
||||||
- name: Set DESTINATION_FOLDER for branch
|
- name: Set DESTINATION_FOLDER for branch
|
||||||
run: |
|
run: |
|
||||||
echo "DESTINATION_FOLDER=$(echo $PR_NUMBER-$GITHUB_SHA | cut -c 1-11)" >> $GITHUB_ENV
|
echo "DESTINATION_FOLDER=$(echo $PR_NUMBER-$GITHUB_SHA | cut -c 1-11)" >> $GITHUB_ENV
|
||||||
- name: Install
|
|
||||||
|
- name: Install app
|
||||||
run: npm ci
|
run: npm ci
|
||||||
- name: Build
|
|
||||||
|
- name: Build app
|
||||||
run: npm run build --if-present
|
run: npm run build --if-present
|
||||||
env:
|
env:
|
||||||
# See the client readme for more info on environment variables:
|
# See the client readme for more info on environment variables:
|
||||||
|
@ -38,23 +45,23 @@ jobs:
|
||||||
DATA_SOURCE: cdn
|
DATA_SOURCE: cdn
|
||||||
SITE_URL: "http://usds-geoplatform-justice40-website.s3-website-us-east-1.amazonaws.com/"
|
SITE_URL: "http://usds-geoplatform-justice40-website.s3-website-us-east-1.amazonaws.com/"
|
||||||
PATH_PREFIX: "/justice40-tool/${{env.DESTINATION_FOLDER}}"
|
PATH_PREFIX: "/justice40-tool/${{env.DESTINATION_FOLDER}}"
|
||||||
|
|
||||||
- name: Get directory contents
|
- name: Get directory contents
|
||||||
run: ls -la public
|
run: ls -la public
|
||||||
- name: Lint
|
|
||||||
|
- name: Lint app
|
||||||
run: npm run lint
|
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
|
# - name: License Check
|
||||||
# run: npm run licenses
|
# run: npm run licenses
|
||||||
- name: Test
|
|
||||||
|
- name: Run unit tests on app
|
||||||
run: npm test
|
run: npm test
|
||||||
|
|
||||||
- name: Check for security vulnerabilities
|
- name: Check for security vulnerabilities
|
||||||
run: npm audit --production
|
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
|
- name: Upload Artifact
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
|
@ -62,20 +69,58 @@ jobs:
|
||||||
# Upload-artifact does not support the default working directory
|
# Upload-artifact does not support the default working directory
|
||||||
# See more: https://github.com/actions/upload-artifact/issues/87
|
# See more: https://github.com/actions/upload-artifact/issues/87
|
||||||
path: ./client/public
|
path: ./client/public
|
||||||
deploy:
|
|
||||||
|
# This job will run the end-to-end cypress/gherkin tests in parallel
|
||||||
|
e2e-tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
container: cypress/browsers:node12.18.3-chrome87-ff82
|
||||||
needs: build
|
needs: build
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
# run copies of the current job in parallel
|
||||||
|
containers: [1, 2, 3, 4, 5]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout source
|
- name: Checkout source
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Download Artifacts
|
- name: Download Artifacts
|
||||||
uses: actions/download-artifact@v2
|
uses: actions/download-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: J40Static
|
name: J40Static
|
||||||
path: ./public
|
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
|
- name: Set DESTINATION_FOLDER for branch
|
||||||
run: |
|
run: |
|
||||||
echo "DESTINATION_FOLDER=$(echo $PR_NUMBER-$GITHUB_SHA | cut -c 1-11)" >> $GITHUB_ENV
|
echo "DESTINATION_FOLDER=$(echo $PR_NUMBER-$GITHUB_SHA | cut -c 1-11)" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Deploy to Github Pages
|
- name: Deploy to Github Pages
|
||||||
uses: JamesIves/github-pages-deploy-action@4.1.0
|
uses: JamesIves/github-pages-deploy-action@4.1.0
|
||||||
with:
|
with:
|
||||||
|
@ -83,14 +128,17 @@ jobs:
|
||||||
FOLDER: public # The folder the action should deploy.
|
FOLDER: public # The folder the action should deploy.
|
||||||
TARGET-FOLDER: ${{env.DESTINATION_FOLDER}} # If we're on a PR branch, merge to PR folder
|
TARGET-FOLDER: ${{env.DESTINATION_FOLDER}} # If we're on a PR branch, merge to PR folder
|
||||||
CLEAN: true
|
CLEAN: true
|
||||||
|
|
||||||
- name: Configure AWS Credentials
|
- name: Configure AWS Credentials
|
||||||
uses: aws-actions/configure-aws-credentials@v1
|
uses: aws-actions/configure-aws-credentials@v1
|
||||||
with:
|
with:
|
||||||
aws-access-key-id: ${{ secrets.CLIENT_DEV_AWS_ACCESS_KEY_ID }}
|
aws-access-key-id: ${{ secrets.CLIENT_DEV_AWS_ACCESS_KEY_ID }}
|
||||||
aws-secret-access-key: ${{ secrets.CLIENT_DEV_AWS_SECRET_ACCESS_KEY }}
|
aws-secret-access-key: ${{ secrets.CLIENT_DEV_AWS_SECRET_ACCESS_KEY }}
|
||||||
aws-region: us-east-1
|
aws-region: us-east-1
|
||||||
|
|
||||||
- name: Deploy to Geoplatform AWS
|
- name: Deploy to Geoplatform AWS
|
||||||
run: aws s3 sync ./public/ s3://usds-geoplatform-justice40-website/justice40-tool/${{env.DESTINATION_FOLDER}} --acl public-read --delete
|
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
|
- name: Update PR with deployed URL
|
||||||
uses: mshick/add-pr-comment@v1
|
uses: mshick/add-pr-comment@v1
|
||||||
with:
|
with:
|
||||||
|
@ -101,6 +149,7 @@ jobs:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
repo-token-user-login: "github-actions[bot]" # The user.login for temporary GitHub tokens
|
repo-token-user-login: "github-actions[bot]" # The user.login for temporary GitHub tokens
|
||||||
allow-repeats: false # This is the default
|
allow-repeats: false # This is the default
|
||||||
|
|
||||||
- name: Printing deployment URLs
|
- name: Printing deployment URLs
|
||||||
run: |
|
run: |
|
||||||
echo "Github pages: https://usds.github.io/justice40-tool/$DESTINATION_FOLDER/en"
|
echo "Github pages: https://usds.github.io/justice40-tool/$DESTINATION_FOLDER/en"
|
||||||
|
|
|
@ -7,6 +7,6 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<!-- your content here... adding comment to trigger build-->
|
<!-- your content here...-->
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Add table
Reference in a new issue