Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to '.github/workflows/ci.yaml')
-rw-r--r--.github/workflows/ci.yaml193
1 files changed, 124 insertions, 69 deletions
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 7a6b43a053..79fb7a2d2e 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -15,7 +15,6 @@ env:
CARGO_NET_RETRY: 10
CI: 1
RUST_BACKTRACE: short
- RUSTFLAGS: "-D warnings -D elided_lifetimes_in_paths -D explicit_outlives_requirements -D unsafe_op_in_unsafe_fn -D unused_extern_crates -D unused_lifetimes -D unreachable_pub"
RUSTUP_MAX_RETRIES: 10
jobs:
@@ -25,7 +24,6 @@ jobs:
pull-requests: read
outputs:
typescript: ${{ steps.filter.outputs.typescript }}
- proc_macros: ${{ steps.filter.outputs.proc_macros }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@1441771bbfdd59dcd748680ee64ebd8faab1a242
@@ -34,52 +32,54 @@ jobs:
filters: |
typescript:
- 'editors/code/**'
- proc_macros:
- - 'crates/tt/**'
- - 'crates/proc-macro-api/**'
- - 'crates/proc-macro-srv/**'
- - 'crates/proc-macro-srv-cli/**'
proc-macro-srv:
- needs: changes
- if: github.repository == 'rust-lang/rust-analyzer' && needs.changes.outputs.proc_macros == 'true'
+ if: github.repository == 'rust-lang/rust-analyzer'
name: proc-macro-srv
runs-on: ubuntu-latest
+ env:
+ RUSTFLAGS: "-D warnings"
+
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
+ - name: Install rustup-toolchain-install-master
+ run: cargo install [email protected]
+
+ # Install a pinned rustc commit to avoid surprises
- name: Install Rust toolchain
run: |
- rustup update --no-self-update nightly
- rustup default nightly
- rustup component add --toolchain nightly rust-src rustfmt
+ RUSTC_VERSION=`cat rust-version`
+ rustup-toolchain-install-master ${RUSTC_VERSION} -c rust-src -c rustfmt
+ rustup default ${RUSTC_VERSION}
+
+ # Emulate a nightly toolchain, because the toolchain installed above does not have "nightly"
+ # in its version string.
+ - name: Emulate a nightly toolchain
+ run: echo "RUSTC_BOOTSTRAP=1" >> $GITHUB_ENV
+
# https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/rust.json
- name: Install Rust Problem Matcher
- if: matrix.os == 'ubuntu-latest'
run: echo "::add-matcher::.github/rust.json"
- - name: Cache Dependencies
- uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609
-
- - name: Bump opt-level
- if: matrix.os == 'ubuntu-latest'
- run: sed -i '/\[profile.dev]/a opt-level=1' Cargo.toml
-
- name: Test
- run: cargo test --features sysroot-abi -p rust-analyzer -p proc-macro-srv -p proc-macro-srv-cli -p proc-macro-api -- --quiet
+ run: cargo test --features sysroot-abi -p proc-macro-srv -p proc-macro-srv-cli -p proc-macro-api -- --quiet
+
+ - name: Check salsa dependency
+ run: "! (cargo tree -p proc-macro-srv-cli | grep -q salsa)"
rust:
if: github.repository == 'rust-lang/rust-analyzer'
name: Rust
runs-on: ${{ matrix.os }}
env:
+ RUSTFLAGS: "-Dwarnings"
CC: deny_c
strategy:
- fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
@@ -93,7 +93,7 @@ jobs:
run: |
rustup update --no-self-update stable
rustup default stable
- rustup component add --toolchain stable rust-src
+ rustup component add --toolchain stable rust-src clippy
# We always use a nightly rustfmt, regardless of channel, because we need
# --file-lines.
rustup toolchain install nightly --profile minimal --component rustfmt
@@ -102,51 +102,105 @@ jobs:
if: matrix.os == 'ubuntu-latest'
run: echo "::add-matcher::.github/rust.json"
- - name: Cache Dependencies
- uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609
+ # - name: Cache Dependencies
+ # uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
+ # with:
+ # workspaces: |
+ # . -> target
+ # ./crates/proc-macro-srv/proc-macro-test/imp -> target
- - name: Bump opt-level
- if: matrix.os == 'ubuntu-latest'
- run: sed -i '/\[profile.dev]/a opt-level=1' Cargo.toml
+ - name: Install nextest
+ uses: taiki-e/install-action@nextest
- name: Codegen checks (rust-analyzer)
+ if: matrix.os == 'ubuntu-latest'
run: cargo codegen --check
- - name: Compile (tests)
- run: cargo test --no-run --locked
+ - name: Compile tests
+ run: cargo test --no-run
- # It's faster to `test` before `build` ¯\_(ツ)_/¯
- - name: Compile (rust-analyzer)
- if: matrix.os == 'ubuntu-latest'
- run: cargo build --quiet
+ - name: Run tests
+ run: cargo nextest run --no-fail-fast --hide-progress-bar --status-level fail
- - name: Test
- if: matrix.os == 'ubuntu-latest' || matrix.os == 'windows-latest' || github.event_name == 'push'
- run: cargo test -- --quiet
+ - name: Cancel parallel jobs
+ if: failure()
+ run: |
+ # https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#cancel-a-workflow-run
+ curl -L \
+ -X POST \
+ -H "Accept: application/vnd.github.v3+json" \
+ -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
+ -H "X-GitHub-Api-Version: 2022-11-28" \
+ https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/cancel
+
+ - name: Run Clippy
+ if: matrix.os == 'macos-latest'
+ run: cargo clippy --all-targets -- -D clippy::disallowed_macros -D clippy::dbg_macro -D clippy::todo -D clippy::print_stdout -D clippy::print_stderr
- - name: Switch to stable toolchain
+ analysis-stats:
+ if: github.repository == 'rust-lang/rust-analyzer'
+ runs-on: ubuntu-latest
+ env:
+ RUSTC_BOOTSTRAP: 1
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Install Rust toolchain
run: |
rustup update --no-self-update stable
- rustup component add --toolchain stable rust-src clippy
rustup default stable
+ rustup component add rustfmt
- - name: Run analysis-stats on rust-analyzer
- if: matrix.os == 'ubuntu-latest'
- run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats .
+ # - name: Cache Dependencies
+ # uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
- - name: Run analysis-stats on the rust standard libraries
- if: matrix.os == 'ubuntu-latest'
- env:
- RUSTC_BOOTSTRAP: 1
- run: target/${{ matrix.target }}/debug/rust-analyzer analysis-stats --with-deps --no-sysroot --no-test $(rustc --print sysroot)/lib/rustlib/src/rust/library/
+ - name: Bump opt-level
+ run: sed -i '/\[profile.dev]/a opt-level=1' Cargo.toml
- - name: clippy
- if: matrix.os == 'windows-latest'
- run: cargo clippy --all-targets -- -D clippy::disallowed_macros -D clippy::dbg_macro -D clippy::todo -D clippy::print_stdout -D clippy::print_stderr
+ - run: cargo build -p rust-analyzer
- - name: rustfmt
- if: matrix.os == 'ubuntu-latest'
- run: cargo fmt -- --check
+ - name: ./rust-analyzer
+ run: ./target/debug/rust-analyzer analysis-stats . -q
+
+ - name: sysroot/lib/rustlib/src/rust/library/
+ run: ./target/debug/rust-analyzer analysis-stats --with-deps --no-sysroot --no-test $(rustc --print sysroot)/lib/rustlib/src/rust/library/ -q
+
+ rustfmt:
+ if: github.repository == 'rust-lang/rust-analyzer'
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Install Rust toolchain
+ run: |
+ rustup update --no-self-update stable
+ rustup default stable
+ rustup component add rustfmt
+
+ - run: cargo fmt -- --check
+
+ miri:
+ if: github.repository == 'rust-lang/rust-analyzer'
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Install Rust toolchain
+ run: |
+ rustup update --no-self-update nightly
+ rustup default nightly
+ rustup component add miri
+
+ # - name: Cache Dependencies
+ # uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
+
+ - run: cargo miri test -p intern
# Weird targets to catch non-portable code
rust-cross:
@@ -154,11 +208,16 @@ jobs:
name: Rust Cross
runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ target: [powerpc-unknown-linux-gnu, x86_64-unknown-linux-musl, wasm32-unknown-unknown]
+ include:
+ # The rust-analyzer binary is not expected to compile on WASM, but the IDE
+ # crate should
+ - target: wasm32-unknown-unknown
+ ide-only: true
env:
- targets: "powerpc-unknown-linux-gnu x86_64-unknown-linux-musl"
- # The rust-analyzer binary is not expected to compile on WASM, but the IDE
- # crate should
- targets_ide: "wasm32-unknown-unknown"
+ RUSTFLAGS: "-Dwarnings"
steps:
- name: Checkout repository
@@ -167,19 +226,15 @@ jobs:
- name: Install Rust toolchain
run: |
rustup update --no-self-update stable
- rustup target add ${{ env.targets }} ${{ env.targets_ide }}
+ rustup target add ${{ matrix.target }}
- - name: Cache Dependencies
- uses: Swatinem/rust-cache@9bdad043e88c75890e36ad3bbc8d27f0090dd609
+ # - name: Cache Dependencies
+ # uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6
- - name: Check
- run: |
- for target in ${{ env.targets }}; do
- cargo check --target=$target --all-targets
- done
- for target in ${{ env.targets_ide }}; do
- cargo check -p ide --target=$target --all-targets
- done
+ - run: cargo check --target=${{ matrix.target }} --all-targets -p ide
+ if: ${{ matrix.ide-only }}
+ - run: cargo check --target=${{ matrix.target }} --all-targets
+ if: ${{ !matrix.ide-only }}
typescript:
needs: changes
@@ -261,7 +316,7 @@ jobs:
run: typos
conclusion:
- needs: [rust, rust-cross, typescript, typo-check, proc-macro-srv]
+ needs: [rust, rust-cross, typescript, typo-check, proc-macro-srv, miri, rustfmt, analysis-stats]
# We need to ensure this job does *not* get skipped if its dependencies fail,
# because a skipped job is considered a success by GitHub. So we have to
# overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run