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
103 changes: 76 additions & 27 deletions .github/workflows/rust.yml β†’ .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: Rust CI
name: CI

on:
pull_request:
branches: [ "master" ]
branches: [master]
push:
branches: [ "master" ]
branches: [master]
workflow_dispatch:

concurrency:
Expand All @@ -12,37 +13,45 @@ concurrency:

env:
CARGO_TERM_COLOR: always

defaults:
run:
shell: bash

jobs:
formatting_and_security:
name: Formatting and Security
formatting_and_quality:
name: Formatting and Quality Checks
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v6

- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt, clippy

- uses: Swatinem/rust-cache@v2

- name: Run cargo fmt
run: cargo fmt --all -- --check

- name: Run Clippy
run: cargo clippy --all-targets -- -D warnings
run: cargo clippy --all-targets --all-features -- -D warnings

- name: Install cargo-audit
uses: taiki-e/install-action@v2
with:
tool: cargo-audit

- name: Run Cargo Audit
run: cargo audit --ignore RUSTSEC-2023-0071
build:
name: Build and Upload Artifacts
if: github.ref == 'refs/heads/master'

test:
name: Test Suite
runs-on: ${{ matrix.os }}
needs: [formatting_and_security, test]
strategy:
fail-fast: false
matrix:
include:
- os: macos-14
Expand All @@ -53,28 +62,35 @@ jobs:
target: x86_64-pc-windows-msvc
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu

steps:
- uses: actions/checkout@v5
- name: Checkout repository
uses: actions/checkout@v6

- uses: dtolnay/rust-toolchain@nightly
- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ matrix.target }}

- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}

- name: Build
run: cargo build --release --target ${{ matrix.target }}

- name: Upload executable
uses: actions/upload-artifact@v4
- name: Install cargo-nextest
uses: taiki-e/install-action@v2
with:
name: ferrumc-${{ matrix.os }}
path: target/${{ matrix.target }}/release/ferrumc*
tool: cargo-nextest

test:
name: Run Tests
- name: Run tests
run: cargo nextest run --target ${{ matrix.target }} --all-targets --all-features -E "not kind(bench)"

build:
name: Build Binaries
runs-on: ${{ matrix.os }}
needs: [formatting_and_quality, test]
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
strategy:
fail-fast: false
matrix:
include:
- os: macos-14
Expand All @@ -85,17 +101,50 @@ jobs:
target: x86_64-pc-windows-msvc
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu

steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v6

- name: Install Rust nightly
uses: dtolnay/rust-toolchain@nightly
with:
targets: ${{ matrix.target }}

- uses: Swatinem/rust-cache@v2
- name: Install cargo-nextest
with:
key: ${{ matrix.target }}

- name: Install cross
if: matrix.cross
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest
- name: Run Tests
run: cargo nextest run --target ${{ matrix.target }} --all-targets --all-features -E "not kind(bench)"
tool: cross

- name: Build release binary
run: |
if [ "${{ matrix.cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we using cross? It's already doing all this on native runners?

else
cargo build --release --target ${{ matrix.target }}
fi

- name: Strip binary (Linux/macOS)
if: runner.os != 'Windows'
run: strip target/${{ matrix.target }}/release/ferrumc || true

- name: Prepare artifact
run: |
mkdir -p artifacts
if [ "${{ runner.os }}" = "Windows" ]; then
cp target/${{ matrix.target }}/release/ferrumc.exe artifacts/ferrumc-${{ matrix.target }}.exe
else
cp target/${{ matrix.target }}/release/ferrumc artifacts/ferrumc-${{ matrix.target }}
fi

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ferrumc-${{ matrix.target }}
path: artifacts/*
retention-days: 7
Loading
Loading