Repository navigation
feat(lsp-policy): 引用工具窗口的分组、树行与用法行交给 Core #84
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Rust Core | |
| # Builds, lints and tests only the Rust Core crates a pull request can affect: | |
| # the crates whose files changed and every crate that depends on them, as | |
| # chosen by scripts/rust-core/affected-crates.mjs. Linux checks every selected | |
| # crate. macOS and Windows run the tests of the selected crates that declare | |
| # those hosts, once the pull request is ready for review and Linux passed. | |
| # | |
| # There is no path filter: a change that affects no crate still reports the | |
| # "Rust Core gate" check, which branch rules can require. | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened, ready_for_review] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: rust-core-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| CARGO_TERM_COLOR: always | |
| # CI compiles each crate once: incremental state and full debug information | |
| # would only cost time and disk space. | |
| CARGO_INCREMENTAL: 0 | |
| CARGO_PROFILE_DEV_DEBUG: line-tables-only | |
| jobs: | |
| select: | |
| name: Select crates | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| outputs: | |
| rust: ${{ steps.select.outputs.rust }} | |
| packages: ${{ steps.select.outputs.packages }} | |
| test-args: ${{ steps.select.outputs.test-args }} | |
| crate-directories: ${{ steps.select.outputs.crate-directories }} | |
| hosts: ${{ steps.select.outputs.hosts }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| # A pull request checks out its merge commit, whose first parent is | |
| # the branch it merges into. | |
| fetch-depth: 2 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| - uses: dtolnay/rust-toolchain@1.100.0 | |
| - name: Test the CI scripts | |
| run: node --test scripts/rust-core/*.test.mjs | |
| - name: Check that every test runs on a host CI tests its crate on | |
| run: node scripts/rust-core/verify-platform-tests.mjs | |
| - name: Select crates | |
| id: select | |
| env: | |
| # A manual run checks every crate. | |
| SCOPE: ${{ github.event_name == 'pull_request' && '--base HEAD^1' || '--all' }} | |
| run: | | |
| read -ra scope <<< "$SCOPE" | |
| node scripts/rust-core/affected-crates.mjs --github "${scope[@]}" | |
| linux: | |
| name: Linux | |
| needs: select | |
| if: needs.select.outputs.rust == 'true' | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| env: | |
| # One build directory for the lints, Rustdoc and the tests. | |
| CARGO_TARGET_DIR: ${{ github.workspace }}/rust/target | |
| PACKAGES: ${{ needs.select.outputs.packages }} | |
| TEST_ARGS: ${{ needs.select.outputs.test-args }} | |
| CRATE_DIRECTORIES: ${{ needs.select.outputs.crate-directories }} | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| - uses: dtolnay/rust-toolchain@1.100.0 | |
| with: | |
| components: clippy, rustfmt | |
| targets: x86_64-pc-windows-msvc | |
| # Only downloaded crates are cached: build output would not fit the | |
| # repository cache quota next to the SDK end-to-end cache. | |
| - uses: actions/cache@v6 | |
| with: | |
| path: | | |
| ~/.cargo/registry/index | |
| ~/.cargo/registry/cache | |
| ~/.cargo/git/db | |
| key: rust-core-cargo-${{ hashFiles('rust/Cargo.lock', 'scripts/rust-core/comment-lexer/Cargo.lock') }} | |
| restore-keys: rust-core-cargo- | |
| - name: Check formatting | |
| run: cargo fmt --manifest-path rust/Cargo.toml --all -- --check | |
| - name: Check the log event catalog | |
| run: node scripts/logging/generate-log-events.mjs --check | |
| - name: Check comments | |
| run: | | |
| read -ra directories <<< "$CRATE_DIRECTORIES" | |
| scripts/rust-core/verify-rust-core-comments.sh "${directories[@]}" | |
| - name: Lint | |
| run: | | |
| read -ra packages <<< "$PACKAGES" | |
| cargo clippy --locked --manifest-path rust/Cargo.toml "${packages[@]}" --all-targets --all-features -- -D warnings | |
| # Code behind cfg(windows) compiles only for Windows. Checking it here | |
| # finds its errors without a Windows runner; default features only, | |
| # because the remote server feature targets Unix hosts. | |
| - name: Lint for Windows | |
| run: | | |
| read -ra packages <<< "$PACKAGES" | |
| cargo clippy --locked --manifest-path rust/Cargo.toml "${packages[@]}" --all-targets --target x86_64-pc-windows-msvc -- -D warnings | |
| - name: Test | |
| run: | | |
| read -ra arguments <<< "$TEST_ARGS" | |
| cargo test --locked --manifest-path rust/Cargo.toml "${arguments[@]}" | |
| hosts: | |
| name: ${{ matrix.name }} | |
| needs: [select, linux] | |
| # Draft pull requests run Linux only, like the desktop repository. | |
| if: needs.select.outputs.hosts != '[]' && (github.event_name != 'pull_request' || !github.event.pull_request.draft) | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJSON(needs.select.outputs.hosts) }} | |
| runs-on: ${{ matrix.runner }} | |
| timeout-minutes: 45 | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| TEST_ARGS: ${{ matrix.test-args }} | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: dtolnay/rust-toolchain@1.100.0 | |
| - name: Test | |
| run: | | |
| read -ra arguments <<< "$TEST_ARGS" | |
| cargo test --locked --manifest-path rust/Cargo.toml "${arguments[@]}" | |
| gate: | |
| name: Rust Core gate | |
| needs: [select, linux, hosts] | |
| if: always() | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| # A job that had nothing to check is skipped; any other result fails. | |
| - name: Require every job to pass or be skipped | |
| env: | |
| NEEDS: ${{ toJSON(needs) }} | |
| run: | | |
| jq -r 'to_entries[] | "\(.key): \(.value.result)"' <<< "$NEEDS" | |
| failed="$(jq -r '[to_entries[] | select(.value.result != "success" and .value.result != "skipped") | .key] | join(", ")' <<< "$NEEDS")" | |
| if [[ -n "$failed" ]]; then | |
| echo "::error::Rust Core jobs did not pass: $failed" | |
| exit 1 | |
| fi |