CI #61
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
name: CI | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
tags: | |
- v* | |
schedule: | |
- cron: '0 0 * * 0' | |
workflow_dispatch: | |
jobs: | |
format: | |
name: Check code formatting | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@984d158d699777abbaa79de23de3134e60c187fa # stable branch | |
- name: Run cargo fmt | |
run: | | |
cargo fmt --all -- --check | |
build: | |
name: Build and test | |
env: | |
CARGO: cargo | |
TARGET_FLAGS: --target ${{ matrix.target }} | |
RUST_BACKTRACE: 1 | |
timeout-minutes: 30 | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
build: | |
- linux | |
- macOS | |
- windows | |
include: | |
- build: linux | |
os: ubuntu-22.04 | |
run-tests: 'true' | |
target: x86_64-unknown-linux-gnu | |
- build: macOS | |
os: macos-12 | |
run-tests: 'true' | |
target: x86_64-apple-darwin | |
- build: windows | |
os: windows-2022 | |
run-tests: 'true' | |
target: x86_64-pc-windows-msvc | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@984d158d699777abbaa79de23de3134e60c187fa # stable branch | |
- name: Install Rust toolchain target | |
run: rustup target add ${{ matrix.target }} | |
- name: Cargo Cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/registry | |
~/.cargo/git | |
key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.toml') }} | |
restore-keys: | | |
${{ runner.os }}-${{ matrix.target }}-cargo- | |
- name: Build the library | |
run: ${{ env.CARGO }} build --release --all-targets ${{ env.TARGET_FLAGS }} | |
- name: Run tests | |
timeout-minutes: 5 | |
run: ${{ env.CARGO }} test --release ${{ env.TARGET_FLAGS }} | |
if: (runner.os == 'linux' || runner.os == 'windows') && matrix.run-tests == 'true' | |
- name: Run tests | |
timeout-minutes: 5 | |
run: sudo "PATH=$PATH" ${{ env.CARGO }} test --release ${{ env.TARGET_FLAGS }} | |
if: runner.os == 'macOS' && matrix.run-tests == 'true' | |
build-freebsd: | |
name: Build and test (freebsd-x86_64) | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 30 | |
strategy: | |
fail-fast: false | |
matrix: | |
box: | |
- fbsd_14 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Display CPU info | |
run: lscpu | |
- name: Install VM tools | |
run: | | |
sudo apt-get update -qq | |
sudo apt-get install -qq -o=Dpkg::Use-Pty=0 moreutils | |
sudo chronic apt-get install -qq -o=Dpkg::Use-Pty=0 vagrant virtualbox qemu libvirt-daemon-system | |
- name: Set up VM | |
shell: sudo bash {0} | |
run: | | |
vagrant plugin install vagrant-libvirt | |
ln -sf ci/Vagrantfile Vagrantfile | |
vagrant status | |
vagrant up --no-tty --provider libvirt ${{ matrix.box }} | |
- name: Build and test | |
shell: sudo bash {0} | |
run: vagrant ssh ${{ matrix.box }} -- bash /vagrant/ci/freebsd-build.sh | |
release: | |
name: Create draft release | |
runs-on: ubuntu-22.04 | |
if: "startsWith(github.ref, 'refs/tags/')" | |
needs: [build, build-freebsd] | |
steps: | |
- uses: marvinpinto/action-automatic-releases@919008cf3f741b179569b7a6fb4d8860689ab7f0 # v1.1.1 | |
with: | |
repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
draft: true | |
prerelease: false |