Skip to content

Commit

Permalink
Add GitHub workflows.
Browse files Browse the repository at this point in the history
  • Loading branch information
yonas committed Aug 24, 2024
1 parent e1c76d8 commit 6a6c731
Show file tree
Hide file tree
Showing 5 changed files with 322 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/changelog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Changelog

on:
push:
tags:
- "v*.*.*"

jobs:
changelog:
name: Generate and publish changelog
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Generate a changelog
uses: orhun/git-cliff-action@v3
id: git-cliff
with:
config: cliff.toml
args: --verbose --latest --strip header
env:
OUTPUT: CHANGES.md
GITHUB_REPO: ${{ github.repository }}

- name: Polish changelog
shell: bash
run: sed -i '1,2d' CHANGES.md

- name: Upload the changelog
uses: ncipollo/release-action@v1
with:
# draft: true
allowUpdates: true
bodyFile: CHANGES.md
122 changes: 122 additions & 0 deletions .github/workflows/coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
on:
pull_request:
push:
branches:
- main

name: Coverage

jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true

- uses: Swatinem/rust-cache@v1

- name: Run cargo check
uses: actions-rs/cargo@v1
with:
command: check

test:
name: Test Suite
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [stable]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true

- uses: Swatinem/rust-cache@v1

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test

coverage:
name: Coverage
strategy:
matrix:
os: [ubuntu-latest]
rust: [stable,nightly]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
components: llvm-tools-preview

- uses: Swatinem/rust-cache@v1

- name: Download grcov
run: |
mkdir -p "${HOME}/.local/bin"
curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.19/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin"
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Run xtask coverage
uses: actions-rs/cargo@v1
with:
command: xtask
args: coverage

# - name: Upload to codecov.io
# uses: codecov/codecov-action@v4
# with:
# files: coverage/*.lcov

lints:
name: Lints
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: true

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v1

- name: Run cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
69 changes: 69 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
on:
pull_request:
push:
branches:
- main


name: Linting

jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
override: true

- uses: actions-rs/cargo@v1
with:
command: check

fmt:
name: Rustfmt and treefmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
override: true
- run: rustup component add rustfmt

- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check

- name: treefmt
run: |
sudo apt install gojq
curl -s https://api.github.com/repos/numtide/treefmt/tags | gojq -r '.[0].name' > .ver
curl -sSLo treefmt.tgz https://github.com/numtide/treefmt/releases/download/$(cat .ver)/treefmt_$(cat .ver | cut -d'v' -f2)_linux_amd64.tar.gz
tar -xvf treefmt.tgz
./treefmt
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy
override: true

- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
name: Clippy Output
27 changes: 27 additions & 0 deletions .github/workflows/release-packaging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
on:
push:
branches:
- main

name: Release Packaging

jobs:
release:
name: Release Packaging
env:
PROJECT_NAME_UNDERSCORE: test2
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: stable
override: true
- name: Release Build
run: cargo build --release
- name: 'Upload Artifact'
uses: actions/upload-artifact@v4
with:
name: ${{ env.PROJECT_NAME_UNDERSCORE }}
path: target/release/${{ env.PROJECT_NAME_UNDERSCORE }}
65 changes: 65 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
on:
pull_request:
push:
branches:
- main

name: Test with Code Coverage

jobs:
test:
name: Test
env:
PROJECT_NAME_UNDERSCORE: test2
CARGO_INCREMENTAL: 0
RUSTFLAGS: -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort
RUSTDOCFLAGS: -Cpanic=abort
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: nightly
override: true
- name: Cache dependencies
uses: actions/cache@v2
env:
cache-name: cache-dependencies
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin
~/.cargo/registry/index
~/.cargo/registry/cache
target
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}

- name: Download grcov
run: |
sudo apt install gojq
mkdir -p "${HOME}/.local/bin"
curl -s https://api.github.com/repos/mozilla/grcov/tags | gojq -r '.[0].name' > .ver
curl -sL https://github.com/mozilla/grcov/releases/download/$(cat .ver)/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin"
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Generate test result and coverage report
run: |
cargo install cargo2junit;
cargo test $CARGO_OPTIONS -- -Z unstable-options --format json | cargo2junit > results.xml;
zip -0 ccov.zip `find . \( -name "$PROJECT_NAME_UNDERSCORE*.gc*" \) -print`;
grcov ccov.zip -s . -t lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" -o lcov.info;
- name: Upload test results
uses: EnricoMi/publish-unit-test-result-action@v1
with:
check_name: Test Results
github_token: ${{ secrets.GITHUB_TOKEN }}
files: results.xml
#- name: Upload to CodeCov
# uses: codecov/codecov-action@v1
# with:
# required for private repositories:
# token: ${{ secrets.CODECOV_TOKEN }}
# files: ./lcov.info
# fail_ci_if_error: true

0 comments on commit 6a6c731

Please sign in to comment.