Refactor the CI system #11
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: CI | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| workflow_dispatch: | |
| concurrency: | |
| cancel-in-progress: true | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| format: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - run: .github/ci/format.sh | |
| check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| shared-key: ci-check | |
| - run: .github/ci/check.sh | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| shared-key: ci-test | |
| - run: .github/ci/test.sh | |
| # Discover buildable examples for the matrix | |
| discover: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| stable: ${{ steps.discover.outputs.stable }} | |
| esp: ${{ steps.discover.outputs.esp }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - id: discover | |
| run: .github/ci/discover.sh | |
| # Build each stable-toolchain example in parallel | |
| build: | |
| needs: discover | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| # Cap parallelism so format/check/test/bloat/build-esp aren't starved | |
| # of runner slots (public repos get 20 concurrent jobs). | |
| max-parallel: 15 | |
| matrix: | |
| include: ${{ fromJson(needs.discover.outputs.stable) }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| shared-key: ci-build-${{ matrix.target }} | |
| - name: Install target and tools | |
| run: | | |
| rustup target add ${{ matrix.target }} | |
| cargo install flip-link 2>/dev/null || true | |
| - name: Build | |
| working-directory: ${{ matrix.dir }} | |
| run: cargo build --release | |
| # Build ESP/xtensa examples (separate toolchain) | |
| build-esp: | |
| needs: discover | |
| if: fromJson(needs.discover.outputs.esp)[0] != null | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| shared-key: ci-build-esp | |
| - run: .github/ci/build.sh | |
| bloat: | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| shared-key: ci-bloat | |
| - run: .github/ci/bloat.sh |