From 77f380563f8bb1bad84c19655e702af5df44ec84 Mon Sep 17 00:00:00 2001 From: Jorge Hermo Date: Mon, 21 Oct 2024 17:59:34 +0200 Subject: [PATCH] chore: Add CI workflows --- .github/workflows/rust.yml | 58 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/rust.yml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 0000000..7023ae3 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,58 @@ +# This workflow runs whenever a PR is opened or updated, or a commit is pushed to main. It runs +# several checks: +# - fmt: checks that the code is formatted according to rustfmt +# - clippy: checks that the code does not contain any clippy warnin +# - test: runs the tests + +# This configuration allows maintainers of this repo to create a branch and pull request based on +# the new branch. Restricting the push trigger to the main branch ensures that the PR only gets +# built once. +on: + push: + branches: [master] + pull_request: + paths: + - "src/**" + - "build.rs" + - "Cargo.toml" + - "Cargo.lock" + - ".github/workflows/rust.yml" +# If new code is pushed to a PR branch, then cancel in progress workflows for that PR. Ensures that +# we don't waste CI time, and returns results quicker https://github.com/jonhoo/rust-ci-conf/pull/5 +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true +name: rust +jobs: + fmt: + runs-on: ubuntu-latest + name: format + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + - name: Run rustfmt + run: cargo fmt --check + clippy: + runs-on: ubuntu-latest + name: clippy + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + - name: Run clippy + run: cargo clippy --tests --locked -- -Dwarnings + test: + runs-on: ubuntu-latest + name: test + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + - name: Run tests + run: cargo test + build: + runs-on: ubuntu-latest + name: build + steps: + - uses: actions/checkout@v4 + - uses: Swatinem/rust-cache@v2 + - name: Run release build + run: cargo build --release