From 1852f24e033da39a084f9092000d4ea821d48992 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Thu, 22 Aug 2024 10:21:53 +0200 Subject: [PATCH 1/6] Remove old linting CI and add new New linting job almost verbatim copied from pfctl-rs --- .github/workflows/ci.yml | 15 --------------- .github/workflows/linting.yml | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/linting.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d646dfd..ed4a23b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,21 +23,6 @@ jobs: - name: Check formatting run: cargo fmt -- --check - linting: - runs-on: macos-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - components: clippy - default: true - - name: Lint (clippy) - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - audit: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 0000000..d97b484 --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,28 @@ +--- +name: Rust linting +on: + pull_request: + paths: + - .github/workflows/linting.yml + - '**/*.rs' + workflow_dispatch: + +permissions: {} + +jobs: + clippy-linting: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions-rs/toolchain@v1.0.6 + with: + toolchain: stable + profile: minimal + components: clippy + default: true + + - name: Clippy check + env: + RUSTFLAGS: --deny warnings + run: cargo clippy --locked --all-targets From 70381a157ed5c845c0eeab72acf62e9f155a5a4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Thu, 22 Aug 2024 10:23:15 +0200 Subject: [PATCH 2/6] Remove cargo audit CI We have decided in another library project that it does not make much sense to audit library-only crates. It creates more needless churn than it helps. --- .github/workflows/ci.yml | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed4a23b..e3c498f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,26 +23,6 @@ jobs: - name: Check formatting run: cargo fmt -- --check - audit: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - default: true - - name: Install cargo-audit - uses: actions-rs/install@v0.1.2 - with: - crate: cargo-audit - version: latest - use-tool-cache: true - - name: Audit - run: cargo audit --deny warnings - - build-and-test: strategy: matrix: From 24aaf733dbf5fe0b7bcf042c0af5d3ab060f3c99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Thu, 22 Aug 2024 10:25:16 +0200 Subject: [PATCH 3/6] Move Rust formatting check to separate workflow Workflow copied from pfctl-rs --- .github/workflows/ci.yml | 13 ------------- .github/workflows/formatting.yml | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/formatting.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3c498f..dce316c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,19 +10,6 @@ env: RUSTFLAGS: --deny warnings jobs: - formatting: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - components: rustfmt - default: true - - name: Check formatting - run: cargo fmt -- --check - build-and-test: strategy: matrix: diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml new file mode 100644 index 0000000..ab9b995 --- /dev/null +++ b/.github/workflows/formatting.yml @@ -0,0 +1,28 @@ +--- +name: Rust formatting +on: + pull_request: + paths: + - .github/workflows/formatting.yml + - '**/*.rs' + workflow_dispatch: + +permissions: {} + +jobs: + check-formatting: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #v1.0.7 + with: + toolchain: stable + profile: minimal + components: rustfmt + default: true + + - name: Check formatting + run: | + rustfmt --version + cargo fmt -- --check From 5b796cb3291a1b304103440004dc4d6153fe716f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Thu, 22 Aug 2024 10:30:02 +0200 Subject: [PATCH 4/6] Upgrade build-and-test CI workflow Copied from nftnl-rs. Also checks minimal versions now. Also checks that docs build cleanly --- .github/workflows/build-and-test.yml | 69 ++++++++++++++++++++++++++++ .github/workflows/ci.yml | 37 --------------- 2 files changed, 69 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/build-and-test.yml delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..fec07a3 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,69 @@ +--- +name: Build and test +on: + pull_request: + paths: + - .github/workflows/build-and-test.yml + - '**/*.rs' + - Cargo.toml + - Cargo.lock + workflow_dispatch: + +permissions: {} + +env: + CARGO_TERM_COLOR: always + RUSTFLAGS: --deny warnings + +jobs: + build-and-test: + strategy: + matrix: + # Keep MSRV in sync with rust-version in Cargo.toml + rust: [stable, beta, nightly, 1.64.0] + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #v1.0.7 + with: + toolchain: ${{ matrix.rust }} + profile: minimal + default: true + + - name: Build + run: cargo build --all-targets --locked + + - name: Test + run: cargo test --locked + + # Make sure documentation builds without warnings (broken links etc) + - name: Generate documentation + if: matrix.rust == 'stable' + run: RUSTDOCFLAGS="--deny warnings" cargo doc + + # Make sure the library builds with all dependencies downgraded to their + # oldest versions allowed by the semver spec. This ensures we have not + # under-specified any dependency + minimal-versions: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + + - name: Install stable Rust + uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #v1.0.7 + with: + toolchain: stable + profile: minimal + + - name: Install nightly Rust + uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af #v1.0.7 + with: + toolchain: nightly + profile: minimal + + - name: Downgrade dependencies to minimal versions + run: cargo +nightly update -Z minimal-versions + + - name: Compile with minimal versions + run: cargo +stable build --all-targets --locked diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index dce316c..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,37 +0,0 @@ - -name: Build and test -on: - - push - # Build if requested manually from the Actions tab - - workflow_dispatch - -env: - CARGO_TERM_COLOR: always - RUSTFLAGS: --deny warnings - -jobs: - build-and-test: - strategy: - matrix: - # MSRV. Not considered breaking when this has to be bumped. - # But should be mentioned in the changelog. - rust: [stable, beta, nightly, 1.64.0] - runs-on: macos-latest - steps: - - uses: actions/checkout@v2 - - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ matrix.rust }} - default: true - - - name: Build - uses: actions-rs/cargo@v1 - with: - command: build - - - name: Test - uses: actions-rs/cargo@v1 - with: - command: test From a07bd90489aa8318a45a5d62889420188827aa8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Thu, 22 Aug 2024 10:32:35 +0200 Subject: [PATCH 5/6] Set `rust-version` in Cargo.toml Good practice --- system-configuration/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/system-configuration/Cargo.toml b/system-configuration/Cargo.toml index 92cc051..ed5b95c 100644 --- a/system-configuration/Cargo.toml +++ b/system-configuration/Cargo.toml @@ -9,6 +9,7 @@ repository = "https://github.com/mullvad/system-configuration-rs" license = "MIT OR Apache-2.0" readme = "../README.md" edition = "2021" +rust-version = "1.64.0" [dependencies] core-foundation = "0.9" From 769dd0a7a4ec9faf7d4f66bed7b31a697c9cc076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Thu, 22 Aug 2024 10:35:44 +0200 Subject: [PATCH 6/6] Commit Cargo.lock --- Cargo.lock | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Cargo.lock diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..3609abf --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,48 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "libc" +version = "0.2.158" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" + +[[package]] +name = "system-configuration" +version = "0.6.0" +dependencies = [ + "bitflags", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +dependencies = [ + "core-foundation-sys", + "libc", +]