Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 100 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full

jobs:
format:
Expand Down Expand Up @@ -41,13 +42,29 @@ jobs:
fi

test:
name: Test
runs-on: ubuntu-latest
name: Test (${{ matrix.rust }} on ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust: [stable, 1.70.0, nightly]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
uses: dtolnay/rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true

- name: Cache dependencies
uses: actions/cache@v3
Expand All @@ -56,16 +73,19 @@ jobs:
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
~/.cargo/git/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-cargo-${{ matrix.rust }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-${{ matrix.rust }}-
${{ runner.os }}-cargo-

- name: Build
run: cargo build --verbose

- name: Run tests
run: cargo test --verbose

lint:
name: Lint
runs-on: ubuntu-latest
Expand All @@ -76,6 +96,78 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
components: clippy

- name: Run clippy
run: cargo clippy
run: cargo clippy -- -D warnings

audit:
name: Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Install cargo-audit
run: |
if ! command -v cargo-audit &> /dev/null; then
cargo install cargo-audit
fi

- name: Run cargo audit
run: cargo audit --deny warnings

coverage:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools-preview
override: true

- name: Install tarpaulin
run: |
if ! command -v cargo-tarpaulin &> /dev/null; then
cargo install cargo-tarpaulin
fi

- name: Run coverage
run: |
mkdir -p target/coverage
cargo tarpaulin --out Lcov --output-dir target/coverage

- name: Upload to codecov
uses: codecov/codecov-action@v3
with:
file: target/coverage/lcov.info
fail_gi_if_error: false
verbose: true

docs:
name: Build Docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rust-docs

- name: Build documentation
run: |
cargo doc --no-deps --document-private-items --no-deps
touch target/doc/.nojekyll

- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: target/doc
branch: gh-pages
clean: true
78 changes: 78 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Release

on:
push:
tags:
- 'v*' # Push events matching v1.0, v20.15.10, etc.

jobs:
build:
name: Create Release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
ext: ''
- os: macos-latest
target: x86_64-apple-darwin
ext: ''
- os: windows-latest
target: x86_64-pc-windows-msvc
ext: '.exe'

steps:
- uses: actions/checkout@v4

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

- name: Build
run: |
cargo build --release --target ${{ matrix.target }}
mkdir -p release
cp target/${{ matrix.target }}/release/polytorus${{ matrix.ext }} release/

- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: polytorus-${{ matrix.target }}
path: |
release/polytorus${{ matrix.ext }}

publish:
name: Publish Release
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download all build artifacts
uses: actions/download-artifact@v3
with:
path: artifacts

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref_name }}
draft: false
prerelease: false

- name: Upload Release Assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifacts/polytorus-*/polytorus*
asset_name: polytorus-${{ github.ref_name }}-${{ matrix.target }}${{ matrix.ext }}
Loading