-
-
Notifications
You must be signed in to change notification settings - Fork 55
136 lines (113 loc) · 3.77 KB
/
Copy pathcode-quality.yml
File metadata and controls
136 lines (113 loc) · 3.77 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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
# For more information see: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow
name: Code Quality
on:
push:
branches: ["*"]
paths:
- "recipes/**/*.js"
- "recipes/**/*.ts"
- "recipes/**/package.json"
- "utils/**/*.js"
- "utils/**/*.ts"
- "utils/package.json"
- "package.json"
- ".github/workflows/ci.yml"
pull_request:
branches: ["*"]
paths:
- "recipes/**/*.js"
- "recipes/**/*.ts"
- "recipes/**/package.json"
- "utils/**/*.js"
- "utils/**/*.ts"
- "utils/**/package.json"
- "package.json"
- ".github/workflows/ci.yml"
types:
- opened
- ready_for_review
- reopened
- synchronize
permissions:
contents: read
jobs:
get-matrix:
name: Get Node + OS matrix
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
outputs:
latest: ${{ steps.set-matrix.outputs.requireds }}
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- uses: ljharb/actions/node/matrix@7f214d8efdbdcefc96ad9689663ef387a195deec # main
id: set-matrix
with:
versionsAsRoot: true
type: majors
preset: ">= 22" # glob is not backported below 22.x
lint-and-types:
name: Lint & types
runs-on: ubuntu-slim
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
steps:
# FIXME https://github.com/step-security/harden-runner/issues/627
# - name: Harden the runner (Audit all outbound calls)
# uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
# with:
# egress-policy: audit
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
show-progress: false
- run: npm ci
- run: node --run lint
- run: node --run type-check
test:
name: Before/After tests
runs-on: ${{ matrix.os }}
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0
with:
egress-policy: audit
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: 0
persist-credentials: false
show-progress: false
- name: Set up Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
cache: "npm"
check-latest: true
node-version-file: ".nvmrc"
- run: npm ci
- name: Run tests related to changes
shell: bash
run: >
changed_paths=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }})
# run everything?
if echo "$changed_paths" | grep -qE '^(package\.json|\.github/workflows/ci\.yml|utils/)$'; then
npm run test --workspaces
exit 0
fi
# run for specific workspace(s)
npm run test $(
echo "$changed_paths" \
| grep '^recipes/'
| cut -d/ -f1,2
| sort -u
| sed 's/^/--workspace=/'
)