fix(ci): add draft PR handling to CI workflows for compatibility and build tests (#4292)

Signed-off-by: Matheus André <matheusandr2@gmail.com>
This commit is contained in:
Matheus André authored and GitHub committed 2026-09-23 22:48:50 -05:00
1 parent 94fc4c45bb
commit 375d83c0f4
3 files changed
+59 -2

No files matched your search

+13 -2
View File
@@ -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'
+12
View File
@@ -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.
+34
View File
@@ -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."