From 375d83c0f44fe301361cfd7aba9435c542e7b6a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matheus=20Andr=C3=A9?= <92062874+matheusandre1@users.noreply.github.com> Date: Thu, 24 Sep 2026 00:48:50 -0300 Subject: [PATCH] fix(ci): add draft PR handling to CI workflows for compatibility and build tests (#4292) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matheus André --- .github/workflows/ci.yml | 15 +++++++++++-- .github/workflows/compatibility.yml | 12 ++++++++++ .github/workflows/pr-draft-gate.yml | 34 +++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/pr-draft-gate.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd721a1657..915060583f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,12 +9,17 @@ on: - 'pom.xml' - '.github/ci/**' - '.github/workflows/ci.yml' + - '.github/workflows/pr-draft-gate.yml' pull_request: + # ready_for_review is not a default type: without it, marking a draft ready + # would not start the run the draft skipped. + types: [opened, synchronize, reopened, ready_for_review] paths: - 'src/**' - 'pom.xml' - '.github/ci/**' - '.github/workflows/ci.yml' + - '.github/workflows/pr-draft-gate.yml' permissions: contents: read @@ -30,10 +35,15 @@ env: SHARD_TOTAL: 4 jobs: + # Drafts skip the suite to spare runners; it runs once the PR is ready for review. + draft-gate: + uses: ./.github/workflows/pr-draft-gate.yml + test: name: Build and Test (shard ${{ matrix.shard }}) runs-on: ubuntu-latest timeout-minutes: 15 + needs: draft-gate strategy: fail-fast: false matrix: @@ -125,8 +135,9 @@ jobs: name: CI summary runs-on: ubuntu-latest timeout-minutes: 10 - needs: test - if: always() + needs: [draft-gate, test] + # Without the gate check, always() would run this on a draft and fail on the skipped shards. + if: always() && needs.draft-gate.result == 'success' steps: - name: Fail if any shard failed if: needs.test.result != 'success' diff --git a/.github/workflows/compatibility.yml b/.github/workflows/compatibility.yml index 83b98120c9..8e7437814d 100644 --- a/.github/workflows/compatibility.yml +++ b/.github/workflows/compatibility.yml @@ -2,6 +2,9 @@ name: Compatibility Tests on: pull_request: + # ready_for_review is not a default type: without it, marking a draft ready + # would not start the run the draft skipped. + types: [opened, synchronize, reopened, ready_for_review] paths: - 'src/**' - 'pom.xml' @@ -18,6 +21,7 @@ on: - '.github/ci/compat-opentofu-allowlist-tf-only.txt' - '.github/ci/compat-opentofu-allowlist-otf-only.txt' - '.github/workflows/compatibility.yml' + - '.github/workflows/pr-draft-gate.yml' permissions: contents: read @@ -27,10 +31,15 @@ concurrency: cancel-in-progress: true jobs: + # Drafts skip the suite to spare runners; it runs once the PR is ready for review. + draft-gate: + uses: ./.github/workflows/pr-draft-gate.yml + docker-runner-regression: name: compat / Docker runner failure aggregation runs-on: ubuntu-24.04 timeout-minutes: 5 + needs: draft-gate steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -41,6 +50,7 @@ jobs: name: compat / aws CLI endpoint resolution runs-on: ubuntu-24.04-arm timeout-minutes: 10 + needs: draft-gate steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -119,6 +129,7 @@ jobs: name: compat / opentofu resource parity runs-on: ubuntu-24.04-arm timeout-minutes: 5 + needs: draft-gate steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -133,6 +144,7 @@ jobs: name: Build native floci image (${{ matrix.arch }}) runs-on: ${{ matrix.runner }} timeout-minutes: 30 + needs: draft-gate # Both published architectures. The native image is the only place an # arch-specific resource can go missing (snappy-java's JNI library is # registered per platform), and one arch cannot prove the other. diff --git a/.github/workflows/pr-draft-gate.yml b/.github/workflows/pr-draft-gate.yml new file mode 100644 index 0000000000..20ad48a3d1 --- /dev/null +++ b/.github/workflows/pr-draft-gate.yml @@ -0,0 +1,34 @@ +name: PR Draft Gate + +# Reusable gate for the expensive PR workflows (CI, Compatibility Tests). Callers +# make their jobs `needs:` the `gate` job: when it is skipped, every job that needs +# it is skipped too, so a draft PR spends no runner time on the heavy suites. +# +# A reusable workflow sees the caller's `github` context, so the condition below +# evaluates against the caller's event. Non-PR events (push to main) always pass. +# `closed` and `edited` are excluded as well, so a caller can widen its trigger +# types without this gate letting those events through. +# +# Callers must list `ready_for_review` in their pull_request types: it is not a +# default type, and without it marking a draft ready would not start the run the +# draft skipped. + +on: + workflow_call: + +permissions: {} + +jobs: + gate: + name: Skip draft PRs + runs-on: ubuntu-latest + timeout-minutes: 1 + if: >- + github.event_name != 'pull_request' || ( + github.event.pull_request.draft == false && + github.event.pull_request.state != 'closed' && + github.event.action != 'edited' + ) + steps: + - name: Not a draft + run: echo "Not a draft PR, running the suite."