forked from alphagov/govuk-design-system
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (102 loc) · 3.16 KB
/
test.yaml
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
125
126
127
128
129
130
name: Test
on:
pull_request:
push:
branches:
- 'feature/**'
- 'v[0-9]'
workflow_call:
inputs:
upload-artifact:
default: false
required: false
type: boolean
workflow_dispatch:
inputs:
runner:
description: Run tests on
type: choice
default: ubuntu-latest
options:
- macos-latest
- ubuntu-latest
- windows-latest
jobs:
build:
name: Build
runs-on: ${{ github.event.inputs.runner || 'ubuntu-latest' }}
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Restore build
uses: actions/[email protected]
id: build-cache
with:
key: build-cache-${{ runner.os }}-${{ github.sha }}
path: deploy/public
- name: Setup Node.js
uses: actions/[email protected]
if: steps.build-cache.outputs.cache-hit != 'true'
with:
cache: npm
node-version-file: .nvmrc
- name: Install dependencies
if: steps.build-cache.outputs.cache-hit != 'true'
run: npm ci
- name: Build
if: steps.build-cache.outputs.cache-hit != 'true'
run: npm run build
# Share data between the build and deploy jobs so we don't need to run `npm run build` again on deploy
# Upload the deploy folder as an artifact so it can be downloaded and used in the deploy job
- name: Upload artifact
uses: actions/[email protected]
if: ${{ inputs.upload-artifact }}
with:
name: build
path: deploy/**
retention-days: 1
test:
name: ${{ matrix.task.description }}
runs-on: ${{ github.event.inputs.runner || 'ubuntu-latest' }}
needs: [build]
strategy:
fail-fast: false
matrix:
task:
- description: Lint Sass
run: npm run lint:scss
- description: Lint JavaScript
run: npm run lint:js
- description: Lint HTML
run: npm run lint:html --ignore-scripts
- description: EditorConfig
run: npm run lint:editorconfig
- description: Prettier
run: npm run lint:prettier
continue-on-error: true
- description: JavaScript tests
run: npx jest --color --maxWorkers=2
- description: Check broken links
run: npm run check-links
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup Node.js
uses: actions/[email protected]
with:
cache: npm
node-version-file: .nvmrc
- name: Install dependencies
run: npm ci
- name: Restore build
uses: actions/cache/[email protected]
with:
key: build-cache-${{ runner.os }}-${{ github.sha }}
path: deploy/public
- name: Run task
id: task
run: ${{ matrix.task.run }}
continue-on-error: ${{ matrix.task.continue-on-error || false }}
- name: Task warnings
if: steps.task.outcome == 'failure'
run: echo "::warning title=${{ matrix.task.description }} task failed::Check has been temporarily ignored"