diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c012e83..c851acbb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,14 +2,19 @@ name: ci on: push: + branches: ["main"] + tags: ["v*"] pull_request: - create: + branches: ["main"] schedule: - cron: "30 4 * * *" jobs: tests: + permissions: + pull-requests: write runs-on: ubuntu-latest + continue-on-error: ${{ matrix.optional }} strategy: fail-fast: false matrix: @@ -20,6 +25,11 @@ jobs: rack: - "~> 2.0" - "~> 3.0" + optional: [false] + include: + - ruby: "jruby" + rack: "~> 3.0" + optional: true name: tests (Ruby ${{ matrix.ruby }}, Rack ${{ matrix.rack }}) steps: - uses: actions/checkout@v1 @@ -33,9 +43,27 @@ jobs: env: RACK_VERSION_CONSTRAINT: ${{matrix.rack}} - name: Run all tests - run: script/ci + id: test + run: | + status=0 + script/ci || status=$? + if [ ${status} -ne 0 ] && [ "${{ matrix.optional }}" == "true" ]; then + echo "::warning::Optional matrix job failed." + echo "optional_fail=true" >> "${GITHUB_OUTPUT}" + echo "optional_fail_status=${status}" >> "${GITHUB_OUTPUT}" + exit 0 # Ignore error here to keep the green checkmark going + fi + exit ${status} env: RACK_VERSION_CONSTRAINT: ${{matrix.rack}} + - name: Add comment for optional failures + uses: thollander/actions-comment-pull-request@v3 + if: ${{ matrix.optional }} + with: + comment-tag: "${{ matrix.ruby }}-${{ matrix.rack }}-optional-notice" + message: | + **⚠️ Optional job failed:** Ruby ${{ matrix.ruby }} / Rack ${{ matrix.rack }} + mode: ${{ steps.test.outputs.optional_fail == 'true' && 'upsert' || 'delete' }} workflow-keepalive: if: github.event_name == 'schedule'