-
Notifications
You must be signed in to change notification settings - Fork 3
139 lines (119 loc) · 3.64 KB
/
pr.yml
File metadata and controls
139 lines (119 loc) · 3.64 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
name: Pull Request
on:
pull_request:
jobs:
prepare:
name: 'Prepare'
runs-on: ubuntu-24.04
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v5
- name: Set up matrix
id: set-matrix
run: |
chmod +x .github/scripts/set-matrix.sh
.github/scripts/set-matrix.sh
build:
name: 'Install and Build'
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Get yarn cache directory
id: yarn-cache-dir
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Cache yarn dependencies
uses: actions/cache@v4
with:
path: ${{ steps.yarn-cache-dir.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Cache node_modules
id: cache-node-modules
uses: actions/cache@v4
with:
path: |
node_modules
*/node_modules
packages/*/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Cache build outputs
id: cache-build
uses: actions/cache@v4
with:
path: |
*/dist
*/build
packages/*/dist
packages/*/build
key: ${{ runner.os }}-build-${{ github.sha }}
- name: Build all packages
run: yarn build
run-tests:
name: 'Run tests - ${{ matrix.folders }}'
needs: [prepare, build]
runs-on: ubuntu-24.04
strategy:
matrix:
folders: ${{ fromJson(needs.prepare.outputs.matrix) }}
fail-fast: false
steps:
- uses: actions/checkout@v5
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v46
with:
files: |
${{ matrix.folders }}/**
- uses: actions/setup-node@v4
if: steps.changed-files.outputs.any_modified == 'true'
with:
node-version: 22
- name: Restore node_modules
if: steps.changed-files.outputs.any_modified == 'true'
uses: actions/cache@v4
with:
path: |
node_modules
*/node_modules
packages/*/node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/yarn.lock') }}
fail-on-cache-miss: true
- name: Restore build outputs
if: steps.changed-files.outputs.any_modified == 'true'
uses: actions/cache@v4
with:
path: |
*/dist
*/build
packages/*/dist
packages/*/build
key: ${{ runner.os }}-build-${{ github.sha }}
fail-on-cache-miss: true
- name: Run lint
if: steps.changed-files.outputs.any_modified == 'true'
working-directory: ${{ matrix.folders }}
run: |
if [ -f "package.json" ] && grep -q '"lint"' package.json; then
yarn lint
else
echo "No lint script found, skipping"
fi
- name: Run tests
if: steps.changed-files.outputs.any_modified == 'true'
working-directory: ${{ matrix.folders }}
run: |
if [ -f "package.json" ] && grep -q '"test"' package.json; then
yarn test
else
echo "No test script found, skipping"
fi