-
Notifications
You must be signed in to change notification settings - Fork 2
240 lines (205 loc) · 6.93 KB
/
Copy pathmake-and-test.yml
File metadata and controls
240 lines (205 loc) · 6.93 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
name: Test
# newer commits in the same PR abort running ones for the same workflow
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
description: "Run the build."
required: false
default: false
jobs:
plan:
runs-on: blacksmith-8vcpu-ubuntu-2404
outputs:
matrix: ${{ steps.plan.outputs.matrix }}
has_tests: ${{ steps.plan.outputs.has_tests }}
mode: ${{ steps.plan.outputs.mode }}
depcheck_packages: ${{ steps.plan.outputs.depcheck_packages }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: install pnpm
uses: pnpm/action-setup@v4
with:
version: 11.5.2
run_install: false
- name: Node.js 24
uses: actions/setup-node@v4
with:
node-version: "24"
- name: Plan test lanes
id: plan
env:
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: |
cd src
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
node scripts/ci-test-plan.mjs --base="$PR_BASE_SHA" --github-output --pretty
else
node scripts/ci-test-plan.mjs --full --github-output --pretty
fi
build:
needs: plan
if: needs.plan.outputs.has_tests == 'true'
runs-on: blacksmith-8vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v4
- name: install pnpm
uses: pnpm/action-setup@v4
with:
version: 11.5.2
run_install: false
- name: Node.js 24
uses: actions/setup-node@v4
with:
node-version: "24"
cache: pnpm
cache-dependency-path: src/packages/pnpm-lock.yaml
- name: Build
run: cd src && pnpm build
- name: Pack workspace build
run: |
cd src
mapfile -d '' build_dirs < <(
find packages \
-type d -name node_modules -prune -o \
-type d \( -name dist -o -name dist-ts \) -print0
)
if (( ${#build_dirs[@]} == 0 )); then
echo "No workspace build directories found."
exit 1
fi
mapfile -d '' test_tools < <(
find packages/backend/node_modules/.bin \
-maxdepth 1 -type f ! -name codex -print0
)
tar --create --file workspace-build.tar \
"${build_dirs[@]}" \
"${test_tools[@]}"
- name: Upload workspace build
uses: actions/upload-artifact@v4
with:
name: workspace-build
path: src/workspace-build.tar
if-no-files-found: error
retention-days: 1
compression-level: 1
checks:
needs: plan
runs-on: blacksmith-8vcpu-ubuntu-2404
steps:
- uses: actions/checkout@v4
- name: install pnpm
uses: pnpm/action-setup@v4
with:
version: 11.5.2
run_install: false
- name: Node.js 24
uses: actions/setup-node@v4
with:
node-version: "24"
cache: pnpm
cache-dependency-path: src/packages/pnpm-lock.yaml
- name: Install workspace dependencies
run: pnpm -C src/packages install --frozen-lockfile
- name: Static checks
run: pnpm -C src test:checks
- name: Dependency checks
env:
DEPCHECK_PACKAGES: ${{ needs.plan.outputs.depcheck_packages }}
TEST_MODE: ${{ needs.plan.outputs.mode }}
run: |
cd src
if [[ "$TEST_MODE" == "full" ]]; then
pnpm depcheck
elif [[ -n "$DEPCHECK_PACKAGES" ]]; then
./workspaces.py pnpm --packages="$DEPCHECK_PACKAGES" --parallel run depcheck
else
echo "No directly changed package requires depcheck."
fi
test:
needs: [plan, build]
if: needs.plan.outputs.has_tests == 'true'
runs-on: blacksmith-8vcpu-ubuntu-2404
timeout-minutes: 15
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.plan.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: install pnpm
uses: pnpm/action-setup@v4
with:
version: 11.5.2
run_install: false
- name: Node.js 24
uses: actions/setup-node@v4
with:
node-version: "24"
cache: pnpm
cache-dependency-path: src/packages/pnpm-lock.yaml
- name: Install system packages
run: |
APT_RETRY=(
-o Acquire::Retries=3
-o Acquire::http::Timeout=15
-o Acquire::https::Timeout=15
)
sudo timeout 3m apt-get "${APT_RETRY[@]}" update
sudo timeout 3m apt-get "${APT_RETRY[@]}" install -y attr btrfs-progs python3
- name: Install workspace dependencies
run: pnpm -C src/packages install --frozen-lockfile
- name: Download workspace build
uses: actions/download-artifact@v4
with:
name: workspace-build
path: src
- name: Extract workspace build
run: tar --extract --file src/workspace-build.tar --directory src
- name: Cache Jest transforms
uses: actions/cache@v4
with:
path: src/.cache/jest
key: jest-${{ runner.os }}-node24-${{ hashFiles('src/packages/pnpm-lock.yaml', 'src/packages/**/jest.config.*', 'src/packages/**/tsconfig.test.json') }}-${{ matrix.lane }}-${{ github.sha }}
restore-keys: |
jest-${{ runner.os }}-node24-${{ hashFiles('src/packages/pnpm-lock.yaml', 'src/packages/**/jest.config.*', 'src/packages/**/tsconfig.test.json') }}-${{ matrix.lane }}-
- name: Cache pip
if: matrix.lane == 'rest'
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip-${{ runner.os }}-py3-${{ hashFiles('src/requirements.txt') }}
restore-keys: |
pip-${{ runner.os }}-py3-
- name: Set up Python venv and Jupyter kernel
if: matrix.lane == 'rest'
run: |
python3 -m pip install --upgrade pip virtualenv
python3 -m virtualenv venv
source venv/bin/activate
pip install ipykernel requests yapf
python -m ipykernel install --prefix=./jupyter-local --name python3-local --display-name "Python 3 (Local)"
- name: Check Essential frontend bundle budgets
if: matrix.lane == 'rest'
run: cd src/packages/static && pnpm run check-ultralite-budgets
- name: Test ${{ matrix.lane }} packages
env:
COCALC_RUNTIME_STORAGE_ALLOW_DIRECT: "yes"
TEST_PACKAGES: ${{ matrix.packages }}
run: |
if [[ "${{ matrix.lane }}" == "rest" ]]; then
source venv/bin/activate
fi
cd src
./workspaces.py test --packages="$TEST_PACKAGES"