-
-
Notifications
You must be signed in to change notification settings - Fork 55
114 lines (97 loc) · 3.21 KB
/
Copy pathcode-quality.yml
File metadata and controls
114 lines (97 loc) · 3.21 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
# 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: ["main"]
paths:
- "recipes/**/*.js"
- "recipes/**/*.ts"
- "recipes/**/package.json"
- "utils/**/*.js"
- "utils/**/*.ts"
- "utils/package.json"
- "package.json"
- ".github/workflows/code-quality.yml"
pull_request:
branches: ["*"]
paths:
- "recipes/**/*.js"
- "recipes/**/*.ts"
- "recipes/**/package.json"
- "utils/**/*.js"
- "utils/**/*.ts"
- "utils/**/package.json"
- "package.json"
- ".github/workflows/code-quality.yml"
types:
- opened
- ready_for_review
- reopened
- synchronize
permissions:
contents: read
jobs:
lint-and-types:
name: Lint & types
runs-on: ubuntu-slim
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: audit
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
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-slim
- windows-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: audit
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
persist-credentials: false
show-progress: false
# ubuntu-slim already include lts node so we don't need to setup node on ubuntu-slim runner
- name: Set up Node.js
if: ${{ matrix.os != 'ubuntu-slim' }}
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.event.before }} ${{ 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=/'
)