diff --git a/.github/workflows/rust-ci.yaml b/.github/workflows/rust-ci.yaml new file mode 100644 index 00000000000..f56d6535aa9 --- /dev/null +++ b/.github/workflows/rust-ci.yaml @@ -0,0 +1,79 @@ +name: rust-ci + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +defaults: + run: + shell: bash + working-directory: rustutils/ + +jobs: + test: + name: Rust tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' + - name: Test rustutils + run: | + # Eventually this script should be moved to a justfile as a "ci-test" recipe + # rust-info: + rustc --version + cargo --version + # + # Test code formatting + # test-fmt: + cargo fmt --all -- --check + # + # Run cargo clippy + # clippy: + cargo clippy --workspace --all-targets -- -D warnings + # + # Quick compile + # check: + RUSTFLAGS='-D warnings' cargo check --workspace --all-targets + # + # Run all tests + # test: + cargo test --workspace --all-targets + # + # Test documentation + # test-doc: + RUSTDOCFLAGS="-D warnings" cargo doc --no-deps + + msrv: + name: Rust tests MSRV + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' + - name: Read crate metadata + id: metadata + run: echo "rust-version=$(sed -ne 's/rust-version *= *\"\(.*\)\"/\1/p' Cargo.toml)" >> $GITHUB_OUTPUT + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + toolchain: ${{ steps.metadata.outputs.rust-version }} + components: rustfmt + - name: Test rustutils + working-directory: rustutils/ + run: | + # Eventually this script should be moved to a justfile as a "ci-test-msrv" recipe + # rust-info: + rustc --version + cargo --version + # + # Quick compile + # check: + RUSTFLAGS='-D warnings' cargo check --workspace --all-targets + # + # Run all tests + # test: + cargo test --workspace --all-targets diff --git a/rustutils/Cargo.lock b/rustutils/Cargo.lock index 16003c0398f..8838098dd5a 100644 --- a/rustutils/Cargo.lock +++ b/rustutils/Cargo.lock @@ -132,7 +132,7 @@ checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" [[package]] name = "rustutils" -version = "0.1.0" +version = "0.0.0" dependencies = [ "csscolorparser", "cxx", diff --git a/rustutils/Cargo.toml b/rustutils/Cargo.toml index 8d98a0d03c4..d910a8af0ae 100644 --- a/rustutils/Cargo.toml +++ b/rustutils/Cargo.toml @@ -1,11 +1,13 @@ [package] name = "rustutils" -version = "0.1.0" +version = "0.0.0" +publish = false # This crate is not intended to be published on crates.io authors = ["MapLibre contributors"] description = "Core Rust utilities for MapLibre Native" edition = "2021" license = "BSD-2-Clause" repository = "https://github.com/maplibre/maplibre-native" +rust-version = "1.78.0" [lib] crate-type = ["staticlib"]