diff --git a/.github/workflows/pr-main.yml b/.github/workflows/pr-main.yml index 3870586..9b9e0e0 100644 --- a/.github/workflows/pr-main.yml +++ b/.github/workflows/pr-main.yml @@ -33,6 +33,9 @@ jobs: - name: Checkout code uses: actions/checkout@v4 + - name: Set up Rust + uses: actions-rust-lang/setup-rust-toolchain@v1 + - name: Cache Cargo and cross uses: actions/cache@v4 with: @@ -50,13 +53,90 @@ jobs: cargo install cross fi - - name: Build - run: ${{ matrix.platform.command }} build --target ${{ matrix.platform.target }} + - name: Build stable + id: build + run: ${{ matrix.platform.command }} build --target ${{ matrix.platform.target }}; + + - name: Test stable + id: test + run: ${{ matrix.platform.command }} test --target ${{ matrix.platform.target }}; + + - name: Set up Rust beta + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: beta - - name: Test - run: ${{ matrix.platform.command }} test --target ${{ matrix.platform.target }} + - name: Build beta + id: build-beta + run: ${{ matrix.platform.command }} +beta build --target ${{ matrix.platform.target }}; + continue-on-error: true + + - name: Test beta + id: test-beta + if: ${{ steps.build-beta.outcome == 'success' }} + run: ${{ matrix.platform.command }} +beta test --target ${{ matrix.platform.target }}; + continue-on-error: true + + - name: Set up Rust nightly + if: ${{ steps.build-beta.outcome == 'success' }} + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: nightly + + - name: Build nightly + id: build-nightly + if: ${{ steps.build-beta.outcome == 'success' }} + run: ${{ matrix.platform.command }} +nightly build --target ${{ matrix.platform.target }}; + continue-on-error: true + + - name: Test nightly + id: test-nightly + if: ${{ steps.build-nightly.outcome == 'success' }} + run: ${{ matrix.platform.command }} +nightly test --target ${{ matrix.platform.target }}; + continue-on-error: true + + - name: Issue warnings for beta/ nightly fails + if: > + ${{ steps.build-beta.outcome == 'failure' || + steps.test-beta.outcome == 'failure' || + steps.build-nightly.outcome == 'failure' || + steps.test-nightly.outcome == 'failure'}} + uses: actions/github-script@v7 + with: + script: | + let body = ""; + + const beta_build_fail = ${{ steps.build-beta.outcome == 'failure' }}; + const nightly_build_fail = ${{ steps.build-nightly.outcome == 'failure' }}; + + if (beta_build_fail || nightly_build_fail) { + const failed_toolchain = beta_build_fail ? "beta" : "nightly" + body = body.concat(`🚨 🛠️ Build Failures on **${failed_toolchain}** Rust with **${{ matrix.platform.target }}** target.\n`) + } + + const beta_test_fail = ${{ steps.test-beta.outcome == 'failure' }}; + const nightly_test_fail = ${{ steps.test-nightly.outcome == 'failure' }}; + + if (beta_test_fail || nightly_test_fail) { + let failed_toolchain = beta_build_fail ? "beta" : "" + + if (nightly_test_fail) { + failed_toolchain = failed_toolchain.concat(" and nightly") + } + + body = body.concat(`🚨 ❌ Test Failures on **${failed_toolchain}** Rust with **${{ matrix.platform.target }}** target.`) + } + + github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + body: body + }); format: + needs: build-and-test + runs-on: ubuntu-latest steps: @@ -73,6 +153,8 @@ jobs: run: cargo +nightly fmt --check clippy: + needs: build-and-test + runs-on: ubuntu-latest steps: