Skip to content

Commit d5d4157

Browse files
committed
ci: Enable manual LSP build runs
1 parent 4b3e7cc commit d5d4157

1 file changed

Lines changed: 71 additions & 9 deletions

File tree

.github/workflows/lsp.yml

Lines changed: 71 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# LSP Pipeline
22
#
3-
# Builds the LSP binaries, packages the VS Code extension, and optionally
3+
# Builds the LSP binaries, optionally packages the VS Code extension, and optionally
44
# publishes it to the VS Code Marketplace from a manual dispatch.
55

66
name: LSP
77

8-
run-name: LSP ${{ inputs.ref || github.ref_name }}
8+
run-name: LSP ${{ inputs.ref || github.ref_name }} (${{ inputs.target || 'all' }})
99

1010
on:
1111
workflow_call:
@@ -19,31 +19,85 @@ on:
1919
ref:
2020
type: string
2121
required: false
22+
target:
23+
type: string
24+
default: all
25+
package_vscode:
26+
type: boolean
27+
default: true
2228
workflow_dispatch:
2329
inputs:
30+
target:
31+
description: "LSP target to build."
32+
type: choice
33+
default: all
34+
options:
35+
- all
36+
- x86_64-apple-darwin
37+
- aarch64-apple-darwin
38+
- x86_64-unknown-linux-musl
39+
- aarch64-unknown-linux-musl
40+
- x86_64-pc-windows-msvc
41+
- aarch64-pc-windows-msvc
42+
package_vscode:
43+
description: "Package the VS Code extension after building all targets."
44+
type: boolean
45+
default: false
2446
publish:
25-
description: "Publish the VS Code extension to the Marketplace. Requires dry_run=false."
47+
description: "Publish the VS Code extension to the Marketplace. Requires target=all, package_vscode=true, dry_run=false."
2648
type: boolean
2749
default: false
2850
dry_run:
2951
description: "Package the VSIX without publishing it."
3052
type: boolean
3153
default: true
3254
ref:
33-
description: "Git ref to package, such as v1.2.3 or v1.2.3-canary.0."
55+
description: "Git ref to build, such as v1.2.3 or v1.2.3-canary.0."
3456
required: false
3557
type: string
3658

3759
permissions:
3860
contents: read
3961

4062
concurrency:
41-
group: lsp-${{ inputs.ref || github.ref_name }}
63+
group: lsp-${{ inputs.ref || github.ref_name }}-${{ inputs.target || 'all' }}
4264
cancel-in-progress: false
4365

4466
jobs:
67+
validate-inputs:
68+
name: "Validate inputs"
69+
runs-on: ubuntu-latest
70+
timeout-minutes: 5
71+
steps:
72+
- name: Validate target
73+
env:
74+
TARGET: ${{ inputs.target || 'all' }}
75+
PACKAGE_VSCODE: ${{ inputs.package_vscode }}
76+
PUBLISH: ${{ inputs.publish }}
77+
DRY_RUN: ${{ inputs.dry_run }}
78+
run: |
79+
case "$TARGET" in
80+
all|x86_64-apple-darwin|aarch64-apple-darwin|x86_64-unknown-linux-musl|aarch64-unknown-linux-musl|x86_64-pc-windows-msvc|aarch64-pc-windows-msvc)
81+
;;
82+
*)
83+
echo "::error::Invalid LSP target '$TARGET'."
84+
exit 1
85+
;;
86+
esac
87+
88+
if [ "$PACKAGE_VSCODE" = "true" ] && [ "$TARGET" != "all" ]; then
89+
echo "::error::Packaging the VS Code extension requires target=all."
90+
exit 1
91+
fi
92+
93+
if [ "$PUBLISH" = "true" ] && [ "$DRY_RUN" != "true" ] && { [ "$TARGET" != "all" ] || [ "$PACKAGE_VSCODE" != "true" ]; }; then
94+
echo "::error::Publishing requires target=all and package_vscode=true."
95+
exit 1
96+
fi
97+
4598
build-rust:
4699
name: "Build Rust"
100+
needs: [validate-inputs]
47101
strategy:
48102
fail-fast: false
49103
matrix:
@@ -62,40 +116,47 @@ jobs:
62116
setup: "sudo apt-get update && sudo apt-get install -y build-essential musl-tools clang llvm gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu"
63117
- host: windows-latest
64118
target: x86_64-pc-windows-msvc
65-
setup: "rustup set default-host x86_64-pc-windows-msvc"
66119
- host: windows-latest
67120
target: aarch64-pc-windows-msvc
68-
setup: "rustup set default-host aarch64-pc-windows-msvc"
69121
runs-on: ${{ matrix.settings.host }}
70122
timeout-minutes: 30
71123
steps:
124+
- name: Skip unselected target
125+
if: ${{ inputs.target != 'all' && inputs.target != matrix.settings.target }}
126+
run: echo "Skipping ${{ matrix.settings.target }} because target=${{ inputs.target }}."
127+
72128
- name: Checkout repo
129+
if: ${{ inputs.target == 'all' || inputs.target == matrix.settings.target }}
73130
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
74131
with:
75132
ref: ${{ inputs.ref || github.ref }}
76133
persist-credentials: false
77134
- name: Prepare build environment
78-
if: ${{ matrix.settings.prepare }}
135+
if: ${{ (inputs.target == 'all' || inputs.target == matrix.settings.target) && matrix.settings.prepare }}
79136
run: ${{ matrix.settings.prepare }}
80137

81138
- name: Setup capnproto
139+
if: ${{ inputs.target == 'all' || inputs.target == matrix.settings.target }}
82140
uses: ./.github/actions/setup-capnproto
83141

84142
- name: Rust Setup
143+
if: ${{ inputs.target == 'all' || inputs.target == matrix.settings.target }}
85144
uses: ./.github/actions/setup-rust
86145
with:
87146
github-token: ${{ github.token }}
88147
targets: ${{ matrix.settings.target }}
89148

90149
- name: Build Setup
91150
shell: bash
92-
if: ${{ matrix.settings.setup }}
151+
if: ${{ (inputs.target == 'all' || inputs.target == matrix.settings.target) && matrix.settings.setup }}
93152
run: ${{ matrix.settings.setup }}
94153

95154
- name: Build
155+
if: ${{ inputs.target == 'all' || inputs.target == matrix.settings.target }}
96156
run: ${{ matrix.settings.rust-build-env }} cargo build --profile release-turborepo-lsp -p turborepo-lsp --target ${{ matrix.settings.target }}
97157

98158
- name: Upload Artifacts
159+
if: ${{ inputs.target == 'all' || inputs.target == matrix.settings.target }}
99160
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
100161
with:
101162
name: turborepo-lsp-${{ matrix.settings.target }}
@@ -104,6 +165,7 @@ jobs:
104165
package-vscode:
105166
name: "Package VS Code Extension"
106167
runs-on: ubuntu-24.04
168+
if: ${{ inputs.package_vscode && inputs.target == 'all' }}
107169
timeout-minutes: 30
108170
needs: [build-rust]
109171
outputs:

0 commit comments

Comments
 (0)