Repository navigation
225 lines (218 loc) · 10.9 KB
/
Copy pathci.yml
File metadata and controls
225 lines (218 loc) · 10.9 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
# Format, lint, build and test on every pull request and on each push to main that changes code.
# The full protected set (TestLocal shards, gate, bound runs, LSP and API oracles, np-suite) stays in
# the revision pipeline (scripts/goport/candidate.sh). This workflow is a fast check that the tree
# builds and its own tests pass on Linux (x64 and arm64), macOS and Windows (x64, MSVC), that
# the tsc compiles for Intel macOS, and that the wasm module (npm/wasm) passes its package tests
# and the wasm-only Rust tests of crates/ts_wasm and goport_util.
name: CI
on:
pull_request:
push:
branches: [main]
paths:
- "crates/**"
- "tools/**"
- "Cargo.toml"
- "Cargo.lock"
- "UPSTREAM.json"
- "scripts/upstream/pin.py"
# The wasm job's module build and package tests.
- "npm/wasm/**"
- "scripts/wasm/**"
- ".github/workflows/ci.yml"
permissions:
contents: read
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
RUSTFLAGS: -C debuginfo=0
# The toolchain of shipped bins (release.yml), the candidate evidence, fmt and clippy
# (scripts/goport/README.md, "Build toolchain").
RUSTUP_TOOLCHAIN: 1.95.0
jobs:
lint:
name: fmt, codegen, clippy
runs-on: blacksmith-8vcpu-ubuntu-2404
timeout-minutes: 60
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- run: rustup toolchain install "$RUSTUP_TOOLCHAIN" --profile minimal -c rustfmt,clippy
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- run: cargo fmt --all -- --check
- name: Generated AST files match the codegen
run: |
cargo run --locked --quiet -p ts_ast_codegen -- check crates/ts_goport/src/astdata/syntax_kind.rs
cargo run --locked --quiet -p ts_ast_codegen -- check-ast crates/ts_goport/src/astdata/ast_generated.rs
# The packages of the revision quality step (candidate.sh): 0 warnings.
- run: cargo clippy --locked -p ts_goport -p goport_core -p goport_util -p goport_lsproto --all-targets -- -D warnings
test:
name: test (${{ matrix.runner }})
strategy:
fail-fast: false
matrix:
# Blacksmith runners (the pingdotgg org has the app), as T3 Code uses. The Windows runner
# builds x86_64-pc-windows-msvc.
runner:
- blacksmith-16vcpu-ubuntu-2404
- blacksmith-16vcpu-ubuntu-2404-arm
- blacksmith-12vcpu-macos-26
- blacksmith-16vcpu-windows-2025
runs-on: ${{ matrix.runner }}
timeout-minutes: 120
# Git Bash on Windows.
defaults:
run:
shell: bash
env:
# One test thread, as goport-tests.sh runs them.
RUST_TEST_THREADS: 1
steps:
# LF in the working tree, as on the other hosts: Git for Windows sets core.autocrlf=true, which
# gives the test fixtures and the scripts CRLF (README.md, "Develop on Windows").
- if: runner.os == 'Windows'
run: git config --global core.autocrlf false
- uses: actions/checkout@v5
with:
persist-credentials: false
# main's Go pin is the saved state's batch.upstreamPin.to. UPSTREAM.json "current" can be an older
# pin until the default pin switch (AGENTS.md, "Pin").
- name: Resolve the Go pin
id: pin
run: |
key=$(jq -r '.batch.upstreamPin.to // empty' docs/typechecker-state/current.json)
# Windows has python, not python3.
py=python3
[[ $RUNNER_OS != Windows ]] || py=python
"$py" scripts/upstream/pin.py show ${key:+"$key"} > "$RUNNER_TEMP/pin.json"
jq -r '"repo=\(.repo)", "commit=\(.commit)", "subdir=\(.subdir // "")"' "$RUNNER_TEMP/pin.json" >> "$GITHUB_OUTPUT"
- name: Check out the pinned Go source
uses: actions/checkout@v5
with:
repository: ${{ steps.pin.outputs.repo }}
ref: ${{ steps.pin.outputs.commit }}
path: go-pin
sparse-checkout: ${{ steps.pin.outputs.subdir }}
persist-credentials: false
# The go_baselines temp roots default to zbook paths on Linux (/tmp on macOS). Windows gets
# native paths (C:\...), as the tests' own temp dirs are.
- name: Set the test paths
run: |
native() { if [[ $RUNNER_OS == Windows ]]; then cygpath -w "$1"; else echo "$1"; fi; }
echo "TS_GO_REPO=$(native "$GITHUB_WORKSPACE/go-pin${SUBDIR:+/$SUBDIR}")" >> "$GITHUB_ENV"
echo "TSCTEST_TMP=$(native "$RUNNER_TEMP/tsctest")" >> "$GITHUB_ENV"
echo "COMPILER_RUNNER_TMP=$(native "$RUNNER_TEMP/compiler-runner")" >> "$GITHUB_ENV"
env:
SUBDIR: ${{ steps.pin.outputs.subdir }}
# The astnav tests run the JS TypeScript of the Go repo's lockfile under Node (Go
# testutil/jstest: <repo>/node_modules/typescript). Only that package, not the repo's npm ci.
- name: Install the Go repo's typescript package
run: |
url=$(jq -r '.packages["node_modules/typescript"].resolved' go-pin/package-lock.json)
mkdir -p go-pin/node_modules/typescript
curl -sSfL "$url" | tar xz -C go-pin/node_modules/typescript --strip-components=1
jq -r .version go-pin/node_modules/typescript/package.json
- run: rustup toolchain install "$RUSTUP_TOOLCHAIN" --profile minimal
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- name: Build
run: |
cargo test --release --locked --workspace --no-run
cargo test --release --locked -p ts_goport --test go_baselines --no-run
- name: Unit and integration tests
run: cargo test --release --locked --workspace --no-fail-fast
# go_baselines has `test = false`, so --workspace skips it. TestLocal (about 12,700 compiler
# cases) runs in 4 shards in goport-tests.sh, in the revision pipeline; the rest of the default
# go_baselines set runs here, also after a failed unit test.
- name: Go baselines
if: ${{ !cancelled() }}
run: |
skip=(--skip compiler_runner::test_local)
# Open on macOS: the 10 tests of project_lsp/resolveahead_test.rs (resolveahead1, merged
# after the macOS port) have never passed there. 9 find no resolve-ahead load and 1 finds
# no configured project. They pass on Linux.
[[ $RUNNER_OS != macOS ]] || skip+=(--skip project_lsp::resolveahead_test::)
cargo test --release --locked --no-fail-fast -p ts_goport --test go_baselines -- "${skip[@]}"
# Windows: the tsc against Go's tsc on Windows path forms, CRLF sources and a junction
# (scripts/goport/win-go-compare.sh). Go's tsc builds from the pinned Go source with the pin's
# Go (oracle.go), as the oracle does; both embed the lib files.
- name: Go version
if: ${{ !cancelled() && runner.os == 'Windows' }}
id: go
run: jq -r '"version=\(.oracle.go | ltrimstr("go"))"' "$RUNNER_TEMP/pin.json" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@v6
if: ${{ !cancelled() && runner.os == 'Windows' }}
with:
go-version: ${{ steps.go.outputs.version }}
cache: false
- name: Compare with Go
if: ${{ !cancelled() && runner.os == 'Windows' }}
env:
SUBDIR: ${{ steps.pin.outputs.subdir }}
run: |
(cd "go-pin${SUBDIR:+/$SUBDIR}" && GOWORK=off CGO_ENABLED=0 go build -trimpath -o "$RUNNER_TEMP/go/tsc.exe" ./cmd/tsc)
cargo build --release --locked -p ts_goport --bin tsgo
scripts/goport/win-go-compare.sh target/release/tsgo.exe "$RUNNER_TEMP/go/tsc.exe" "$RUNNER_TEMP/win-go"
# Intel Macs: the release ships an x86_64-apple-darwin tsc (release.yml builds it on an Intel
# runner). A cross check of the tsc here finds compile errors in its cfg paths on each PR.
- name: Check x86_64-apple-darwin
if: ${{ !cancelled() && runner.os == 'macOS' }}
run: |
rustup target add --toolchain "$RUSTUP_TOOLCHAIN" x86_64-apple-darwin
cargo check --locked -p ts_goport --bin tsgo --target x86_64-apple-darwin
# The wasm module of npm/wasm on a fast profile, and the package's tests in Node. The protected set
# builds no wasm32 target, so it did not see a checker panic that only the wasm build had (issue
# #83). Its repro is a test in npm/wasm/test/tsc.test.mjs.
wasm:
name: wasm
runs-on: blacksmith-16vcpu-ubuntu-2404
timeout-minutes: 30
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- run: rustup toolchain install "$RUSTUP_TOOLCHAIN" --profile minimal -c clippy -t wasm32-wasip1
- uses: Swatinem/rust-cache@v2
with:
save-if: ${{ github.ref == 'refs/heads/main' }}
- uses: actions/setup-node@v5
with:
node-version: 24
# The release profile and no wasm-opt: about 1.5 minutes on 32 vCPU with no cache.
- name: Build the module
run: scripts/wasm/build.sh
env:
WASM_PROFILE: release
WASM_OPT: none
# `npm test` runs `node --test test/*.test.mjs`, with the #83 repro in test/tsc.test.mjs.
- name: Package tests
working-directory: npm/wasm
run: npm test
# The wasm-only Rust tests, in Node: release_checker in crates/ts_wasm, and the WASI case
# probe of goport_util's osvfs.rs (#89). The probe keeps its first answer, so its second test
# runs alone (--ignored).
- name: wasm unit tests
run: |
cargo test --locked -p ts_wasm --target wasm32-wasip1
cargo test --locked -p goport_util --lib --target wasm32-wasip1 -- osvfs::wasi_tests --nocapture
cargo test --locked -p goport_util --lib --target wasm32-wasip1 -- osvfs::wasi_tests --ignored --nocapture
env:
CARGO_TARGET_WASM32_WASIP1_RUNNER: node ${{ github.workspace }}/scripts/wasm/test-runner.mjs
# clippy for wasm32, where the wasm-gated code lives (the lint job builds the host target only):
# ts_wasm with its wasm-only tests and allocator, and the crates that it builds, without their
# default features, as ts_wasm builds them. ts_goport's tests/ are native only (they run tsgo),
# so ts_goport takes its lib, bins and examples, then its unit tests (--profile test). The
# goport crates allow clippy::all and pedantic at their roots, so for them this step checks
# rustc warnings and the workspace lints; full clippy applies to ts_wasm.
- name: clippy wasm32
run: |
cargo clippy --locked --target wasm32-wasip1 --no-default-features -p ts_wasm -p goport_core -p goport_util -p goport_lsproto --all-targets -- -D warnings
cargo clippy --locked --target wasm32-wasip1 --no-default-features -p ts_goport --lib --bins --examples -- -D warnings
cargo clippy --locked --target wasm32-wasip1 --no-default-features -p ts_goport --lib --profile test -- -D warnings