Review and release infrastructure #9
This file contains hidden or 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 | |
| # This workflow runs tests, formatting checks, and the fspec tool. | |
| # | |
| # To set up branch protection for master/main (require reviews and passing CI): | |
| # 1. Go to your repository on GitHub | |
| # 2. Navigate to Settings > Branches | |
| # 3. Click "Add branch protection rule" or edit existing rule for master/main | |
| # 4. Enable the following options: | |
| # - "Require a pull request before merging" | |
| # - Enable "Require approvals" (set to 1 or more) | |
| # - Optionally enable "Dismiss stale pull request approvals when new commits are pushed" | |
| # - "Require status checks to pass before merging" | |
| # - Select "Test Suite" as the required status check | |
| # - Optionally: "Require conversation resolution before merging" | |
| # - Optionally: "Do not allow bypassing the above settings" (prevents admins from bypassing) | |
| # 5. Click "Create" or "Save changes" | |
| # | |
| # Note: Branch protection cannot be configured via files alone - it requires | |
| # repository settings access. However, this workflow will fail if tests don't pass, | |
| # which effectively enforces the requirement. | |
| on: | |
| push: | |
| branches: [ master, main ] | |
| pull_request: | |
| branches: [ master, main ] | |
| workflow_dispatch: # Allows manual triggering from GitHub Actions UI | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| # Format check only runs on Linux (no need to run on all platforms) | |
| fmt: | |
| name: Format Check | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ${{ runner.home }}/.cargo/bin/ | |
| ${{ runner.home }}/.cargo/registry/index/ | |
| ${{ runner.home }}/.cargo/registry/cache/ | |
| ${{ runner.home }}/.cargo/git/db/ | |
| target/ | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| # Test suite runs on all platforms | |
| test: | |
| name: Test Suite (${{ matrix.os }}) | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-24.04 | |
| target: x86_64-unknown-linux-gnu | |
| - os: windows-2022 | |
| target: x86_64-pc-windows-msvc | |
| - os: macos-14 | |
| target: x86_64-apple-darwin | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ${{ runner.home }}/.cargo/bin/ | |
| ${{ runner.home }}/.cargo/registry/index/ | |
| ${{ runner.home }}/.cargo/registry/cache/ | |
| ${{ runner.home }}/.cargo/git/db/ | |
| target/ | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Run tests | |
| run: cargo test --workspace --all-features --target ${{ matrix.target }} | |
| - name: Run fspec tool | |
| run: cargo run --target ${{ matrix.target }} | |
| working-directory: ${{ github.workspace }} | |
| # Build release binaries for all platforms | |
| build: | |
| name: Build Release (${{ matrix.os }}) | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-24.04 | |
| target: x86_64-unknown-linux-gnu | |
| artifact_name: fspec-x86_64-unknown-linux-gnu | |
| binary_name: fspec | |
| - os: windows-2022 | |
| target: x86_64-pc-windows-msvc | |
| artifact_name: fspec-x86_64-pc-windows-msvc | |
| binary_name: fspec.exe | |
| - os: macos-14 | |
| target: x86_64-apple-darwin | |
| artifact_name: fspec-x86_64-apple-darwin | |
| binary_name: fspec | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ${{ runner.home }}/.cargo/bin/ | |
| ${{ runner.home }}/.cargo/registry/index/ | |
| ${{ runner.home }}/.cargo/registry/cache/ | |
| ${{ runner.home }}/.cargo/git/db/ | |
| target/ | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Build release binary | |
| run: cargo build --release --target ${{ matrix.target }} --bin fspec | |
| - name: Create artifact directory | |
| shell: bash | |
| run: | | |
| mkdir -p ${{ matrix.artifact_name }} | |
| cp target/${{ matrix.target }}/release/${{ matrix.binary_name }} ${{ matrix.artifact_name }}/ | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact_name }} | |
| path: ${{ matrix.artifact_name }}/* | |
| retention-days: 90 | |