From 87b1d6c3a55961de155f0b1134dde0d733fbab14 Mon Sep 17 00:00:00 2001 From: Tim Rogers Date: Sat, 30 Nov 2024 13:00:45 +0000 Subject: [PATCH] Simplfying CI setup and bind to Rust 1.83 --- .github/workflows/build_and_release.yml | 55 +++----------------- .github/workflows/pre-commit.yml | 69 ++++++++++++------------- rust-toolchain.toml | 5 ++ 3 files changed, 44 insertions(+), 85 deletions(-) create mode 100644 rust-toolchain.toml diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml index 8e65152..0f6369e 100644 --- a/.github/workflows/build_and_release.yml +++ b/.github/workflows/build_and_release.yml @@ -40,26 +40,9 @@ jobs: - name: Install libudev-dev run: sudo apt-get update && sudo apt-get install libudev-dev if: matrix.job.os == 'ubuntu-latest' || matrix.job.os == 'self-hosted' - - name: Cache Rust dependencies - uses: actions/cache@v4.1.2 - with: - path: target - key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-build- - - name: Install latest Rust nightly - uses: actions-rs/toolchain@v1 - with: - profile: minimal - components: rustc, cargo - toolchain: nightly - override: true - target: ${{ matrix.job.target }} - - name: Run cargo build --release - uses: actions-rs/cargo@v1 - with: - args: --release --target=${{ matrix.job.target }} - command: build + - uses: Swatinem/rust-cache@v2 + - name: Build in release mode + run: cargo build --release --target=${{ matrix.job.target }} - name: Sanitise Git ref for use in filenames id: sanitise_ref run: echo "::set-output name=value::$(echo "${{ github.ref_name }}" | tr '/' '_')" @@ -164,20 +147,7 @@ jobs: - uses: actions/checkout@v4 - name: Install libudev-dev run: sudo apt-get update && sudo apt-get install libudev-dev - - name: Cache Rust dependencies - uses: actions/cache@v4.1.2 - with: - path: target - key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-build- - - name: Install latest Rust nightly - uses: actions-rs/toolchain@v1 - with: - profile: minimal - components: rustc, cargo - toolchain: nightly - override: true + - uses: Swatinem/rust-cache@v2 - name: Install cargo-edit run: cargo install cargo-edit - name: Set the version to a dummy version to allow publishing @@ -234,19 +204,8 @@ jobs: - uses: actions/checkout@v4 - name: Install libudev-dev run: sudo apt-get update && sudo apt-get install libudev-dev - - name: Cache Rust dependencies - uses: actions/cache@v4.1.2 - with: - path: target - key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-build- - - name: Install latest Rust nightly - uses: actions-rs/toolchain@v1 - with: - profile: minimal - components: rustc, cargo - toolchain: nightly - override: true + - uses: Swatinem/rust-cache@v2 + - name: Build in release mode + run: cargo build --release --target=${{ matrix.job.target }} - name: Publish to Crates.io run: cargo publish --token ${{ secrets.CRATES_IO_API_TOKEN }} diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 4800456..2912953 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -8,40 +8,35 @@ jobs: pre-commit: runs-on: ubuntu-latest steps: - - name: Install libudev-dev - run: sudo apt-get update && sudo apt-get install libudev-dev - - - name: Install latest Rust nightly - uses: actions-rs/toolchain@v1 - with: - toolchain: nightly - override: true - components: rustc, rustfmt, clippy - - - name: Check out repository - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - - name: Set up Python - uses: actions/setup-python@v5 - - - name: Detect code style issues - uses: pre-commit/action@v3.0.1 - env: - SKIP: no-commit-to-branch - - - name: Generate patch file - if: failure() - run: | - git diff-index -p HEAD > "${PATCH_FILE}" - [ -s "${PATCH_FILE}" ] && echo "UPLOAD_PATCH_FILE=${PATCH_FILE}" >> "${GITHUB_ENV}" - env: - PATCH_FILE: pre-commit.patch - - - name: Upload patch artifact - if: failure() && env.UPLOAD_PATCH_FILE != null - uses: actions/upload-artifact@v4 - with: - name: ${{ env.UPLOAD_PATCH_FILE }} - path: ${{ env.UPLOAD_PATCH_FILE }} + - name: Install libudev-dev + run: sudo apt-get update && sudo apt-get install libudev-dev + + - name: Check out repository + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Set up Python + uses: actions/setup-python@v5 + + - uses: Swatinem/rust-cache@v2 + + - name: Detect code style issues + uses: pre-commit/action@v3.0.1 + env: + SKIP: no-commit-to-branch + + - name: Generate patch file + if: failure() + run: | + git diff-index -p HEAD > "${PATCH_FILE}" + [ -s "${PATCH_FILE}" ] && echo "UPLOAD_PATCH_FILE=${PATCH_FILE}" >> "${GITHUB_ENV}" + env: + PATCH_FILE: pre-commit.patch + + - name: Upload patch artifact + if: failure() && env.UPLOAD_PATCH_FILE != null + uses: actions/upload-artifact@v4 + with: + name: ${{ env.UPLOAD_PATCH_FILE }} + path: ${{ env.UPLOAD_PATCH_FILE }} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..ad058db --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,5 @@ +[toolchain] +channel = "1.83.0" +components = [ "rustc", "rustfmt", "clippy" ] +targets = [ "x86_64-unknown-linux-gnu", "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "aarch64-apple-darwin", "x86_64-pc-windows-msvc" ] +profile = "minimal" \ No newline at end of file