Skip to content

Commit

Permalink
Add CI Workflows (#218)
Browse files Browse the repository at this point in the history
This PR adds the following workflows:
- Clippy # checks for linting issues
- Hakari # ensures that all crates use the workspace-hack
- Fmt # checks for styling issues
- Test # runs all our unit tests and uploads a coverage report to codecov
  • Loading branch information
TroyKomodo authored Dec 5, 2024
1 parent 03c9934 commit f7814e6
Show file tree
Hide file tree
Showing 51 changed files with 1,178 additions and 609 deletions.
27 changes: 27 additions & 0 deletions .config/hakari.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This file contains settings for `cargo hakari`.
# See https://docs.rs/cargo-hakari/latest/cargo_hakari/config for a full list of options.

hakari-package = "scuffle-workspace-hack"

# Format version for hakari's output. Version 4 requires cargo-hakari 0.9.22 or above.
dep-format-version = "4"

workspace-hack-line-style = "workspace-dotted"

# Setting workspace.resolver = "2" in the root Cargo.toml is HIGHLY recommended.
# Hakari works much better with the new feature resolver.
# For more about the new feature resolver, see:
# https://blog.rust-lang.org/2021/03/25/Rust-1.51.0.html#cargos-new-feature-resolver
resolver = "2"

# Add triples corresponding to platforms commonly used by developers here.
# https://doc.rust-lang.org/rustc/platform-support.html
platforms = [
"x86_64-unknown-linux-gnu",
"x86_64-apple-darwin",
# "aarch64-apple-darwin",
# "x86_64-pc-windows-msvc",
]

# Write out exact versions rather than a semver range. (Defaults to false.)
# exact-versions = true
2 changes: 2 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[profile.ci.junit]
path = "junit.xml"
156 changes: 156 additions & 0 deletions .github/workflows/cargo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: cargo

on:
push:
branches:
- main
pull_request: {}

jobs:
pre-job:
runs-on: ubuntu-24.04
permissions:
actions: write
contents: read
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
concurrent_skipping: "never"
skip_after_successful_duplicate: "true"
paths_ignore: '["**/README.md", "**/docs/**"]'
do_not_skip: '["pull_request", "workflow_dispatch", "schedule"]'

clippy:
name: Clippy
runs-on: ubuntu-24.04
needs: pre-job
if: ${{ needs.pre-job.outputs.should_skip != 'true' }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: clang curl pkg-config xz-utils libxv-dev ninja-build meson nasm protobuf-compiler

- uses: dtolnay/rust-toolchain@stable
id: setup-rust
with:
toolchain: nightly
components: clippy

- uses: Swatinem/rust-cache@v2
with:
prefix-key: "v0-rust-${{ steps.setup-rust.outputs.cachekey }}"
key: clippy

- uses: cargo-bins/cargo-binstall@main

- uses: taiki-e/install-action@v2
with:
tool: just

- name: Make sure code is linted
run: just ci clippy

fmt:
name: Fmt
runs-on: ubuntu-24.04
needs: pre-job
if: ${{ needs.pre-job.outputs.should_skip != 'true' }}
permissions:
checks: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- uses: dtolnay/rust-toolchain@stable
id: setup-rust
with:
toolchain: nightly
components: rustfmt

- uses: cargo-bins/cargo-binstall@main

- uses: taiki-e/install-action@v2
with:
tool: just

- name: Make sure code is formatted
run: just ci fmt

hakari:
name: Hakari
runs-on: ubuntu-24.04
needs: pre-job
if: ${{ needs.pre-job.outputs.should_skip != 'true' }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- uses: dtolnay/rust-toolchain@stable
id: setup-rust
with:
toolchain: nightly

- uses: cargo-bins/cargo-binstall@main

- uses: taiki-e/install-action@v2
with:
tool: cargo-hakari,just

- name: Make sure Hakari is up-to-date
run: just ci hakari

test:
name: Test
runs-on: ubuntu-24.04
needs: pre-job
if: ${{ needs.pre-job.outputs.should_skip != 'true' }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: clang curl pkg-config xz-utils libxv-dev ninja-build meson nasm protobuf-compiler

- uses: dtolnay/rust-toolchain@stable
id: setup-rust
with:
toolchain: nightly
components: llvm-tools-preview

- uses: Swatinem/rust-cache@v2
with:
prefix-key: "v0-rust-${{ steps.setup-rust.outputs.cachekey }}"
key: test

- uses: cargo-bins/cargo-binstall@main

- uses: taiki-e/install-action@v2
with:
tool: cargo-nextest,cargo-llvm-cov,just

- run: just ci test

- uses: codecov/codecov-action@v5
with:
fail_ci_if_error: true
files: ./lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
files: ./target/nextest/ci/junit.xml
token: ${{ secrets.CODECOV_TOKEN }}
Loading

0 comments on commit f7814e6

Please sign in to comment.