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 d646dfd..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,85 +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: - 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 - - 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: - - 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: - # 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 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 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 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", +] 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"