-
Notifications
You must be signed in to change notification settings - Fork 176
257 lines (213 loc) · 7.93 KB
/
ci.yml
File metadata and controls
257 lines (213 loc) · 7.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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
name: CI
permissions:
# Doing it explicitly because the default permission only includes metadata: read.
contents: read
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize]
paths-ignore:
- '**/*.md'
push:
branches:
- main
paths-ignore:
- '**/*.md'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.ref_name != 'main' }}
defaults:
run:
shell: bash
jobs:
test:
name: Test
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: windows-latest
target: x86_64-pc-windows-msvc
- os: namespace-profile-mac-default
target: aarch64-apple-darwin
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
submodules: true
- uses: oxc-project/setup-rust@d286d43bc1f606abbd98096666ff8be68c8d5f57 # v1.0.0
with:
save-cache: ${{ github.ref_name == 'main' }}
cache-key: test
- run: rustup target add x86_64-unknown-linux-musl
if: ${{ matrix.os == 'ubuntu-latest' }}
- name: Configure Git for access to vite-task
run: git config --global url."https://x-access-token:${{ secrets.VITE_TASK_TOKEN }}@github.com/".insteadOf "https://github.com/"
- run: cargo check --all-targets --all-features
env:
RUSTFLAGS: '-D warnings --cfg tokio_unstable' # also update .cargo/config.toml
- run: cargo test
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
submodules: true
- name: Configure Git for access to vite-task
run: git config --global url."https://x-access-token:${{ secrets.VITE_TASK_TOKEN }}@github.com/".insteadOf "https://github.com/"
- uses: oxc-project/setup-rust@d286d43bc1f606abbd98096666ff8be68c8d5f57 # v1.0.0
with:
save-cache: ${{ github.ref_name == 'main' }}
cache-key: lint
tools: dprint,cargo-shear
components: clippy rust-docs rustfmt
- run: |
dprint check
cargo shear
cargo fmt --check
# cargo clippy --all-targets --all-features -- -D warnings
RUSTDOCFLAGS='-D warnings' cargo doc --no-deps --document-private-items
- uses: crate-ci/typos@85f62a8a84f939ae994ab3763f01a0296d61a7ee # v1.36.2
with:
files: .
- uses: oxc-project/setup-node@fdbf0dfd334c4e6d56ceeb77d91c76339c2a0885 # v1.0.4
- name: Deduplicate dependencies
run: pnpm dedupe --check
run:
name: Run task
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
submodules: true
- name: Configure Git for access to vite-task
run: git config --global url."https://x-access-token:${{ secrets.VITE_TASK_TOKEN }}@github.com/".insteadOf "https://github.com/"
- uses: oxc-project/setup-rust@d286d43bc1f606abbd98096666ff8be68c8d5f57 # v1.0.0
with:
save-cache: ${{ github.ref_name == 'main' }}
cache-key: run
- uses: oxc-project/setup-node@fdbf0dfd334c4e6d56ceeb77d91c76339c2a0885 # v1.0.4
- name: Build self
run: pnpm bootstrap-cli
- name: Run self
run: vite run -r build
- name: Print help for built-in commands
run: |
vite -h
vite run -h
vite lint -h
vite test -h
vite build -h
vite fmt -h
cli-e2e-test:
name: CLI E2E test
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- os: namespace-profile-mac-default
- os: windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
submodules: true
- name: Configure Git for access to vite-task
run: git config --global url."https://x-access-token:${{ secrets.VITE_TASK_TOKEN }}@github.com/".insteadOf "https://github.com/"
- run: |
brew install rustup
rustup install stable
echo "PATH=/opt/homebrew/opt/rustup/bin:$PATH" >> $GITHUB_ENV
if: ${{ matrix.os == 'namespace-profile-mac-default' }}
- uses: oxc-project/setup-rust@d286d43bc1f606abbd98096666ff8be68c8d5f57 # v1.0.0
with:
save-cache: ${{ github.ref_name == 'main' }}
cache-key: cli-e2e-test
- uses: oxc-project/setup-node@fdbf0dfd334c4e6d56ceeb77d91c76339c2a0885 # v1.0.4
- name: Build CLI
run: pnpm run bootstrap-cli
- name: Run CLI lint
run: pnpm lint
if: ${{ matrix.os != 'windows-latest' }}
- name: Install Playwright browsers
run: pnpx playwright install chromium
- name: Run CLI E2E tests
if: ${{ matrix.os != 'windows-latest' }}
run: |
RUST_BACKTRACE=1 pnpm test
git diff --exit-code
- name: Run CLI E2E tests
if: ${{ matrix.os == 'windows-latest' }}
run: |
RUST_BACKTRACE=1 pnpm -r snap-test
git diff --exit-code
install-e2e-test:
name: vite install E2E test
# FIXME: Error: spawnSync esbuild ENOTSOCK
# runs-on: ubuntu-latest
runs-on: namespace-profile-mac-default
if: ${{ github.ref_name == 'main' }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
submodules: true
- name: Configure Git for access to vite-task
run: git config --global url."https://x-access-token:${{ secrets.VITE_TASK_TOKEN }}@github.com/".insteadOf "https://github.com/"
- uses: oxc-project/setup-rust@d286d43bc1f606abbd98096666ff8be68c8d5f57 # v1.0.0
with:
save-cache: ${{ github.ref_name == 'main' }}
cache-key: install-e2e-test
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
- uses: oxc-project/setup-node@fdbf0dfd334c4e6d56ceeb77d91c76339c2a0885 # v1.0.4
- name: Build vite rust binary
run: cargo build --bin vite --release
- name: Run vite install
run: |
export PATH=$PWD/target/release:$PATH
# Test vite install on various repositories with different package managers
repos=(
# pnpm workspace
"pnpm/pnpm:pnpm"
"vitejs/vite:vite"
# yarn workspace
"napi-rs/napi-rs:napi-rs"
"toeverything/AFFiNE:AFFiNE"
# npm workspace
"npm/cli:npm"
"redhat-developer/vscode-extension-tester:vscode-extension-tester"
)
for repo_info in "${repos[@]}"; do
IFS=':' read -r repo dir_name <<< "$repo_info"
echo "Testing vite install on $repo..."
# remove the directory if it exists
if [ -d "tmp/$dir_name" ]; then
rm -rf "tmp/$dir_name"
fi
git clone --depth 1 "https://github.com/$repo.git" "tmp/$dir_name"
cd "tmp/$dir_name"
vite install
# run again to show install cache increase by time
time vite install
echo "✓ Successfully installed dependencies for $repo"
echo ""
done
done:
runs-on: ubuntu-latest
needs:
- test
- lint
- run
- cli-e2e-test
steps:
- run: exit 1
# Thank you, next https://github.com/vercel/next.js/blob/canary/.github/workflows/build_and_test.yml#L379
if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) }}