2020-09-27 15:10:11 +03:00
|
|
|
# NOTE: Changes to this file should also be applied to './test-windows.yml' and './test-translations.yml'
|
|
|
|
|
|
|
|
name: Node.js Tests
|
|
|
|
|
|
|
|
on:
|
2020-10-14 17:43:31 +03:00
|
|
|
workflow_dispatch:
|
2020-09-27 15:10:11 +03:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
pull_request:
|
|
|
|
branches-ignore:
|
|
|
|
- translations
|
|
|
|
|
|
|
|
env:
|
|
|
|
CI: true
|
|
|
|
|
|
|
|
jobs:
|
2020-10-14 19:57:45 +03:00
|
|
|
see_if_should_skip:
|
2020-10-15 19:49:16 +03:00
|
|
|
continue-on-error: true
|
2020-10-14 19:57:45 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
# Map a step output to a job output
|
|
|
|
outputs:
|
|
|
|
should_skip: ${{ steps.skip_check.outputs.should_skip }}
|
|
|
|
steps:
|
|
|
|
- id: skip_check
|
2020-10-16 00:54:23 +03:00
|
|
|
uses: fkirc/skip-duplicate-actions@36feb0d8d062137530c2e00bd278d138fe191289
|
2020-10-14 19:57:45 +03:00
|
|
|
with:
|
|
|
|
cancel_others: 'false'
|
|
|
|
github_token: ${{ github.token }}
|
2020-11-03 19:24:08 +03:00
|
|
|
paths: '[".github/workflows/test.yml", ".node-version", ".npmrc", "app.json", "content/**", "data/**","lib/**", "Dockerfile", "feature-flags.json", "Gemfile", "Gemfile.lock", "middleware/**", "node_modules/**","package.json", "package-lock.json", "server.js", "tests/**", "translations/**", "Procfile", "webpack.config.js"]'
|
2020-09-27 15:10:11 +03:00
|
|
|
|
|
|
|
test:
|
2020-10-14 19:57:45 +03:00
|
|
|
needs: see_if_should_skip
|
2020-09-27 15:10:11 +03:00
|
|
|
runs-on: ubuntu-latest
|
2020-10-29 23:41:01 +03:00
|
|
|
timeout-minutes: 60
|
2020-09-27 15:10:11 +03:00
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
test-group: [content, meta, rendering, routing, unit, links-and-images]
|
|
|
|
steps:
|
2020-11-16 17:07:00 +03:00
|
|
|
# Each of these ifs needs to be repeated at each step to make sure the required check still runs
|
|
|
|
# Even if if doesn't do anything
|
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
|
|
|
name: Check out repo
|
2020-11-04 19:54:53 +03:00
|
|
|
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
|
2020-11-09 22:09:52 +03:00
|
|
|
with:
|
|
|
|
# Enables cloning the Early Access repo later with the relevant PAT
|
|
|
|
persist-credentials: 'false'
|
2020-09-27 15:10:11 +03:00
|
|
|
|
2020-11-16 17:07:00 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
|
|
|
name: Setup node
|
2020-10-15 15:45:27 +03:00
|
|
|
uses: actions/setup-node@56899e050abffc08c2b3b61f3ec6a79a9dc3223d
|
2020-09-27 15:10:11 +03:00
|
|
|
with:
|
2020-10-06 03:02:55 +03:00
|
|
|
node-version: 14.x
|
2020-09-27 15:10:11 +03:00
|
|
|
|
2020-11-16 17:07:00 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
|
|
|
name: Get npm cache directory
|
2020-09-27 15:10:11 +03:00
|
|
|
id: npm-cache
|
|
|
|
run: |
|
|
|
|
echo "::set-output name=dir::$(npm config get cache)"
|
|
|
|
|
2020-11-16 17:07:00 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
|
|
|
name: Cache node modules
|
2020-11-09 18:19:53 +03:00
|
|
|
uses: actions/cache@0781355a23dac32fd3bac414512f4b903437991a
|
2020-09-27 15:10:11 +03:00
|
|
|
with:
|
|
|
|
path: ${{ steps.npm-cache.outputs.dir }}
|
|
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-node-
|
|
|
|
|
2020-11-16 17:07:00 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
|
|
|
name: Install dependencies
|
2020-09-27 15:10:11 +03:00
|
|
|
run: npm ci
|
|
|
|
|
2020-11-09 22:09:52 +03:00
|
|
|
- name: Clone early access
|
|
|
|
if: ${{ github.repository == 'github/docs-internal' }}
|
2020-11-03 19:30:11 +03:00
|
|
|
run: npm run heroku-postbuild
|
2020-10-23 21:00:42 +03:00
|
|
|
env:
|
|
|
|
DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }}
|
2020-11-17 22:51:48 +03:00
|
|
|
GIT_BRANCH: ${{ github.ref }}
|
2020-10-23 21:00:42 +03:00
|
|
|
|
2020-11-06 06:20:08 +03:00
|
|
|
- name: Run build script
|
2020-11-16 21:07:53 +03:00
|
|
|
if: ${{ github.repository != 'github/docs-internal' and needs.see_if_should_skip.outputs.should_skip != 'true'}}
|
2020-09-27 15:10:11 +03:00
|
|
|
run: npm run build
|
|
|
|
|
2020-11-16 17:07:00 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
|
|
|
name: Run tests
|
2020-09-27 15:10:11 +03:00
|
|
|
run: npx jest tests/${{ matrix.test-group }}/
|
2020-11-04 00:15:55 +03:00
|
|
|
env:
|
|
|
|
NODE_OPTIONS: "--max_old_space_size=4096"
|