Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CI

CI #104

Workflow file for this run

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@v4
- 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-24.04
run-tests: 'true'
target: x86_64-unknown-linux-gnu
- build: macOS
os: macos-14
run-tests: 'true'
target: aarch64-apple-darwin
- build: windows
os: windows-2022
run-tests: 'true'
target: x86_64-pc-windows-msvc
steps:
- name: Checkout repository
uses: actions/checkout@v4
- 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 (FreeBSD)
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@4305c38b25d97ef35a8ad1f985ccf2d2242004f2 # stable branch
- uses: Swatinem/[email protected]
- name: Cache cross binary
id: cache-cross
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/cross
key: ${{ runner.os }}-cross-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cross-
- name: Install cross
if: steps.cache-cross.outputs.cache-hit != 'true'
run: cargo install cross --git https://github.com/cross-rs/cross --rev 51f46f296253d8122c927c5bb933e3c4f27cc317
- name: Cargo Cache
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Cross-compile spytools
run: cross test --release --no-run --target x86_64-unknown-freebsd
- name: Launch Firecracker VM
uses: acj/[email protected]
with:
verbose: false
pre-run: |
rm -rf .cargo
ln -s $HOME/.cargo .cargo
include_path="$(mktemp)"
cat <<EOF > $include_path
target
target/x86_64-unknown-freebsd
target/x86_64-unknown-freebsd/release
target/x86_64-unknown-freebsd/release/deps
target/x86_64-unknown-freebsd/release/deps/spytools-*
EOF
rsync -r -e "ssh" \
--relative \
--copy-links \
--include-from "$include_path" \
--exclude "*" \
. firecracker:
rm -f "$exclude_path"
run-in-vm: |
mkdir -p /home/runner
ln -s $(pwd)/.cargo /home/runner/.cargo
failed=0
for testbin in $(find target/x86_64-unknown-freebsd/release/deps -type f -perm -u+x ! -name "*.d" -print); do
if ! $testbin; then
failed=1
fi
done
if [ $failed -ne 0 ]; then
exit 1
fi
post-run: ""
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