-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add gh actions config [PT-188007060]
- Loading branch information
Showing
2 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
name: Continuous Integration | ||
|
||
on: push | ||
|
||
jobs: | ||
build_test: | ||
name: Build and Run Jest Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
- name: Install Dependencies | ||
run: npm ci | ||
- name: Build | ||
run: npm run build | ||
- name: Run Tests | ||
run: npm run test:coverage -- --runInBand | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
flags: jest | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
cypress: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
# when one test fails, DO NOT cancel the other | ||
# containers, because this will kill Cypress processes | ||
# leaving the Dashboard hanging ... | ||
# https://github.com/cypress-io/github-action/issues/48 | ||
fail-fast: false | ||
matrix: | ||
# run 3 copies of the current job in parallel | ||
containers: [1, 2, 3] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- uses: cypress-io/github-action@v6 | ||
with: | ||
start: npm start | ||
wait-on: 'http://localhost:8080' | ||
# only record the results to dashboard.cypress.io if CYPRESS_RECORD_KEY is set | ||
record: ${{ !!secrets.CYPRESS_RECORD_KEY }} | ||
# only do parallel if we have a record key | ||
parallel: ${{ !!secrets.CYPRESS_RECORD_KEY }} | ||
env: | ||
# pass the Dashboard record key as an environment variable | ||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | ||
# pass GitHub token to allow accurately detecting a build vs a re-run build | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# turn on code coverage when running npm start | ||
# so far we've been using a webpack coverage-istanbul-loader for this | ||
# but there has been work on using the code coverage support in the browser directly, | ||
# which should be much faster | ||
CODE_COVERAGE: true | ||
# Also turn on the code coverage tasks in cypress itself, these are disabled | ||
# by default. | ||
CYPRESS_coverage: true | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
flags: cypress | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
s3-deploy: | ||
name: S3 Deploy | ||
needs: | ||
- build_test | ||
- cypress | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: ${{ github.ref_type == 'branch' && 'branches' || 'versions' }} | ||
url: https://models-resources.concord.org/codap-day-length-plugin-3/${{ steps.s3-deploy.outputs.deployPath }}/index.html | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
- name: Install Dependencies | ||
run: npm ci | ||
env: | ||
# skip installing cypress since it isn't needed for just building | ||
# This decreases the deploy time quite a bit | ||
CYPRESS_INSTALL_BINARY: 0 | ||
- uses: concord-consortium/s3-deploy-action@v1 | ||
id: s3-deploy | ||
with: | ||
bucket: models-resources | ||
prefix: codap-day-length-plugin-3 | ||
awsAccessKeyId: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
awsSecretAccessKey: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
# Parameters to GHActions have to be strings, so a regular yaml array cannot | ||
# be used. Instead the `|` turns the following lines into a string | ||
topBranches: | | ||
["main"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: Release | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: The git tag for the version to use for index.html | ||
required: true | ||
env: | ||
BUCKET: models-resources | ||
PREFIX: codap-day-length-plugin-3 | ||
SRC_FILE: index-top.html | ||
DEST_FILE: index.html | ||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: > | ||
aws s3 cp | ||
s3://${{ env.BUCKET }}/${{ env.PREFIX }}/version/${{ github.event.inputs.version }}/${{ env.SRC_FILE }} | ||
s3://${{ env.BUCKET }}/${{ env.PREFIX }}/${{ env.DEST_FILE }} | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
AWS_DEFAULT_REGION: us-east-1 |