Increment the build number #5294
Workflow file for this run
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
name: Continuous Integration (CODAP v3) | |
on: | |
push: | |
paths: # only run this workflow if it contains v3 files | |
- 'v3/**' # https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#example-including-paths | |
- '.github/workflows/v3.yml' | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: snow-actions/sparse-checkout@v1.2.0 | |
with: | |
patterns: v3 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
cache-dependency-path: v3/package-lock.json | |
- name: Install Dependencies | |
working-directory: v3 | |
run: npm ci | |
- name: Restore ESLint Cache | |
id: restore-eslint-cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: v3/.cache/eslint/ | |
key: eslint-${{ hashFiles('v3/package-lock.json', 'v3/.eslintrc.build.cjs', 'v3/.eslintrc.cjs') }} | |
- name: Lint | |
working-directory: v3 | |
run: npm run lint:build | |
- name: Save ESLint Cache | |
uses: actions/cache/save@v4 | |
# Always save the cache on the main branch, it won't be built often and | |
# this way features branches will have an up-to-date main cache | |
if: github.ref_name == 'main' || steps.restore-eslint-cache.outputs.cache-hit != 'true' | |
with: | |
path: v3/.cache/eslint/ | |
key: ${{steps.restore-eslint-cache.outputs.cache-primary-key}} | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: snow-actions/sparse-checkout@v1.2.0 | |
with: | |
patterns: v3 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
cache-dependency-path: v3/package-lock.json | |
- name: Install Dependencies | |
working-directory: v3 | |
run: npm ci | |
- name: Restore Webpack Cache | |
id: restore-webpack-cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: v3/.cache/webpack/ | |
key: webpack-build-${{ hashFiles('v3/webpack.config.js') }} | |
- uses: concord-consortium/s3-deploy-action/deploy-path@v1 | |
id: s3-deploy-path | |
- name: Configure Environment | |
working-directory: v3 | |
run: | | |
cat <<EOF > .env | |
GOOGLE_DRIVE_CLIENT_ID="${{ secrets.GOOGLE_DRIVE_CLIENT_ID }}" | |
GOOGLE_DRIVE_API_KEY="${{ secrets.GOOGLE_DRIVE_API_KEY }}" | |
GOOGLE_DRIVE_APP_ID="${{ secrets.GOOGLE_DRIVE_APP_ID }}" | |
EOF | |
- name: Build | |
working-directory: v3 | |
run: npm run build:ci | |
env: | |
DEPLOY_PATH: ${{ steps.s3-deploy-path.outputs.deployPath }} | |
- name: Save Webpack Cache | |
uses: actions/cache/save@v4 | |
# Always save the cache on the main branch, it won't be built often and | |
# this way features branches will have an up-to-date main cache | |
if: github.ref_name == 'main' || steps.restore-webpack-cache.outputs.cache-hit != 'true' | |
with: | |
path: v3/.cache/webpack/ | |
key: ${{steps.restore-webpack-cache.outputs.cache-primary-key}} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: build | |
path: v3/dist/ | |
jest: | |
name: Run Jest Tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: snow-actions/sparse-checkout@v1.2.0 | |
with: | |
patterns: v3 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
cache-dependency-path: v3/package-lock.json | |
- name: Install Dependencies | |
working-directory: v3 | |
run: npm ci | |
- name: Jest Cache | |
uses: actions/cache@v4 | |
with: | |
path: /tmp/jest_rt | |
key: jest-${{ hashFiles('v3/package-lock.json') }} | |
- name: Get number of CPU cores | |
id: cpu-cores | |
uses: SimenB/github-actions-cpu-cores@v2 | |
- name: Run Tests | |
working-directory: v3 | |
run: npm run test:coverage -- --maxWorkers=${{ steps.cpu-cores.outputs.count }} | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
flags: jest | |
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 | |
steps: | |
- uses: browser-actions/setup-chrome@v1 | |
with: | |
chrome-version: stable | |
- uses: snow-actions/sparse-checkout@v1.2.0 | |
with: | |
patterns: v3 | |
- name: Restore Webpack Cache | |
id: restore-webpack-cache | |
uses: actions/cache/restore@v4 | |
with: | |
path: v3/.cache/webpack/ | |
# this key is different from the build job above because this is a dev build so its | |
# folder in the cache will be different and cached data is also likely different | |
key: webpack-dev-build-${{ hashFiles('v3/webpack.config.js') }} | |
- uses: cypress-io/github-action@v6 | |
with: | |
working-directory: v3 | |
start: npm start | |
wait-on: 'http://localhost:8080' | |
# add timeout of 5 minutes to start | |
wait-on-timeout: 300 | |
# only record the results to dashboard.cypress.io if CYPRESS_RECORD_KEY is set | |
record: ${{ !!secrets.CYPRESS_RECORD_KEY }} | |
browser: chrome | |
# only run a single test | |
# TODO: setup a special test for this purpose | |
spec: cypress/e2e/smoke/single-codap-smoke.ts | |
group: 'Smoke Tests' | |
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 | |
# Have webpack skip eslint checking, that was already done by the build step | |
SKIP_ESLINT: true | |
- name: Save Webpack Cache | |
uses: actions/cache/save@v4 | |
# Always save the cache on the main branch, it won't be built often and | |
# this way features branches will have an up-to-date main cache | |
if: github.ref_name == 'main' || steps.restore-webpack-cache.outputs.cache-hit != 'true' | |
with: | |
path: v3/.cache/webpack/ | |
key: ${{steps.restore-webpack-cache.outputs.cache-primary-key}} | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
flags: cypress | |
s3-deploy: | |
name: S3 Deploy | |
needs: | |
- lint | |
- build | |
- jest | |
- cypress | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ github.ref_type == 'branch' && 'branches' || 'versions' }} | |
url: https://codap3.concord.org/${{ steps.s3-deploy.outputs.deployPath }}/ | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: build | |
path: v3/dist | |
- uses: concord-consortium/s3-deploy-action@v1 | |
id: s3-deploy | |
with: | |
build: echo no build | |
bucket: models-resources | |
prefix: codap3 | |
workingDirectory: v3 | |
awsAccessKeyId: ${{ secrets.V3_AWS_ACCESS_KEY_ID }} | |
awsSecretAccessKey: ${{ secrets.V3_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"] |