Merge pull request #45 from Project-Fungus/disable-min-matches-by-def… #117
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: Rust | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
workflow_dispatch: | |
inputs: | |
release: | |
description: 'Build for release?' | |
required: true | |
default: false | |
type: boolean | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build | |
run: cargo build | |
- name: Run tests | |
run: cargo test | |
- name: Lint | |
run: cargo clippy -- -Dclippy::complexity -Dclippy::perf -Dclippy::suspicious -Dclippy::style | |
- name: Format | |
run: cargo fmt --check | |
# Based on the release workflow for hyperfine: | |
# https://github.com/sharkdp/hyperfine/blob/24a0d5da1bff11567bbf307315d11cb0e10733ec/.github/workflows/CICD.yml | |
build_release: | |
if: ${{ inputs.release }} | |
needs: test | |
runs-on: ${{ matrix.job.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
job: | |
- { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } | |
- { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true } | |
- { target: arm-unknown-linux-musleabihf, os: ubuntu-20.04, use-cross: true } | |
- { target: i686-pc-windows-msvc , os: windows-2019 } | |
- { target: i686-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } | |
- { target: i686-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } | |
- { target: x86_64-apple-darwin , os: macos-12 } | |
- { target: x86_64-pc-windows-msvc , os: windows-2019 } | |
- { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true } | |
- { target: x86_64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true } | |
env: | |
BUILD_CMD: cargo | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v4 | |
- name: Install prerequisites | |
shell: bash | |
run: | | |
case ${{ matrix.job.target }} in | |
arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;; | |
aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;; | |
esac | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.job.target }} | |
- name: Install cross | |
if: matrix.job.use-cross | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cross | |
- name: Overwrite build command env variable | |
if: matrix.job.use-cross | |
shell: bash | |
run: echo "BUILD_CMD=cross" >> $GITHUB_ENV | |
- name: Show version information (Rust, cargo, GCC) | |
shell: bash | |
run: | | |
gcc --version || true | |
rustup -V | |
rustup toolchain list | |
rustup default | |
cargo -V | |
rustc -V | |
- name: Build | |
shell: bash | |
run: $BUILD_CMD build --locked --release --target=${{ matrix.job.target }} | |
- name: Set binary name & path | |
id: bin | |
shell: bash | |
run: | | |
# Figure out suffix of binary | |
EXE_suffix="" | |
case ${{ matrix.job.target }} in | |
*-pc-windows-*) EXE_suffix=".exe" ;; | |
esac; | |
# Setup paths | |
BIN_NAME="fungus${EXE_suffix}" | |
BIN_PATH="target/${{ matrix.job.target }}/release/${BIN_NAME}" | |
# Let subsequent steps know where to find the binary | |
echo "BIN_PATH=${BIN_PATH}" >> $GITHUB_OUTPUT | |
echo "BIN_NAME=${BIN_NAME}" >> $GITHUB_OUTPUT | |
- name: Upload binary | |
uses: actions/upload-artifact@v4 | |
with: | |
name: fungus-${{ matrix.job.target }} | |
path: ${{ steps.bin.outputs.BIN_PATH }} | |
if-no-files-found: error |