ci: Add lint job, concurrency control, caching, and timeouts #1887
Workflow file for this run
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: Rust | |
| on: | |
| push: | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: 1 | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy, rustfmt | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| - name: Clippy | |
| run: cargo clippy --all-targets -- -D warnings | |
| linux-ubuntu: | |
| needs: lint | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 45 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: System info | |
| run: | | |
| echo "=== Architecture ===" | |
| uname -a | |
| echo "=== CPU ===" | |
| lscpu | head -20 | |
| echo "=== Toolchain ===" | |
| rustc --version | |
| cargo --version | |
| cc --version || true | |
| as --version || true | |
| - name: Fetch | |
| run: cargo fetch | |
| - name: Build | |
| run: cargo build --release --verbose | |
| - name: Run tests | |
| run: cargo test --release --verbose | |
| macos-homebrew: | |
| needs: lint | |
| runs-on: macos-latest | |
| timeout-minutes: 45 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: System info | |
| run: | | |
| echo "=== Architecture ===" | |
| uname -a | |
| arch | |
| echo "=== Toolchain ===" | |
| rustc --version | |
| cargo --version | |
| cc --version || true | |
| as -version || true | |
| echo "=== Xcode ===" | |
| xcodebuild -version || true | |
| - name: Fetch | |
| run: cargo fetch | |
| - name: Build | |
| run: cargo build --release --verbose | |
| - name: Run tests | |
| run: cargo test --release --verbose | |
| - name: Run cc tests (detailed) | |
| if: failure() | |
| run: | | |
| echo "=== Re-running cc tests with more detail ===" | |
| cargo test --release -p posixutils-cc --verbose -- --nocapture --test-threads=1 2>&1 | head -500 |