Skip to content

Commit

Permalink
chore: Add a more capable CI workflow
Browse files Browse the repository at this point in the history
This is mostly copied from the Granddave/timecalc-rs project without the
docs building which is not needed for this project.
  • Loading branch information
Granddave committed May 21, 2024
1 parent cd39c0c commit 8d0bcb8
Showing 1 changed file with 76 additions and 24 deletions.
100 changes: 76 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,92 @@
---
name: ci
name: Continious integration

on:
push:
pull_request:
paths-ignore:
- "**/*.md"
push:
branches:
- "master"
- "renovate/**"
paths-ignore:
- "**/*.md"
merge_group:
types:
- checks_requested

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: -D warnings
RUSTDOCFLAGS: -D warnings

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
build:
strategy:
matrix:
toolchain:
- stable
- beta
fmt:
name: Rustfmt
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install Rust
uses: actions-rs/toolchain@v1
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
components: rustfmt, clippy

- name: Format
toolchain: stable
components: rustfmt
- name: Run Cargo Fmt
run: cargo fmt --all -- --check

- name: Build
run: cargo build --verbose
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy
- name: Get build cache
uses: Swatinem/rust-cache@v2
- name: Run clippy
run: cargo clippy --all-targets -- -D warnings

- name: Run tests
run: cargo test
test:
name: Test
runs-on: ${{ matrix.job.os }}
strategy:
matrix:
job:
- os: macos-latest
- os: ubuntu-latest
- os: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Get build cache
uses: Swatinem/rust-cache@v2
- name: Run Cargo Test
run: cargo test -r --all-targets --workspace

- name: Run clippy
run: cargo clippy -- -D warnings
result:
name: Result (CI)
runs-on: ubuntu-latest
needs:
- fmt
- clippy
- test
steps:
- name: Mark the job as successful
run: exit 0
if: "success()"
- name: Mark the job as unsuccessful
run: exit 1
if: "!success()"

0 comments on commit 8d0bcb8

Please sign in to comment.