forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
124 lines (107 loc) · 4.43 KB
/
Copy pathtest.yml
File metadata and controls
124 lines (107 loc) · 4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# NOTE: Changes to this file should also be applied to './test-windows.yml' and './test-translations.yml'
name: Node.js Tests
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches-ignore:
- translations
env:
CI: true
jobs:
see_if_should_skip:
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
uses: fkirc/skip-duplicate-actions@a12175f6209d4805b5a163d723270be2a0dc7b36
with:
cancel_others: 'false'
github_token: ${{ github.token }}
paths_ignore: '[".all-contributorsrc", ".env.example", ".gitattributes", ".vscode/**", "app.json", "assets/**", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "contributing/**", "crowdin-actions-config.yml", "crowdin.yml", "docs", "javascripts/**", "jest-puppeteer.config.js", "LICENSE-CODE", "LICENSE", "nodemon.json", "ownership.yaml", "README.md", "script/**", "stylesheets/**"]'
lint:
needs: see_if_should_skip
runs-on: ubuntu-latest
steps:
# 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 == 'false' }}
name: Check out repo
uses: actions/checkout@v2
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Setup node
uses: actions/setup-node@v1
with:
node-version: 14.x
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Cache node modules
uses: actions/cache@v2
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Install dependencies
run: npm ci
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Run linter
run: npx standard
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Check dependencies
run: npm run check-deps
test:
needs: see_if_should_skip
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test-group: [content, meta, rendering, routing, unit, links-and-images]
steps:
# 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 == 'false' }}
name: Check out repo
uses: actions/checkout@v2
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Setup node
uses: actions/setup-node@v1
with:
node-version: 14.x
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Get npm cache directory
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Cache node modules
uses: actions/cache@v2
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Install dependencies
run: npm ci
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Run build script
run: npm run build
- if: ${{ needs.see_if_should_skip.outputs.should_skip == 'false' }}
name: Run tests
run: npx jest tests/${{ matrix.test-group }}/
- name: Send Slack notification if workflow fails
uses: rtCamp/action-slack-notify@master
if: failure() && github.ref == 'early-access'
env:
SLACK_WEBHOOK: ${{ secrets.DOCS_ALERTS_SLACK_WEBHOOK }}
SLACK_MESSAGE: "Tests are failing on the `early-access` branch. https://github.com/github/docs-internal/tree/early-access"