-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bootstrap the project CI/CD pipeline
- Loading branch information
Showing
2 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Build | ||
on: [push] | ||
|
||
jobs: | ||
rustfmt: | ||
runs-on: ubuntu-latest | ||
env: | ||
CARGO_TERM_COLOR: always | ||
NUM_JOBS: 2 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
profile: minimal | ||
override: true | ||
components: rustfmt, clippy | ||
- uses: Swatinem/rust-cache@v2 | ||
- uses: actions-rs/cargo@v1 | ||
with: | ||
command: fmt | ||
args: --check | ||
|
||
# Run the build, clippy, and test commands in the same job in serial so they can share the same | ||
# build directory, and hopefully run faster. | ||
build-lint-test: | ||
runs-on: ubuntu-latest | ||
env: | ||
RUSTFLAGS: -Dwarnings | ||
CARGO_TERM_COLOR: always | ||
NUM_JOBS: 2 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
profile: minimal | ||
override: true | ||
components: rustfmt, clippy | ||
- uses: Swatinem/rust-cache@v2 | ||
- uses: taiki-e/install-action@v2 | ||
with: | ||
tool: cargo-tarpaulin | ||
|
||
- name: Build | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: build | ||
args: --release --all-targets --all-features | ||
|
||
- name: Lint | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: clippy | ||
args: --release --all-targets --all-features | ||
|
||
- name: Test | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: tarpaulin | ||
args: --release --all-features --out xml | ||
|
||
# TODO: Code coverage badge on README | ||
|
||
- name: Get Pull Request Number | ||
id: pr | ||
run: echo "pull_request_number=$(gh pr view --json number -q .number || echo "")" >> $GITHUB_OUTPUT | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: PR coverage report | ||
uses: 5monkeys/cobertura-action@v13 | ||
with: | ||
path: 'cobertura.xml' | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
pull_request_number: ${{ steps.pr.outputs.pull_request_number }} | ||
only_changed_files: true | ||
show_line: true | ||
show_branch: true | ||
skip_covered: false | ||
# If we want to enforce a minimum coverage percentage, this is how. | ||
minimum_coverage: 0 | ||
fail_below_threshold: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Build | ||
on: [push] | ||
|
||
jobs: | ||
rustdoc: | ||
runs-on: ubuntu-latest | ||
env: | ||
RUSTDOCFLAGS: -Dwarnings | ||
CARGO_TERM_COLOR: always | ||
NUM_JOBS: 2 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: stable | ||
profile: minimal | ||
override: true | ||
- uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Build documentation | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
command: doc | ||
args: --no-deps | ||
|
||
- name: Prepare HTML | ||
run: | | ||
mkdir -p ./public/ | ||
# The ./target/doc/ directory has assets one level above the index.html, but it | ||
# requires relative links, so we redirect to it from one level higher. | ||
echo '<meta http-equiv="refresh" content="0; url=ag_iso_stack">' >./public/index.html | ||
cp -r target/doc/* ./public/ | ||
# TODO: Replace with docs.rs once crate publishing is figured out | ||
- name: Deploy documentation | ||
uses: peaceiris/actions-gh-pages@v3 | ||
# if: github.ref == 'refs/heads/main' | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./public/ | ||
force_orphan: true |