Skip to content

Commit 1abdcc7

Browse files
authored
ci: share artifact workflow for dev packages (#274)
2 parents 49b5110 + 133ae10 commit 1abdcc7

7 files changed

Lines changed: 81 additions & 243 deletions

File tree

.github/scripts/ci-plan.mjs

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ const DEFAULT_RUST_TEST_MATRIX = {
55
};
66
const FALLBACK_RUST_TEST_MATRIX = { os: ["ubuntu-latest"] };
77

8-
const DEV_PACKAGE_TARGETS = new Map([
9-
["linux-x64", { os: "ubuntu-22.04", target: "linux-x64" }],
10-
["linux-arm64", { os: "ubuntu-22.04-arm", target: "linux-arm64" }],
11-
["win32-x64", { os: "windows-latest", target: "win32-x64" }],
12-
["darwin-arm64", { os: "macos-15", target: "darwin-arm64" }],
13-
]);
14-
158
export async function planCi({ github, context, core, filters }) {
169
const eventName = context.eventName;
1710
const workflowDispatch = eventName === "workflow_dispatch";
@@ -43,27 +36,15 @@ export async function planCi({ github, context, core, filters }) {
4336
rustTestMatrix = { os: failedRustTestOs };
4437
}
4538

46-
let runDevPackage = false;
47-
let runDevWebPackage = false;
48-
let devPackageMatrix = [DEV_PACKAGE_TARGETS.get("linux-x64")];
39+
let runDevArtifacts = false;
4940

5041
if (!pullRequest) {
5142
if (workflowDispatch || packageChanged) {
52-
runDevPackage = true;
53-
runDevWebPackage = true;
54-
devPackageMatrix = [...DEV_PACKAGE_TARGETS.values()];
43+
runDevArtifacts = true;
5544
} else {
56-
const failedDevPackageTargets = failedTargets(
57-
failedJobNames,
58-
DEV_PACKAGE_TARGETS,
45+
runDevArtifacts = failedJobNames.some((name) =>
46+
name.startsWith("Dev Artifacts"),
5947
);
60-
61-
runDevPackage = failedDevPackageTargets.length > 0;
62-
runDevWebPackage = failedJobNames.includes("Dev Package (web)");
63-
64-
if (runDevPackage) {
65-
devPackageMatrix = failedDevPackageTargets;
66-
}
6748
}
6849
}
6950

@@ -83,9 +64,7 @@ export async function planCi({ github, context, core, filters }) {
8364
vscodeChanged ||
8465
packageChanged ||
8566
failedJobNames.includes("VS Code Web Smoke"),
86-
run_dev_package: runDevPackage,
87-
dev_package_matrix: devPackageMatrix,
88-
run_dev_web_package: runDevWebPackage,
67+
run_dev_artifacts: runDevArtifacts,
8968
};
9069
}
9170

.github/workflows/build-release-artifacts.yml renamed to .github/workflows/build-artifacts.yml

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1-
name: Build release artifacts
1+
name: Build artifacts
22

33
on:
44
workflow_call:
55
inputs:
66
plan:
77
required: false
88
type: string
9+
build-kind:
10+
required: false
11+
type: string
12+
default: ""
13+
cargo-profile:
14+
required: false
15+
type: string
16+
default: release
17+
vsix-profile:
18+
required: false
19+
type: string
20+
default: release
921

1022
permissions:
1123
contents: read
@@ -79,7 +91,7 @@ jobs:
7991
continue-on-error: true
8092
with:
8193
shared-key: release-${{ runner.os }}-${{ matrix.rust-target }}
82-
key: native-${{ hashFiles('Cargo.toml', 'Cargo.lock', 'build.rs', 'rust-toolchain.toml', 'src/**', 'crates/**', 'xtask/**', 'scripts/build-release-artifact.sh') }}
94+
key: native-${{ hashFiles('Cargo.toml', 'Cargo.lock', 'build.rs', 'rust-toolchain.toml', 'src/**', 'crates/**', 'xtask/**', 'scripts/build-artifact.sh') }}
8395
cache-workspace-crates: true
8496
cache-on-failure: true
8597

@@ -97,31 +109,31 @@ jobs:
97109
- name: Set VSIX build metadata
98110
shell: bash
99111
run: |
100-
echo "VIDE_EXTENSION_BUILD_KIND=${{ inputs.plan && fromJson(inputs.plan).announcement_is_prerelease && 'beta' || 'stable' }}" >> "$GITHUB_ENV"
112+
echo "VIDE_EXTENSION_BUILD_KIND=${{ inputs.build-kind || (inputs.plan && fromJson(inputs.plan).announcement_is_prerelease && 'beta' || 'stable') }}" >> "$GITHUB_ENV"
101113
echo "VIDE_EXTENSION_COMMIT_HASH=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV"
102114
echo "VIDE_EXTENSION_BUILD_DATE=$(date -u +'%Y%m%dT%H%M%SZ')" >> "$GITHUB_ENV"
103115
104116
- name: Build binary archive and stage VSIX server
105117
shell: bash
106-
run: scripts/build-release-artifact.sh "${{ matrix.rust-target }}" "${{ matrix.vsix-target }}"
118+
run: scripts/build-artifact.sh "${{ matrix.rust-target }}" "${{ matrix.vsix-target }}" "${{ inputs.cargo-profile }}"
107119

108120
- name: Build VSIX
109121
working-directory: editors/vscode
110-
run: npm run package:vsix -- --target ${{ matrix.vsix-target }} --server=prebuilt
122+
run: npm run package:vsix -- --target ${{ matrix.vsix-target }} --profile ${{ inputs.vsix-profile }} --server=prebuilt
111123

112124
- name: Upload cargo-dist artifacts
113125
uses: actions/upload-artifact@v4
114126
with:
115127
name: artifacts-${{ matrix.rust-target }}
116128
path: |
117-
target/distrib/vide-${{ matrix.rust-target }}.*
129+
target/distrib/vide-${{ matrix.rust-target }}${{ inputs.cargo-profile == 'debug' && '-debug' || '' }}.*
118130
if-no-files-found: error
119131

120132
- name: Upload VSIX artifact
121133
uses: actions/upload-artifact@v4
122134
with:
123135
name: vsix-${{ matrix.vsix-target }}
124-
path: editors/vscode/vide-vscode-${{ matrix.vsix-target }}.vsix
136+
path: editors/vscode/vide-vscode-${{ matrix.vsix-target }}${{ inputs.vsix-profile == 'debug' && '-debug' || '' }}.vsix
125137
if-no-files-found: error
126138

127139
source-and-checksums:
@@ -226,16 +238,19 @@ jobs:
226238
working-directory: .
227239
shell: bash
228240
run: |
229-
echo "VIDE_EXTENSION_BUILD_KIND=${{ inputs.plan && fromJson(inputs.plan).announcement_is_prerelease && 'beta' || 'stable' }}" >> "$GITHUB_ENV"
241+
echo "VIDE_EXTENSION_BUILD_KIND=${{ inputs.build-kind || (inputs.plan && fromJson(inputs.plan).announcement_is_prerelease && 'beta' || 'stable') }}" >> "$GITHUB_ENV"
230242
echo "VIDE_EXTENSION_COMMIT_HASH=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV"
231243
echo "VIDE_EXTENSION_BUILD_DATE=$(date -u +'%Y%m%dT%H%M%SZ')" >> "$GITHUB_ENV"
232244
245+
- name: Compile web extension
246+
run: npm run compile:web
247+
233248
- name: Build web VSIX
234-
run: npm run package:vsix:web
249+
run: npx tsx scripts/package.ts --target web --profile ${{ inputs.vsix-profile }}
235250

236251
- name: Upload web VSIX artifact
237252
uses: actions/upload-artifact@v4
238253
with:
239254
name: vsix-web
240-
path: editors/vscode/vide-vscode-web.vsix
255+
path: editors/vscode/vide-vscode-web${{ inputs.vsix-profile == 'debug' && '-debug' || '' }}.vsix
241256
if-no-files-found: error

.github/workflows/ci.yml

Lines changed: 9 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -215,188 +215,14 @@ jobs:
215215
- name: Web smoke test
216216
run: npm run test:web
217217

218-
dev-package:
219-
name: Dev Package (${{ matrix.target }})
218+
dev-artifacts:
219+
name: Dev Artifacts
220220
needs: changes
221-
if: fromJSON(needs.changes.outputs.plan).run_dev_package == true
222-
runs-on: ${{ matrix.os }}
223-
strategy:
224-
fail-fast: false
225-
matrix:
226-
include: ${{ fromJSON(needs.changes.outputs.plan).dev_package_matrix }}
227-
defaults:
228-
run:
229-
working-directory: editors/vscode
230-
env:
231-
SERVER_BIN: ${{ startsWith(matrix.target, 'win32-') && 'vide.exe' || 'vide' }}
232-
steps:
233-
- uses: actions/checkout@v4
234-
- name: Restore bundled server cache
235-
id: bundled-server-cache
236-
uses: actions/cache/restore@v4
237-
with:
238-
path: editors/vscode/server/${{ matrix.target }}/${{ env.SERVER_BIN }}
239-
key: bundled-server-${{ matrix.target }}-${{ hashFiles('Cargo.toml', 'Cargo.lock', 'build.rs', 'rust-toolchain.toml', 'src/**', 'crates/**', 'xtask/**') }}
240-
- name: Install Rust
241-
uses: ./.github/actions/setup-rust
242-
with:
243-
components: rustfmt
244-
- name: Setup sccache
245-
uses: ./.github/actions/setup-sccache
246-
with:
247-
cmake-launcher: "true"
248-
- name: Rust Cache
249-
uses: Swatinem/rust-cache@v2
250-
continue-on-error: true
251-
with:
252-
shared-key: rust-${{ runner.os }}
253-
key: package-${{ hashFiles('Cargo.toml', 'Cargo.lock', 'build.rs', 'rust-toolchain.toml', 'src/**', 'crates/**', 'xtask/**') }}
254-
cache-workspace-crates: true
255-
cache-on-failure: true
256-
- name: Setup Node
257-
uses: actions/setup-node@v4
258-
with:
259-
node-version: 22
260-
cache: npm
261-
cache-dependency-path: editors/vscode/package-lock.json
262-
- name: Install dependencies
263-
run: npm ci
264-
- name: Set build metadata
265-
id: build-metadata
266-
shell: bash
267-
run: |
268-
commit_hash="$(git rev-parse --short "$GITHUB_SHA")"
269-
echo "commit_hash=${commit_hash}" >> "$GITHUB_OUTPUT"
270-
echo "VIDE_EXTENSION_BUILD_KIND=nightly" >> "$GITHUB_ENV"
271-
echo "VIDE_EXTENSION_COMMIT_HASH=${commit_hash}" >> "$GITHUB_ENV"
272-
echo "VIDE_EXTENSION_BUILD_DATE=$(date -u +'%Y%m%dT%H%M%SZ')" >> "$GITHUB_ENV"
273-
- name: Package extension
274-
run: npm run package:vsix:debug -- --target ${{ matrix.target }} ${{ steps.bundled-server-cache.outputs.cache-hit == 'true' && '--server=prebuilt' || '--server=build' }}
275-
- name: Save bundled server cache
276-
if: steps.bundled-server-cache.outputs.cache-hit != 'true'
277-
uses: actions/cache/save@v4
278-
continue-on-error: true
279-
with:
280-
path: editors/vscode/server/${{ matrix.target }}/${{ env.SERVER_BIN }}
281-
key: ${{ steps.bundled-server-cache.outputs.cache-primary-key }}
282-
- name: Upload dev VSIX
283-
uses: actions/upload-artifact@v4
284-
with:
285-
name: vide-vscode-dev-${{ matrix.target }}-${{ steps.build-metadata.outputs.commit_hash }}
286-
path: editors/vscode/vide-vscode-${{ matrix.target }}-debug.vsix
287-
if-no-files-found: error
288-
retention-days: 14
289-
- name: Upload dev language server binary
290-
shell: bash
291-
working-directory: .
292-
run: |
293-
set -euo pipefail
294-
server_dir="editors/vscode/server/${{ matrix.target }}"
295-
if [[ "${{ matrix.target }}" == win32-* ]]; then
296-
src="${server_dir}/vide.exe"
297-
dst="vide-${{ matrix.target }}.exe"
298-
else
299-
src="${server_dir}/vide"
300-
dst="vide-${{ matrix.target }}"
301-
fi
302-
if [[ ! -f "$src" ]]; then
303-
echo "Language server binary not found: $src" >&2
304-
exit 1
305-
fi
306-
cp "$src" "$dst"
307-
- name: Upload dev language server binary artifact
308-
uses: actions/upload-artifact@v4
309-
with:
310-
name: vide-lsp-dev-${{ matrix.target }}-${{ steps.build-metadata.outputs.commit_hash }}
311-
path: vide-${{ matrix.target }}*
312-
if-no-files-found: error
313-
retention-days: 14
314-
315-
dev-web-package:
316-
name: Dev Package (web)
317-
needs: changes
318-
if: fromJSON(needs.changes.outputs.plan).run_dev_web_package == true
319-
runs-on: ubuntu-latest
320-
defaults:
321-
run:
322-
working-directory: editors/vscode
323-
steps:
324-
- uses: actions/checkout@v4
325-
- name: Restore playground WASM cache
326-
id: playground-wasm-cache
327-
uses: actions/cache/restore@v4
328-
with:
329-
path: playground/public/wasm
330-
key: playground-wasm-${{ runner.os }}-${{ env.EMSDK_VERSION }}-${{ hashFiles('Cargo.toml', 'Cargo.lock', 'build.rs', 'rust-toolchain.toml', 'src/**', 'crates/**', 'playground/scripts/build-vide-wasm.mjs', 'playground/scripts/script-utils.mjs', '.github/actions/setup-emscripten/**', '.github/actions/setup-rust/**') }}
331-
- name: Verify cached playground WASM
332-
if: steps.playground-wasm-cache.outputs.cache-hit == 'true'
333-
working-directory: .
334-
run: |
335-
test -s playground/public/wasm/vide-lsp.js
336-
test -s playground/public/wasm/vide-core.js
337-
test -s playground/public/wasm/vide-core.wasm
338-
- name: Install Rust
339-
if: steps.playground-wasm-cache.outputs.cache-hit != 'true'
340-
uses: ./.github/actions/setup-rust
341-
with:
342-
components: rustfmt
343-
- name: Setup sccache
344-
if: steps.playground-wasm-cache.outputs.cache-hit != 'true'
345-
uses: ./.github/actions/setup-sccache
346-
with:
347-
cmake-launcher: "true"
348-
- name: Rust Cache
349-
if: steps.playground-wasm-cache.outputs.cache-hit != 'true'
350-
uses: Swatinem/rust-cache@v2
351-
continue-on-error: true
352-
with:
353-
shared-key: vscode-web-wasm-${{ runner.os }}-${{ env.EMSDK_VERSION }}
354-
key: wasm-src-${{ hashFiles('Cargo.toml', 'Cargo.lock', 'build.rs', 'rust-toolchain.toml', 'src/**', 'crates/**', 'playground/scripts/build-vide-wasm.mjs', 'playground/scripts/script-utils.mjs', '.github/actions/setup-emscripten/**', '.github/actions/setup-rust/**') }}
355-
cache-workspace-crates: true
356-
cache-on-failure: true
357-
- name: Install Emscripten SDK
358-
if: steps.playground-wasm-cache.outputs.cache-hit != 'true'
359-
uses: ./.github/actions/setup-emscripten
360-
with:
361-
version: ${{ env.EMSDK_VERSION }}
362-
- name: Setup Node
363-
uses: actions/setup-node@v4
364-
with:
365-
node-version: 22
366-
cache: npm
367-
cache-dependency-path: editors/vscode/package-lock.json
368-
- name: Install dependencies
369-
run: npm ci
370-
- name: Build playground WASM
371-
if: steps.playground-wasm-cache.outputs.cache-hit != 'true'
372-
working-directory: playground
373-
run: |
374-
source "${EMSDK}/emsdk_env.sh"
375-
npm run build:wasm
376-
- name: Save playground WASM cache
377-
if: steps.playground-wasm-cache.outputs.cache-hit != 'true'
378-
uses: actions/cache/save@v4
379-
continue-on-error: true
380-
with:
381-
path: playground/public/wasm
382-
key: ${{ steps.playground-wasm-cache.outputs.cache-primary-key }}
383-
- name: Set build metadata
384-
id: build-metadata
385-
shell: bash
386-
working-directory: .
387-
run: |
388-
commit_hash="$(git rev-parse --short "$GITHUB_SHA")"
389-
echo "commit_hash=${commit_hash}" >> "$GITHUB_OUTPUT"
390-
echo "VIDE_EXTENSION_BUILD_KIND=nightly" >> "$GITHUB_ENV"
391-
echo "VIDE_EXTENSION_COMMIT_HASH=${commit_hash}" >> "$GITHUB_ENV"
392-
echo "VIDE_EXTENSION_BUILD_DATE=$(date -u +'%Y%m%dT%H%M%SZ')" >> "$GITHUB_ENV"
393-
- name: Package extension
394-
run: npm run package:vsix:web
395-
- name: Upload dev VSIX
396-
uses: actions/upload-artifact@v4
397-
with:
398-
name: vide-vscode-dev-web-${{ steps.build-metadata.outputs.commit_hash }}
399-
path: editors/vscode/vide-vscode-web.vsix
400-
if-no-files-found: error
401-
retention-days: 14
221+
if: fromJSON(needs.changes.outputs.plan).run_dev_artifacts == true
222+
uses: ./.github/workflows/build-artifacts.yml
223+
with:
224+
plan: '{"announcement_is_prerelease":true}'
225+
build-kind: nightly
226+
cargo-profile: debug
227+
vsix-profile: debug
402228

.github/workflows/dev-release-verification.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ on:
66
paths:
77
- ".github/workflows/dev-release-verification.yml"
88
- ".github/workflows/release.yml"
9-
- ".github/workflows/build-release-artifacts.yml"
9+
- ".github/workflows/build-artifacts.yml"
1010
- ".github/workflows/publish-vsix.yml"
1111
- ".github/actions/**"
1212
- "Cargo.toml"
1313
- "Cargo.lock"
1414
- "dist-workspace.toml"
1515
- "rust-toolchain.toml"
1616
- "build.rs"
17-
- "scripts/build-release-artifact.sh"
17+
- "scripts/build-artifact.sh"
1818
- "src/**"
1919
- "crates/**"
2020
- "xtask/**"
@@ -28,8 +28,8 @@ concurrency:
2828
cancel-in-progress: true
2929

3030
jobs:
31-
build-release-artifacts:
32-
uses: ./.github/workflows/build-release-artifacts.yml
31+
build-artifacts:
32+
uses: ./.github/workflows/build-artifacts.yml
3333
with:
3434
plan: '{"announcement_is_prerelease":true}'
3535
secrets: inherit

0 commit comments

Comments
 (0)