From 42797f33e896c2bd6232ad6d136eb683c473d8e6 Mon Sep 17 00:00:00 2001 From: Tim de Jager Date: Thu, 19 Sep 2024 19:33:16 +0200 Subject: [PATCH 1/7] feat: extend compile pipeline --- .github/workflows/rust-compile.yml | 132 +++++++++++++++-------------- 1 file changed, 68 insertions(+), 64 deletions(-) diff --git a/.github/workflows/rust-compile.yml b/.github/workflows/rust-compile.yml index f3a5173..953f99f 100644 --- a/.github/workflows/rust-compile.yml +++ b/.github/workflows/rust-compile.yml @@ -1,72 +1,76 @@ on: - push: - branches: + push: + branches: - "main" - pull_request: - + pull_request: + name: Rust - + concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + env: - RUST_LOG: info - RUST_BACKTRACE: 1 - RUSTFLAGS: "-D warnings" - CARGO_TERM_COLOR: always - + RUST_LOG: info + RUST_BACKTRACE: 1 + RUSTFLAGS: "-D warnings" + CARGO_TERM_COLOR: always + jobs: - check-rustdoc-links: - name: Check intra-doc links - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions-rust-lang/setup-rust-toolchain@v1 - - run: | - for package in $(cargo metadata --no-deps --format-version=1 | jq -r '.packages[] | .name'); do - cargo rustdoc -p "$package" --all-features -- -D warnings -W unreachable-pub - done - - format_and_lint: - name: Format and Lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - components: clippy, rustfmt - - name: Run rustfmt - uses: actions-rust-lang/rustfmt@v1 - - name: Run clippy - run: cargo clippy --all-targets - - test: - name: Test - runs-on: ubuntu-latest - needs: [ format_and_lint ] - steps: - - name: Checkout source code - uses: actions/checkout@v4 + check-rustdoc-links: + name: Check intra-doc links + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + - run: | + for package in $(cargo metadata --no-deps --format-version=1 | jq -r '.packages[] | .name'); do + cargo rustdoc -p "$package" --all-features -- -D warnings -W unreachable-pub + done + + format_and_lint: + name: Format and Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: clippy, rustfmt + - name: Run rustfmt + uses: actions-rust-lang/rustfmt@v1 + - name: Run clippy + run: cargo clippy --all-targets + + test: + name: Test + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: $ {{ matrix.os }} + needs: [format_and_lint] + steps: + - name: Checkout source code + uses: actions/checkout@v4 + - name: Install Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt + cache: false + + - uses: Swatinem/rust-cache@v2 + + - name: Install cargo nextest + uses: taiki-e/install-action@v2 + with: + tool: cargo-nextest - - name: Install Rust toolchain - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - components: rustfmt - cache: false + - name: Run tests + run: > + cargo nextest run --workspace - - name: Install cargo nextest - uses: taiki-e/install-action@v2 - with: - tool: cargo-nextest - - - name: Run tests - run: > - cargo nextest run --workspace - - - name: Run doctests - run: > - cargo test --doc - \ No newline at end of file + - name: Run doctests + run: > + cargo test --doc From 755f5508cd5d733a13b4f9273c7720472b2cfe14 Mon Sep 17 00:00:00 2001 From: Tim de Jager Date: Fri, 20 Sep 2024 09:28:13 +0200 Subject: [PATCH 2/7] fix: inter-docs links --- .github/workflows/rust-compile.yml | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/rust-compile.yml b/.github/workflows/rust-compile.yml index 953f99f..2ea0118 100644 --- a/.github/workflows/rust-compile.yml +++ b/.github/workflows/rust-compile.yml @@ -23,9 +23,28 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions-rust-lang/setup-rust-toolchain@v1 - - run: | - for package in $(cargo metadata --no-deps --format-version=1 | jq -r '.packages[] | .name'); do - cargo rustdoc -p "$package" --all-features -- -D warnings -W unreachable-pub + - run: > + # Check intra-doc links, thanks to ChatGPT + cargo metadata --no-deps --format-version=1 \ + | jq -r '.packages[] | .name as $pname | .targets[] | [$pname, .kind[], .name] | @tsv' \ + | while IFS=$'\t' read -r package kind name; do + case "$kind" in + lib) + cargo rustdoc -p "$package" --lib --all-features -- -D warnings -W unreachable-pub + ;; + bin) + cargo rustdoc -p "$package" --bin "$name" --all-features -- -D warnings -W unreachable-pub + ;; + example) + cargo rustdoc -p "$package" --example "$name" --all-features -- -D warnings -W unreachable-pub + ;; + test) + cargo rustdoc -p "$package" --test "$name" --all-features -- -D warnings -W unreachable-pub + ;; + bench) + cargo rustdoc -p "$package" --bench "$name" --all-features -- -D warnings -W unreachable-pub + ;; + esac done format_and_lint: @@ -54,6 +73,7 @@ jobs: steps: - name: Checkout source code uses: actions/checkout@v4 + - name: Install Rust toolchain uses: actions-rust-lang/setup-rust-toolchain@v1 with: From 6788a2ce1b881732318b97962bbbb53468baaad8 Mon Sep 17 00:00:00 2001 From: Tim de Jager Date: Fri, 20 Sep 2024 09:31:24 +0200 Subject: [PATCH 3/7] fix: try to get bash function working --- .github/workflows/rust-compile.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust-compile.yml b/.github/workflows/rust-compile.yml index 2ea0118..341bb6b 100644 --- a/.github/workflows/rust-compile.yml +++ b/.github/workflows/rust-compile.yml @@ -23,7 +23,8 @@ jobs: steps: - uses: actions/checkout@v4 - uses: actions-rust-lang/setup-rust-toolchain@v1 - - run: > + - shell: bash + run: > # Check intra-doc links, thanks to ChatGPT cargo metadata --no-deps --format-version=1 \ | jq -r '.packages[] | .name as $pname | .targets[] | [$pname, .kind[], .name] | @tsv' \ From b7f38c5347270b7ff22daca07837fdbbd5d1a3ff Mon Sep 17 00:00:00 2001 From: Tim de Jager Date: Fri, 20 Sep 2024 09:38:14 +0200 Subject: [PATCH 4/7] fix: try to fix ci again --- .github/workflows/rust-compile.yml | 24 +----------------------- intra-doc-links.bash | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 23 deletions(-) create mode 100644 intra-doc-links.bash diff --git a/.github/workflows/rust-compile.yml b/.github/workflows/rust-compile.yml index 341bb6b..d5729cb 100644 --- a/.github/workflows/rust-compile.yml +++ b/.github/workflows/rust-compile.yml @@ -25,29 +25,7 @@ jobs: - uses: actions-rust-lang/setup-rust-toolchain@v1 - shell: bash run: > - # Check intra-doc links, thanks to ChatGPT - cargo metadata --no-deps --format-version=1 \ - | jq -r '.packages[] | .name as $pname | .targets[] | [$pname, .kind[], .name] | @tsv' \ - | while IFS=$'\t' read -r package kind name; do - case "$kind" in - lib) - cargo rustdoc -p "$package" --lib --all-features -- -D warnings -W unreachable-pub - ;; - bin) - cargo rustdoc -p "$package" --bin "$name" --all-features -- -D warnings -W unreachable-pub - ;; - example) - cargo rustdoc -p "$package" --example "$name" --all-features -- -D warnings -W unreachable-pub - ;; - test) - cargo rustdoc -p "$package" --test "$name" --all-features -- -D warnings -W unreachable-pub - ;; - bench) - cargo rustdoc -p "$package" --bench "$name" --all-features -- -D warnings -W unreachable-pub - ;; - esac - done - + ./intra-doc-links.bash format_and_lint: name: Format and Lint runs-on: ubuntu-latest diff --git a/intra-doc-links.bash b/intra-doc-links.bash new file mode 100644 index 0000000..96d586f --- /dev/null +++ b/intra-doc-links.bash @@ -0,0 +1,21 @@ +cargo metadata --no-deps --format-version=1 \ +| jq -r '.packages[] | .name as $pname | .targets[] | [$pname, .kind[], .name] | @tsv' \ +| while IFS=$'\t' read -r package kind name; do + case "$kind" in + lib) + cargo rustdoc -p "$package" --lib --all-features -- -D warnings -W unreachable-pub + ;; + bin) + cargo rustdoc -p "$package" --bin "$name" --all-features -- -D warnings -W unreachable-pub + ;; + example) + cargo rustdoc -p "$package" --example "$name" --all-features -- -D warnings -W unreachable-pub + ;; + test) + cargo rustdoc -p "$package" --test "$name" --all-features -- -D warnings -W unreachable-pub + ;; + bench) + cargo rustdoc -p "$package" --bench "$name" --all-features -- -D warnings -W unreachable-pub + ;; + esac +done From 3b9092387e7e5a9d2760732284e1df8ba67342fa Mon Sep 17 00:00:00 2001 From: Tim de Jager Date: Fri, 20 Sep 2024 10:02:32 +0200 Subject: [PATCH 5/7] feat: make executable --- intra-doc-links.bash | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 intra-doc-links.bash diff --git a/intra-doc-links.bash b/intra-doc-links.bash old mode 100644 new mode 100755 From 6cc4ece999b29db2f5ade20e0dbbba779d9593fa Mon Sep 17 00:00:00 2001 From: Tim de Jager Date: Fri, 20 Sep 2024 10:03:01 +0200 Subject: [PATCH 6/7] feat: add bash --- intra-doc-links.bash | 1 + 1 file changed, 1 insertion(+) diff --git a/intra-doc-links.bash b/intra-doc-links.bash index 96d586f..4b4b687 100755 --- a/intra-doc-links.bash +++ b/intra-doc-links.bash @@ -1,3 +1,4 @@ +#!/bin/bash cargo metadata --no-deps --format-version=1 \ | jq -r '.packages[] | .name as $pname | .targets[] | [$pname, .kind[], .name] | @tsv' \ | while IFS=$'\t' read -r package kind name; do From bb2c6f2f68f1f64c19c1ffbb22cd82727dc6ca7a Mon Sep 17 00:00:00 2001 From: Tim de Jager Date: Fri, 20 Sep 2024 10:09:09 +0200 Subject: [PATCH 7/7] fix: runners --- .github/workflows/rust-compile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust-compile.yml b/.github/workflows/rust-compile.yml index d5729cb..8a3746a 100644 --- a/.github/workflows/rust-compile.yml +++ b/.github/workflows/rust-compile.yml @@ -47,7 +47,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - runs-on: $ {{ matrix.os }} + runs-on: ${{ matrix.os }} needs: [format_and_lint] steps: - name: Checkout source code