Skip to content

Commit

Permalink
chore: add Rust CI
Browse files Browse the repository at this point in the history
* validate that the rustutils crate is valid
* currently uses hardcoded CI script, but should move it all to justfile similar to many other similar crates
* add MSRV (tested with `cargo msrv find` + CI for it
* ensure rustutils crate is not published, and set version to 0.0.0 as it has no internal version
  • Loading branch information
nyurik committed Jan 24, 2025
1 parent c7b63cd commit a3b316f
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 2 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/rust-ci.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion rustutils/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion rustutils/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down

0 comments on commit a3b316f

Please sign in to comment.