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-10-15 20:58:54 +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
|
|
|
lint:
|
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
|
|
|
|
steps:
|
2020-10-14 19:57:45 +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
|
2020-10-15 21:14:33 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
2020-10-14 19:57:45 +03:00
|
|
|
name: Check out repo
|
2020-10-15 15:45:27 +03:00
|
|
|
uses: actions/checkout@a81bbbf8298c0fa03ea29cdc473d45769f953675
|
2020-09-27 15:10:11 +03:00
|
|
|
|
2020-10-15 21:14:33 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
2020-10-14 19:57:45 +03:00
|
|
|
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-10-15 21:14:33 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
2020-10-14 19:57:45 +03:00
|
|
|
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-10-15 21:14:33 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
2020-10-14 19:57:45 +03:00
|
|
|
name: Cache node modules
|
2020-10-15 15:45:27 +03:00
|
|
|
uses: actions/cache@d1255ad9362389eac595a9ae406b8e8cb3331f16
|
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-10-15 21:14:33 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
2020-10-14 19:57:45 +03:00
|
|
|
name: Install dependencies
|
2020-09-27 15:10:11 +03:00
|
|
|
run: npm ci
|
|
|
|
|
2020-11-02 22:23:46 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' && GITHUB_REPOSITORY == 'github/docs-internal' }}
|
2020-10-23 21:00:42 +03:00
|
|
|
name: Clone early access
|
|
|
|
run: npm run heroku-prebuild
|
|
|
|
env:
|
|
|
|
DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }}
|
|
|
|
|
2020-10-15 21:14:33 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
2020-10-14 19:57:45 +03:00
|
|
|
name: Run linter
|
2020-09-27 15:10:11 +03:00
|
|
|
run: npx standard
|
|
|
|
|
2020-10-15 21:14:33 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
2020-10-14 19:57:45 +03:00
|
|
|
name: Check dependencies
|
2020-09-27 15:10:11 +03:00
|
|
|
run: npm run check-deps
|
|
|
|
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
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
test-group: [content, meta, rendering, routing, unit, links-and-images]
|
|
|
|
steps:
|
2020-10-14 19:57:45 +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
|
2020-10-15 21:14:33 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
2020-10-14 19:57:45 +03:00
|
|
|
name: Check out repo
|
2020-10-15 15:45:27 +03:00
|
|
|
uses: actions/checkout@a81bbbf8298c0fa03ea29cdc473d45769f953675
|
2020-09-27 15:10:11 +03:00
|
|
|
|
2020-10-15 21:14:33 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
2020-10-14 19:57:45 +03:00
|
|
|
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-10-15 21:14:33 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
2020-10-14 19:57:45 +03:00
|
|
|
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-10-15 21:14:33 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
2020-10-14 19:57:45 +03:00
|
|
|
name: Cache node modules
|
2020-10-15 15:45:27 +03:00
|
|
|
uses: actions/cache@d1255ad9362389eac595a9ae406b8e8cb3331f16
|
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-10-15 21:14:33 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
2020-10-14 19:57:45 +03:00
|
|
|
name: Install dependencies
|
2020-09-27 15:10:11 +03:00
|
|
|
run: npm ci
|
|
|
|
|
2020-10-26 16:52:35 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' && GITHUB_REPOSITORY == 'github/docs-internal' }}
|
2020-10-23 21:00:42 +03:00
|
|
|
name: Clone early access
|
|
|
|
run: npm run heroku-prebuild
|
|
|
|
env:
|
|
|
|
DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }}
|
|
|
|
|
2020-10-15 21:14:33 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
2020-10-14 19:57:45 +03:00
|
|
|
name: Run build script
|
2020-09-27 15:10:11 +03:00
|
|
|
run: npm run build
|
|
|
|
|
2020-10-15 21:14:33 +03:00
|
|
|
- if: ${{ needs.see_if_should_skip.outputs.should_skip != 'true' }}
|
2020-10-14 19:57:45 +03:00
|
|
|
name: Run tests
|
2020-09-27 15:10:11 +03:00
|
|
|
run: npx jest tests/${{ matrix.test-group }}/
|
|
|
|
|
|
|
|
- name: Send Slack notification if workflow fails
|
2020-10-15 16:07:01 +03:00
|
|
|
uses: rtCamp/action-slack-notify@e17352feaf9aee300bf0ebc1dfbf467d80438815
|
2020-09-27 15:10:11 +03:00
|
|
|
if: failure() && github.ref == 'early-access'
|
|
|
|
env:
|
|
|
|
SLACK_WEBHOOK: ${{ secrets.DOCS_ALERTS_SLACK_WEBHOOK }}
|
2020-10-14 17:43:31 +03:00
|
|
|
SLACK_MESSAGE: "Tests are failing on the `early-access` branch. https://github.com/github/docs-internal/tree/early-access"
|