Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/stacked-pr-dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Stacked PR Dispatch

# Companion to test-on-pr.yml and unit-tests.yml for the stacked
# flux-pumping PR chains. Those workflows keep their pull_request types
# untouched so the required run-golden-record check is never created in a
# skipped state: a job skipped by its 'if' reports Success, and the newest
# check run with the same name on the head SHA is what the merge gate on
# main evaluates, so a skipped run of the required job would launder a red
# golden record into a mergeable PR. This workflow instead reacts to the
# events the real workflows must not see (run-golden-record label
# additions, base retargets, pushes to labeled stacked PRs) with a
# differently named job and re-triggers them via workflow_dispatch, which
# always produces real runs.
#
# workflow_dispatch uses the workflow definition on the target ref:
# dispatching test-on-pr.yml on a stacked head works only once that head
# contains the commit that added its workflow_dispatch trigger (rebase the
# stack onto an updated main first).

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled, edited]
branches:
- main
- master
- fix/flux-pumping/**
- diag/flux-pumping/**
- feat/flux-pumping/**
- integration/flux-pumping/**

permissions:
actions: write

jobs:
# NOT named run-golden-record or unit-tests: skipped runs of this job
# must never shadow the real checks.
dispatch-stacked-checks:
runs-on: ubuntu-24.04
# React only to: base retargets ('edited' with a base change), the
# run-golden-record label being added, and events on labeled stacked
# PRs. Everything else is already covered by the pull_request triggers
# of the real workflows. Fork heads are excluded because
# workflow_dispatch can only target refs in this repository.
if: >-
github.event.pull_request.draft == false &&
github.event.pull_request.head.repo.full_name == github.repository &&
((github.event.action == 'edited' && github.event.changes.base != null) ||
(github.event.action == 'labeled' && github.event.label.name == 'run-golden-record') ||
(github.event.action != 'edited' && github.event.action != 'labeled' &&
github.base_ref != 'main' && github.base_ref != 'master' &&
contains(github.event.pull_request.labels.*.name, 'run-golden-record')))

env:
GH_TOKEN: ${{ github.token }}
HEAD_REF: ${{ github.event.pull_request.head.ref }}

steps:
- name: Dispatch unit tests on base retarget
# unit-tests.yml does not listen to 'edited', so a retargeted PR
# gets its unit-test run from here.
if: github.event.action == 'edited'
run: gh workflow run unit-tests.yml --repo "$GITHUB_REPOSITORY" --ref "$HEAD_REF"

- name: Dispatch golden record
# Label events and pushes to labeled stacked PRs always dispatch;
# a base retarget dispatches when the new base is main/master
# (where run-golden-record is required) or the PR carries the
# run-golden-record label.
if: >-
github.event.action != 'edited' ||
github.base_ref == 'main' || github.base_ref == 'master' ||
contains(github.event.pull_request.labels.*.name, 'run-golden-record')
run: gh workflow run test-on-pr.yml --repo "$GITHUB_REPOSITORY" --ref "$HEAD_REF"
32 changes: 26 additions & 6 deletions .github/workflows/test-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,40 @@ on:
branches:
- main
- master
# run-golden-record is the required status check on main. Its types and
# branches stay exactly as they are so that every check run named
# run-golden-record comes from a real run: a job skipped by its 'if'
# reports Success and would satisfy the branch protection gate. Label
# additions, base retargets, and pushes to labeled stacked flux-pumping
# PRs are handled by stacked-pr-dispatch.yml, which re-triggers this
# workflow via workflow_dispatch under a differently named job.
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- main
- master
workflow_dispatch:
inputs:
compare_against_main:
description: Also run the exact golden-record comparison against main
required: false
default: true
type: boolean

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.event_name == 'workflow_dispatch' && github.run_id) || github.ref }}
cancel-in-progress: true

jobs:
run-golden-record:
runs-on: ubuntu-24.04
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false)
# Do not add event- or label-based skip conditions here: a skipped
# run-golden-record counts as Success for the required status check
# on main. Gating for stacked PRs lives in stacked-pr-dispatch.yml.
if: >-
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'pull_request' && github.event.pull_request.draft == false)

env:
CC: gcc
Expand Down Expand Up @@ -192,7 +212,7 @@ jobs:
${{ steps.run_test_stable.outputs.test_dir }}/ql/reference/out

- name: Build NEO-2 (reference version - main branch)
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.compare_against_main)
id: build_reference_main
run: |
# Build reference version from main branch for PR comparison
Expand All @@ -210,7 +230,7 @@ jobs:
echo "neo2_par_main=$(pwd)/build/NEO-2-PAR/neo_2_par.x" >> $GITHUB_OUTPUT

- name: Run golden record test against main version (exact check)
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.compare_against_main)
env:
CURRENT_NEO2_PAR: ${{ steps.build.outputs.neo2_par }}
REFERENCE_NEO2_PAR: ${{ steps.build_reference_main.outputs.neo2_par_main }}
Expand Down Expand Up @@ -247,7 +267,7 @@ jobs:
${{ steps.run_test_stable.outputs.test_dir }}/ql/reference/out

- name: Run QL performance test
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.compare_against_main)
env:
CURRENT_NEO2_QL: ${{ steps.build.outputs.neo2_ql }}
REFERENCE_NEO2_QL: ${{ steps.build_reference_main.outputs.neo2_ql_main }}
Expand Down Expand Up @@ -275,7 +295,7 @@ jobs:
${{ steps.run_test_stable.outputs.test_dir }}/performance_ql/performance_report.txt

- name: Run (slow) par golden record test on pull request
if: github.event_name == 'pull_request'
if: github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.compare_against_main)
env:
CURRENT_NEO2_PAR: ${{ steps.build.outputs.neo2_par }}
id: run_par_test
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@ on:
branches:
- main
- master
# The flux-pumping patterns give stacked PRs (bases like
# fix/flux-pumping/*) unit-test coverage on every push. 'edited' stays
# out of types so a title/body edit never spawns a skipped run that
# shadows the latest real unit-tests result; base retargets are handled
# by stacked-pr-dispatch.yml via workflow_dispatch.
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- main
- master
- fix/flux-pumping/**
- diag/flux-pumping/**
- feat/flux-pumping/**
- integration/flux-pumping/**
workflow_dispatch:
inputs:
libneo_ref:
Expand Down
Loading