gn-language-server/.github/workflows/ci.yml
2025-12-23 00:51:31 +09:00

253 lines
8.1 KiB
YAML

# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: CI
on:
push:
branches:
- "main"
- "v*.*.x"
tags:
- "v*.*.*"
pull_request:
branches:
- "main"
- "v*.*.x"
env:
CARGO_TERM_COLOR: always
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.25.5
- uses: dtolnay/rust-toolchain@8a40291d6a0a08b8fb98b13bad5a0305b42d5f9c # 1.92.0
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '22'
- run: go install github.com/google/addlicense@dc31ac9ffcca99c9457226366135701794b128c0 # v1.1.1
- run: addlicense -check .
- run: cargo fmt --check
- run: cargo clippy
- run: cargo install --force --locked cargo-deny@0.18.2
- run: cargo deny check licenses
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: npm ci
working-directory: vscode-gn
- run: npm run lint
working-directory: vscode-gn
- run: ./gradlew check
working-directory: intellij-gn
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@8a40291d6a0a08b8fb98b13bad5a0305b42d5f9c # 1.92.0
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '22'
- run: cargo test
- run: ./gradlew test
working-directory: intellij-gn
build-server-and-extension:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
rust_target: x86_64-unknown-linux-musl
vscode_target: linux-x64
- os: macos-latest
rust_target: aarch64-apple-darwin
vscode_target: darwin-arm64
- os: windows-latest
rust_target: x86_64-pc-windows-msvc
vscode_target: win32-x64
runs-on: ${{ matrix.os }}
env:
CARGO_BUILD_TARGET: ${{ matrix.rust_target }}
name: build (${{ matrix.vscode_target }})
steps:
- uses: actions/checkout@v4
- run: sudo apt-get install musl-tools
if: matrix.os == 'ubuntu-latest'
- uses: dtolnay/rust-toolchain@8a40291d6a0a08b8fb98b13bad5a0305b42d5f9c # 1.92.0
with:
targets: ${{ matrix.rust_target }}
- uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: npm ci
working-directory: vscode-gn
- run: npm run build
working-directory: vscode-gn
- run: npx vsce package $(if python3 ../scripts/is_prerelease.py; then echo --pre-release; fi) --target=${{ matrix.vscode_target }}
working-directory: vscode-gn
shell: bash
- uses: actions/upload-artifact@v4
with:
name: vscode-gn-vsix-${{ matrix.vscode_target }}
path: vscode-gn/*.vsix
- uses: actions/upload-artifact@v4
with:
name: gn-language-server-${{ matrix.rust_target }}
path: vscode-gn/dist/gn-language-server*
build-intellij-plugin:
runs-on: ubuntu-latest
needs:
- build-server-and-extension
name: build IntelliJ plugin
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '22'
- uses: actions/download-artifact@v4
with:
pattern: gn-language-server-x86_64-unknown-linux-musl
path: ${{ github.workspace }}/lsp-prebuilts
- uses: actions/download-artifact@v4
with:
pattern: gn-language-server-aarch64-apple-darwin
path: ${{ github.workspace }}/lsp-prebuilts
- uses: actions/download-artifact@v4
with:
pattern: gn-language-server-x86_64-pc-windows-msvc
path: ${{ github.workspace }}/lsp-prebuilts
- run: mv gn-language-server-x86_64-unknown-linux-musl x86_64-unknown-linux-musl
working-directory: lsp-prebuilts
- run: mv gn-language-server-aarch64-apple-darwin aarch64-apple-darwin
working-directory: lsp-prebuilts
- run: mv gn-language-server-x86_64-pc-windows-msvc x86_64-pc-windows-msvc
working-directory: lsp-prebuilts
- run: ls -lR .
working-directory: lsp-prebuilts
- run: ./gradlew signPlugin
working-directory: intellij-gn
env:
GN_LSP_PREBUILTS: ${{ github.workspace }}/lsp-prebuilts
JETBRAINS_CERT: ${{ secrets.JETBRAINS_CERT }}
JETBRAINS_PRIVATE_KEY: ${{ secrets.JETBRAINS_PRIVATE_KEY }}
- uses: actions/upload-artifact@v4
with:
name: intellij-gn
path: intellij-gn/build/distributions/intellij-gn-*-signed.zip
attestation:
runs-on: ubuntu-latest
permissions:
id-token: write
attestations: write
needs:
- build-server-and-extension
- build-intellij-plugin
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/artifacts
- uses: actions/attest-build-provenance@v3
with:
subject-path: artifacts/**
upload-release-artifacts:
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- build-server-and-extension
- build-intellij-plugin
- test
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: vscode-gn-vsix-*
path: ${{ github.workspace }}/artifacts
merge-multiple: true
- uses: actions/download-artifact@v4
with:
pattern: intellij-gn
path: ${{ github.workspace }}/artifacts
- run: mv intellij-gn/*.zip ./ && rmdir intellij-gn
working-directory: artifacts
- run: ls -l .
working-directory: artifacts
- run: gh release upload "${{ github.ref_name }}" artifacts/*
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: startsWith(github.ref, 'refs/tags/v')
publish-vscode:
runs-on: ubuntu-latest
needs:
- build-server-and-extension
- test
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
pattern: vscode-gn-vsix-*
path: ${{ github.workspace }}/vscode-gn
merge-multiple: true
- run: ls -l *.vsix
working-directory: vscode-gn
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: npm ci
working-directory: vscode-gn
if: startsWith(github.ref, 'refs/tags/v')
- run: npx -y vsce publish --skip-duplicate $(python3 ../scripts/release_flags.py) --packagePath *.vsix
working-directory: vscode-gn
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
if: startsWith(github.ref, 'refs/tags/v')
- run: npx -y ovsx publish --pat ${{ secrets.OVSX_PAT }} $(if python3 ../scripts/is_prerelease.py; then echo --pre-release; fi) --packagePath *.vsix
working-directory: vscode-gn
if: startsWith(github.ref, 'refs/tags/v')
publish-cargo:
runs-on: ubuntu-latest
needs:
- build-server-and-extension
- test
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@8a40291d6a0a08b8fb98b13bad5a0305b42d5f9c # 1.92.0
- run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
if: startsWith(github.ref, 'refs/tags/v')