Skip to content

Commit

Permalink
ci: improve the CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Mcdostone committed Feb 5, 2025
1 parent f7f426f commit e64d036
Show file tree
Hide file tree
Showing 13 changed files with 1,163 additions and 94 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Actionlint

on:
workflow_dispatch:
push:
paths:
- .github/workflows/**

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
actionlint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: actionlint
uses: raven-actions/[email protected]
139 changes: 103 additions & 36 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
name: Build

on:
schedule:
- cron: "0 0 1 * *"
push:
paths-ignore:
- changelog
branches-ignore:
- main
pull_request:
branches:
- main
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings"
MINIMUM_SUPPORTED_RUST_VERSION: 1.65.0
RUSTDOCFLAGS: '--deny warnings'
MINIMUM_SUPPORTED_RUST_VERSION: 1.80.1

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Run cargo check
run: cargo check --all-features --locked --release --all
env:
CARGO_NET_GIT_FETCH_WITH_CLI: true

build:
name: Build
name: Build w/o features
needs: check
runs-on: ubuntu-latest
strategy:
Expand All @@ -39,68 +46,98 @@ jobs:
- stable
- beta
- nightly
- 1.65.0
features:
- ''
include:
- rust: stable
features: '--all-features'
- rust: stable
features: '--no-default-features'
- rust: stable
features: '--features "display"'
- rust: stable
features: '--features "hash"'
- rust: stable
features: '--features "serialize"'
- rust: stable
features: '--features "deserialize"'
- rust: nightly
features: '--all-features'
- rust: nightly
features: '--no-default-features'
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
- uses: Swatinem/rust-cache@v2
- name: Run cargo build
run: cargo build ${{ matrix.features }}
run: cargo build

build-for-targets:
name: Build for targets
needs: check
runs-on: ${{ matrix.platforms.os }}
continue-on-error: true
strategy:
matrix:
platforms:
- os: macOS-latest
target: aarch64-apple-darwin
features: ""
- os: macos-latest-large
target: x86_64-apple-darwin
features: ""
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
features: ""
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
features: "--no-default-features"
- os: windows-latest
target: x86_64-pc-windows-gnu
features: "--no-default-features"
- os: windows-latest
target: x86_64-pc-windows-msvc
features: "--no-default-features"

steps:
- uses: actions/checkout@v4
- uses: houseabsolute/actions-rust-cross@v1
# if: (github.event.pull_request.base.ref == 'main' && matrix.platforms.os == 'macos-latest-large') == false
with:
target: ${{ matrix.platforms.target }}
args: "--locked ${{ matrix.platforms.features }}"
env:
KRB5_CV_ATTR_CONSTRUCTOR_DESTRUCTOR: yes
AC_CV_FUNC_REGCOMP: yes
AC_CV_PRINTF_POSITIONAL: yes

clippy:
needs: check
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: clippy
- uses: Swatinem/rust-cache@v2
- name: Run cargo clippy
run: cargo clippy --all-targets --all-features -- --deny warnings

fmt:
format:
needs: check
name: Fmt
name: Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: rustfmt
- uses: Swatinem/rust-cache@v2
- name: Run cargo fmt
run: cargo fmt --all -- --check

unused-dependencies:
needs: check
name: Unused dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- uses: bnjbvr/cargo-machete@main

code-coverage:
name: Code coverage
needs: check
name: Unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
Expand All @@ -112,16 +149,46 @@ jobs:
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
CI: "true"

doc:
needs: check
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Build documentation
run: cargo doc --no-deps --document-private-items --verbose
run: cargo doc --no-deps --document-private-items --verbose

lychee:
name: Lychee
runs-on: ubuntu-latest
needs: [check]
steps:
- uses: actions/checkout@v4
- uses: lycheeverse/lychee-action@v2
name: Link Checker

typos:
name: Typos
runs-on: ubuntu-latest
needs: [check]
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4
- name: Install typos-cli
run: cargo install typos-cli
- name: Run typos-cli
run: typos --exclude ./benches/*

cargo-deny:
name: Cargo deny
runs-on: ubuntu-latest
needs: [check]
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v2
68 changes: 68 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Changelog

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings"
RUSTDOCFLAGS: '--deny warnings'

permissions:
id-token: write
packages: write
contents: write
pull-requests: write

on:
workflow_dispatch:
workflow_call:

jobs:
changelog:
name: Create changelog
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-tags: 'true'
fetch-depth: 0
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- id: release
run: echo "version=v$(cargo pkgid --manifest-path crates/bin/Cargo.toml | cut -d '@' -f2)" >> "$GITHUB_OUTPUT"
- name: Install git-cliff
run: cargo install git-cliff
- name: Generate a changelog
run: |
if [ -f CHANGELOG.md ]; then
git-cliff --config github --prepend CHANGELOG.md --latest
else
git-cliff --config github --output CHANGELOG.md
fi
env:
OUTPUT: CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit changelog
run: |
git checkout -b "changelog/${{ steps.release.outputs.version }}"
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
set +e
git add CHANGELOG.md
git commit -m "chore: Update changelog"
git push origin "changelog/${{ steps.release.outputs.version }}" --force
- name: Check out repository
uses: actions/checkout@v4
with:
ref: "changelog/${{ steps.release.outputs.version }}"
- name: Create pull request for changelog
run: |
alreadyExists=$(gh pr list --json headRefName | jq '.[] | select(.headRefName == "changelog/${{ steps.release.outputs.version }}") | any')
if [[ "$alreadyExists" == "" ]]; then
branch=$(git branch --show-current)
gh pr create --head "$branch" --title "Changelog for ${{ steps.release.outputs.version }}" --body "This PR updates the changelog for version ${{ steps.release.outputs.version }}."
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39 changes: 39 additions & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Code coverage

on:
pull_request:
branches:
- main
paths-ignore:
- CHANGELOG.md
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings"
RUSTDOCFLAGS: '--deny warnings'
MINIMUM_SUPPORTED_RUST_VERSION: 1.80.1

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
code-coverage:
name: Code coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin
- name: Run cargo tarpaulin
run: cargo tarpaulin --all-features --out Xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Loading

0 comments on commit e64d036

Please sign in to comment.