-
-
Notifications
You must be signed in to change notification settings - Fork 1
140 lines (124 loc) · 4.86 KB
/
Copy pathlint-and-test.yml
File metadata and controls
140 lines (124 loc) · 4.86 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: Lint and test
# Also on live, for two reasons: a pull-request-only workflow leaves the
# default branch with no status, so the README badge reports whichever branch
# ran last; and the queue squashes without rebuilding, so nothing else sees
# what actually landed.
on:
pull_request:
push:
branches:
- live
jobs:
lint_and_test:
name: Lint and test
runs-on: ubuntu-latest
steps:
- name: Check out project repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# `verify.commits` compares against the base branch, which a
# single-commit checkout does not contain.
fetch-depth: 0
- name: Set up Node.js runtime
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: 'package.json'
- name: Install
run: |
# No corepack: node is unbundling it, and pnpm reads
# `packageManager` and fetches that version itself. Installing the
# named one rather than the newest saves fetching pnpm twice.
npm install --global "pnpm@$(node -p "require('./package.json').packageManager.replace('pnpm@','').split('+')[0]")"
pnpm --version
pnpm install
echo "$(pwd)/node_modules/.bin" >> $GITHUB_PATH
- name: Build
run: nps build
# Checks to see if any files in the PR match one of the listed file types.
# We can use this filter to decide whether or not to run linters or tests.
# You can check if a file with a listed file type is in the PR by doing:
# if: ${{ steps.filter.outputs.md == 'true' }}
# This will return true if there's a Markdown file the PR has changed.
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
id: filter
with:
filters: |
browserslist:
- '.browserslistrc'
dockerfile:
- '**/Dockerfile'
js:
- '**/*.js'
- '**/*.mjs'
json:
- '**/*.json'
- '**/*.json5'
- '**/*.jsonc'
liquid:
- '**/*.html'
- '**/*.liquid'
md:
- '**/*.md'
scss:
- '**/*.scss'
svg:
- '**/*.svg'
toml:
- '**/*.toml'
ts:
- '**/*.ts'
- '**/*.mts'
yaml:
- '**/*.yml'
- '**/*.yaml'
# Not behind a filter: every pull request has commit messages, whatever
# it touches.
- name: Verify commit messages
run: nps verify.commits
# Use the filter to check if files with a specific file type were changed
# in the PR. If they were, run the relevant linters. Otherwise, skip.
- name: Verify Browserslist
if: ${{ steps.filter.outputs.browserslist == 'true' }}
run: nps verify.browserslist
- name: Verify Dockerfile
if: ${{ steps.filter.outputs.dockerfile == 'true' }}
run: nps verify.dockerfile
- name: Verify JavaScript
if: ${{ steps.filter.outputs.js == 'true' }}
run: nps verify.js
- name: Verify JSON
if: ${{ steps.filter.outputs.json == 'true' }}
run: nps verify.json
- name: Verify Liquid
if: ${{ steps.filter.outputs.liquid == 'true' }}
run: nps verify.liquid
- name: Verify Markdown
if: ${{ steps.filter.outputs.md == 'true' }}
run: nps verify.md
- name: Verify SCSS
if: ${{ steps.filter.outputs.scss == 'true' }}
run: nps verify.scss
- name: Verify SVG
if: ${{ steps.filter.outputs.svg == 'true' }}
run: nps verify.svg
- name: Verify TOML
if: ${{ steps.filter.outputs.toml == 'true' }}
run: nps verify.toml
- name: Verify TypeScript
if: ${{ steps.filter.outputs.ts == 'true' }}
run: nps verify.ts
- name: Verify YAML
if: ${{ steps.filter.outputs.yaml == 'true' }}
run: nps verify.yaml
# Only run tests if the PR touches behavior-related files. On live
# everything runs, since nothing else checks what landed.
- name: Test
if: ${{ github.event_name == 'push' || steps.filter.outputs.js == 'true' || steps.filter.outputs.json == 'true' || steps.filter.outputs.ts == 'true' }}
# verify.validForEC fetches the editorconfig-checker binary from the
# GitHub API on first use, and node_modules is new on every run here.
# Unauthenticated that is 60 requests an hour shared with every other
# job leaving this address, which is a job failing for no reason of
# its own. The wrapper reads GITHUB_TOKEN and the runner is given one.
env:
GITHUB_TOKEN: ${{ github.token }}
run: nps test