From 1648a8f5fe1ace309277a25dd7c1b5e8f2a9f559 Mon Sep 17 00:00:00 2001 From: Chris Beck Date: Sat, 12 Oct 2024 14:03:02 -0600 Subject: [PATCH] add github actions CI --- .github/actions/check-dirty-git/action.yml | 17 ++++++ .github/workflows/ci-rust.yml | 65 ++++++++++++++++++++++ src/traits.rs | 2 - 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 .github/actions/check-dirty-git/action.yml create mode 100644 .github/workflows/ci-rust.yml diff --git a/.github/actions/check-dirty-git/action.yml b/.github/actions/check-dirty-git/action.yml new file mode 100644 index 0000000..3959a79 --- /dev/null +++ b/.github/actions/check-dirty-git/action.yml @@ -0,0 +1,17 @@ +name: Check dirty git +description: Check the git status of the current directory, and raise an error if there are uncommitted changes. + +runs: + using: composite + steps: + - name: Checking dirty git + shell: bash + run: | + # Workaround for https://github.com/actions/checkout/issues/766 + git config --global --add safe.directory "$GITHUB_WORKSPACE" + + if [[ -n $(git status --porcelain) ]]; then + echo "repo is dirty" + git status + exit 1 + fi diff --git a/.github/workflows/ci-rust.yml b/.github/workflows/ci-rust.yml new file mode 100644 index 0000000..c4cbcd1 --- /dev/null +++ b/.github/workflows/ci-rust.yml @@ -0,0 +1,65 @@ +name: Continuous Integration (rust) + +on: + push: + branches: [ "develop" ] + # See docu here: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-and-excluding-branches + # it seems pretty similar to .gitignore + paths: + - '**' + - '!**.md' + pull_request: + paths: + - '**' + - '!**.md' + +env: + CARGO_TERM_COLOR: always + RUST_BACKTRACE: full + +jobs: + # builds and tests rust code, with --deny warnings. tests for dirty git + build-and-test-rust: + runs-on: ubuntu-latest + + env: + RUSTFLAGS: --deny warnings + + steps: + - uses: actions/checkout@v4 + - name: Rustup update + run: rustup update + - name: Show cargo version + run: cargo --version + - name: rust build caching + uses: Swatinem/rust-cache@v2 + with: + workspaces: . -> target + save-if: ${{ github.ref == 'refs/heads/develop' }} + - name: Build Rust + run: cargo check --verbose --locked + - name: Test Rust + run: cargo test --all --verbose --locked + - name: Check dirty git + uses: ./.github/actions/check-dirty-git + + # lints and checks formatting of rust code + lint-rust: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Rustup install nightly & update + run: rustup toolchain add nightly && rustup component add --toolchain nightly rustfmt && rustup update + - name: Show cargo version + run: cargo --version + - name: rust build caching + uses: Swatinem/rust-cache@v2 + with: + key: lint + workspaces: . -> target + save-if: ${{ github.ref == 'refs/heads/develop' }} + - name: Format + run: cargo +nightly fmt -- --check + - name: Clippy + run: cargo clippy --all --all-features -- -D warnings diff --git a/src/traits.rs b/src/traits.rs index ddd0c88..43f9413 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -9,7 +9,6 @@ use std::ffi::OsString; /// their config structure in `main()`. /// /// Hand-written implementations of this trait are not supported. -/// #[doc = include_str!("../REFERENCE_derive_conf.md")] pub trait Conf: Sized { /// Parse self from the process CLI args and environment, and exit the program with a help @@ -153,7 +152,6 @@ pub trait Conf: Sized { /// the `#[conf(subcommands)]` attribute. /// /// Hand-written implementations of this trait are not supported. -/// #[doc = include_str!("../REFERENCE_derive_subcommands.md")] pub trait Subcommands: Sized { // Get the subcommands associated to this enum.