-
Notifications
You must be signed in to change notification settings - Fork 1
264 lines (231 loc) · 8.56 KB
/
Copy pathdeploy.yml
File metadata and controls
264 lines (231 loc) · 8.56 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
258
259
260
261
262
263
264
name: Deploy to VS Code Marketplace
on:
push:
branches:
- main
pull_request_target:
branches:
- main
workflow_dispatch:
permissions:
contents: read
jobs:
test:
name: test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v6
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt, clippy, llvm-tools-preview
# wasm32-wasip1: rcl-zed clippy. wasm32-unknown-unknown: rcl-core-wasm
# clippy + wasm-pack build/test (`bun run test` runs both).
target: wasm32-wasip1, wasm32-unknown-unknown
cache-key: test-${{ matrix.os }}
# `bun run test` runs `wasm-pack test --node` (core-wasm wasm-bindgen
# tests) and `bun run build` (wasm-pack build), so wasm-pack must exist.
- uses: taiki-e/install-action@v2.81.5
with:
tool: wasm-pack
- uses: oven-sh/setup-bun@v2
with:
bun-version: '1.3.9'
- run: bun install --frozen-lockfile
# `bun run lint` = oxlint + cargo fmt --check + cargo clippy (native)
# + cargo clippy (wasm32-wasip1 rcl-zed) + cargo clippy
# (wasm32-unknown-unknown rcl-core-wasm).
- run: bun run lint
- run: bun run typecheck
# `bun run test` = cargo test (workspace, excluding the wasm crates)
# + wasm-pack test --node (rcl-core-wasm wasm-bindgen tests)
# + cargo build wasm32-wasip1 (rcl-zed) + bun run build
# + VS Code integration tests (packages/vscode test:integration).
- run: bun run test
# Coverage gate runs on Linux only to keep one toolchain install per OS.
- name: Install cargo-tarpaulin
if: matrix.os == 'ubuntu-latest'
uses: taiki-e/install-action@v2.81.5
with:
tool: cargo-tarpaulin
# tarpaulin/LLVM cannot attribute coverage to the continuation lines of
# multi-line expressions, so they are impossible to ever mark covered.
# Collapse statements onto single lines first (wide rustfmt) so 100% is
# actually attainable, then measure. Pattern: dev-five-git/devup-ui.
# `bun run test:coverage` fails the job if line coverage is below 100%.
- name: Coverage (100% gate)
if: matrix.os == 'ubuntu-latest'
run: |
printf '%s\n' \
'max_width = 100000' \
'tab_spaces = 4' \
'newline_style = "Unix"' \
'fn_call_width = 100000' \
'fn_params_layout = "Compressed"' \
'chain_width = 100000' \
'merge_derives = true' \
'use_small_heuristics = "Default"' > .rustfmt.toml
cargo fmt
bun run test:coverage
# Restore canonical formatting even if the coverage gate failed, so no
# later step (or cache) sees the collapsed source.
- name: Format rollback
if: ${{ always() && matrix.os == 'ubuntu-latest' }}
run: |
rm -f .rustfmt.toml
cargo fmt
changepacks:
name: changepacks
runs-on: ubuntu-latest
permissions:
# create pull request comments
pull-requests: write
# Actions > General > Workflow permissions for creating pull request
# Create brench to create pull request
contents: write
needs:
- test
steps:
- uses: actions/checkout@v6
- uses: changepacks/action@main
id: changepacks
with:
token: ${{ secrets.GITHUB_TOKEN }}
outputs:
changepacks: ${{ steps.changepacks.outputs.changepacks }}
release_assets_urls: ${{ steps.changepacks.outputs.release_assets_urls }}
upload-assets:
needs: changepacks
if: ${{ contains(needs.changepacks.outputs.changepacks, 'packages/vscode/package.json') }}
permissions:
contents: write
name: Upload Assets
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- uses: oven-sh/setup-bun@v2
with:
bun-version: '1.3.9'
- run: bun install --frozen-lockfile
- name: Package VSIX
working-directory: packages/vscode
run: bunx @vscode/vsce package --no-dependencies
- name: Upload Asset
uses: owjs3901/upload-github-release-asset@main
with:
upload_url: ${{ fromJson(needs.changepacks.outputs.release_assets_urls)['packages/vscode/package.json'] }}
asset_path: packages/vscode/react-component-lens-*.vsix
lsp-binaries:
name: lsp-binaries (${{ matrix.target }})
needs: changepacks
if: ${{ contains(needs.changepacks.outputs.changepacks, 'packages/vscode/package.json') }}
permissions:
contents: write
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
asset_arch: x86_64
asset_os: unknown-linux-gnu
cross: false
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
asset_arch: aarch64
asset_os: unknown-linux-gnu
cross: true
- target: x86_64-apple-darwin
os: macos-13
archive: tar.gz
asset_arch: x86_64
asset_os: apple-darwin
cross: false
- target: aarch64-apple-darwin
os: macos-14
archive: tar.gz
asset_arch: aarch64
asset_os: apple-darwin
cross: false
- target: x86_64-pc-windows-msvc
os: windows-latest
archive: zip
asset_arch: x86_64
asset_os: pc-windows-msvc
cross: false
steps:
- uses: actions/checkout@v6
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
cache-key: lsp-binaries-${{ matrix.target }}
- name: Install cross
if: ${{ matrix.cross }}
run: cargo install cross --locked --version '^0.2'
- name: Read VS Code package version
id: version
shell: bash
run: |
version=$(node -p "require('./packages/vscode/package.json').version")
stem="rcl-lsp-${version}-${{ matrix.asset_arch }}-${{ matrix.asset_os }}"
echo "version=${version}" >> "$GITHUB_OUTPUT"
echo "stem=${stem}" >> "$GITHUB_OUTPUT"
echo "archive=${stem}.${{ matrix.archive }}" >> "$GITHUB_OUTPUT"
- name: Build rcl-lsp
shell: bash
run: |
if [[ "${{ matrix.cross }}" == "true" ]]; then
cross build --release --target ${{ matrix.target }} -p rcl-lsp --bin rcl-lsp
else
cargo build --release --target ${{ matrix.target }} -p rcl-lsp --bin rcl-lsp
fi
- name: Package archive
shell: bash
run: |
mkdir -p staging
if [[ "${{ matrix.target }}" == *windows* ]]; then
cp "target/${{ matrix.target }}/release/rcl-lsp.exe" staging/
(cd staging && 7z a -tzip "../${{ steps.version.outputs.archive }}" rcl-lsp.exe)
else
cp "target/${{ matrix.target }}/release/rcl-lsp" staging/
(cd staging && tar -czf "../${{ steps.version.outputs.archive }}" rcl-lsp)
fi
ls -lh "${{ steps.version.outputs.archive }}"
- name: Upload to GitHub Release
uses: owjs3901/upload-github-release-asset@main
with:
upload_url: ${{ fromJson(needs.changepacks.outputs.release_assets_urls)['packages/vscode/package.json'] }}
asset_path: ${{ steps.version.outputs.archive }}
publish:
name: Publish
runs-on: ubuntu-latest
if: ${{ contains(needs.changepacks.outputs.changepacks, 'packages/vscode/package.json') }}
needs:
- changepacks
- lsp-binaries
steps:
- uses: actions/checkout@v6
- uses: oven-sh/setup-bun@v2
with:
bun-version: '1.3.9'
- run: bun install --frozen-lockfile
- name: Package VSIX
working-directory: packages/vscode
run: bunx @vscode/vsce package --no-dependencies
- name: Publish to VS Code Marketplace
working-directory: packages/vscode
run: bunx @vscode/vsce publish --no-dependencies --packagePath react-component-lens-*.vsix
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
- name: Publish to Open VSX
working-directory: packages/vscode
run: bunx ovsx publish react-component-lens-*.vsix -p $OVSX_PAT
env:
OVSX_PAT: ${{ secrets.OVSX_PAT }}