Skip to content
Merged
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
20 changes: 14 additions & 6 deletions .github/workflows/Breakage.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
name: Breakage
run-name: "Breakage${{ inputs.pr && format(' #{0}', inputs.pr) || '' }}"

# On a pull request, a label starts its own run through Labels.yml
# (CTActions docs/workflows/label-dispatch.md).

# The packages that depend on OptimalControlProblems, tested against it; see CTActions
# docs/workflows/breakage-suite.md.

on:
pull_request:
types: [labeled, synchronize, reopened]
push:
branches: [main]
workflow_dispatch:
inputs:
pr:
description: 'Pull request number, set by label-dispatch.yml; empty by hand: the baseline run'
required: false
default: ''
target:
description: 'packages or applications'
required: false
default: ''

jobs:
call:
if: >
github.event_name != 'pull_request' ||
(github.event.action == 'labeled' && github.event.label.name == 'run breakage') ||
(github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, 'run breakage'))
if: inputs.pr == '' || inputs.target == 'packages'
uses: control-toolbox/CTActions/.github/workflows/breakage-suite.yml@main
with:
use_ct_registry: true
Expand Down
73 changes: 42 additions & 31 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
name: CI
run-name: "CI ${{ inputs.target }}${{ inputs.pr && format(' #{0}', inputs.pr) || '' }}"

# On a pull request, a label starts its own run through Labels.yml
# (CTActions docs/workflows/label-dispatch.md): `target` says which runner, `pr` which
# pull request. The scope of the CI is read from that pull request.

on:
push:
branches:
- main
tags: '*'
pull_request:
types: [labeled, unlabeled, synchronize, reopened]
workflow_dispatch:
inputs:
pr:
description: 'Pull request number, set by label-dispatch.yml'
required: false
default: ''
target:
description: 'github, occidata or kkt'
required: false
default: ''

jobs:
# Turn the files a pull request changes, and its scope labels, into the arguments of
Expand All @@ -17,6 +30,7 @@ jobs:
# shared change, a removed or renamed file and any unreadable or truncated file list
# run everything. The rules are in test/README.md.
scope:
if: github.event_name == 'push' || inputs.target == 'github'
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -25,15 +39,26 @@ jobs:
test_args: ${{ steps.scope.outputs.test_args }}
steps:
- uses: actions/checkout@v4
# The labels and the number of changed files of the pull request: a dispatched run
# has no pull request in its event.
- id: pr
if: inputs.pr != ''
env:
GH_TOKEN: ${{ github.token }}
PR: ${{ inputs.pr }}
run: |
gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR}" \
--jq '"labels=\([.labels[].name] | tojson)", "changed_files=\(.changed_files)"' >> "$GITHUB_OUTPUT"
- id: files
if: github.event_name == 'pull_request'
if: inputs.pr != ''
env:
GH_TOKEN: ${{ github.token }}
PR: ${{ inputs.pr }}
run: |
# Written only on success: a failed call leaves no list and the scope step
# runs the complete catalogue.
if gh api --paginate \
"repos/${GITHUB_REPOSITORY}/pulls/${{ github.event.pull_request.number }}/files" \
"repos/${GITHUB_REPOSITORY}/pulls/${PR}/files" \
--jq '.[] | [.status, .filename] | @tsv' > changed_files.tsv.new; then
mv changed_files.tsv.new changed_files.tsv
else
Expand All @@ -48,30 +73,24 @@ jobs:

- id: scope
env:
# null outside pull_request events: the script reads it as no label.
LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }}
# null outside a pull request: the script reads it as no label.
LABELS: ${{ steps.pr.outputs.labels || 'null' }}
EVENT: ${{ inputs.pr != '' && 'pull_request' || github.event_name }}
CHANGED_FILES: ${{ steps.pr.outputs.changed_files }}
run: |
args=$(cat changed_files.tsv 2>/dev/null | python3 tools/ci/scope.py \
--event "${{ github.event_name }}" \
--event "$EVENT" \
--labels "$LABELS" \
--expected-files "${{ github.event.pull_request.changed_files }}" \
--expected-files "$CHANGED_FILES" \
--summary "$GITHUB_STEP_SUMMARY")
echo "test_args=$args" >> "$GITHUB_OUTPUT"
echo "test_args: '$args'"

# On a pull request, run when the runner label is set: on a push, on the runner label
# being added, or on a label that changes what runs being added or removed (the scope
# labels `test ...`, including `test all problems`, and `release`). Other label events
# do not rerun the CI.
# On a push, and for the runner label (target github): the scope labels `test ...` and
# `release` run it again through Labels.yml (restart_labels).
call:
needs: scope
if: >
github.event_name != 'pull_request' ||
(contains(github.event.pull_request.labels.*.name, 'run ci github-runner') &&
((github.event.action != 'labeled' && github.event.action != 'unlabeled') ||
github.event.label.name == 'run ci github-runner' ||
github.event.label.name == 'release' ||
startsWith(github.event.label.name, 'test ')))
if: github.event_name == 'push' || inputs.target == 'github'
uses: control-toolbox/CTActions/.github/workflows/ci.yml@main
with:
# Temporary, during the reorganisation of #310: Ubuntu and Julia 1.13 only.
Expand Down Expand Up @@ -105,14 +124,9 @@ jobs:
- run: python3 tools/ci/results.py --reports artifacts --summary "$GITHUB_STEP_SUMMARY" > /dev/null

# GPU tests (environment `GPU`: Exa and MadNLP on the GPU, test/README.md) on the
# self-hosted runners, on a pull request with the runner label. A `labeled` event fires
# once per label added: react only to the label of the runner, and to the other events
# when the label is set.
# self-hosted runners, on a pull request with the runner label (target occidata or kkt).
test-gpu-occidata:
if: >
github.event_name == 'pull_request' &&
((github.event.action == 'labeled' && github.event.label.name == 'run ci occidata-runner') ||
(github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, 'run ci occidata-runner')))
if: inputs.target == 'occidata'
uses: control-toolbox/CTActions/.github/workflows/ci.yml@main
with:
versions: '["1.13"]'
Expand All @@ -124,10 +138,7 @@ jobs:
SSH_KEY: ${{ secrets.SSH_KEY }}

test-gpu-kkt:
if: >
github.event_name == 'pull_request' &&
((github.event.action == 'labeled' && github.event.label.name == 'run ci kkt-runner') ||
(github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, 'run ci kkt-runner')))
if: inputs.target == 'kkt'
uses: control-toolbox/CTActions/.github/workflows/ci.yml@main
with:
versions: '["1.13"]'
Expand All @@ -141,7 +152,7 @@ jobs:
# On a push (main, tags): a single GPU run, on kkt unless it is offline, else occidata
# (CTActions ci-gpu.yml).
test-gpu-main:
if: github.event_name != 'pull_request'
if: github.event_name == 'push'
uses: control-toolbox/CTActions/.github/workflows/ci-gpu.yml@main
with:
versions: '["1.13"]'
Expand Down
21 changes: 13 additions & 8 deletions .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
name: Documentation
run-name: "Documentation${{ inputs.pr && format(' #{0}', inputs.pr) || '' }}"

# On a pull request, a label starts its own run through Labels.yml
# (CTActions docs/workflows/label-dispatch.md).

on:
push:
branches:
- main
tags:
- 'v[0-9]+\.[0-9]+\.[0-9]+' # v0.5.0 yes, v0.5.0-beta no
pull_request:
types: [labeled, synchronize, reopened]
workflow_dispatch:
inputs:
pr:
description: 'Pull request number, set by label-dispatch.yml'
required: false
default: ''
preview:
description: 'Deploy the preview of the pull request (label documentation push preview)'
required: false
default: 'false'

jobs:
call:
if: >
github.event_name != 'pull_request' ||
(contains(github.event.pull_request.labels.*.name, 'run documentation') &&
(github.event.action != 'labeled' ||
github.event.label.name == 'run documentation' ||
github.event.label.name == 'documentation push preview'))
uses: control-toolbox/CTActions/.github/workflows/documentation.yml@main
with:
use_ct_registry: true
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/Labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Labels

# A label added to a pull request starts the workflow of that label, and only that one
# (CTActions docs/workflows/label-dispatch.md): CI, Documentation and Breakage are
# dispatched, they no longer listen to pull_request.

on:
pull_request:
types: [labeled, unlabeled, synchronize, reopened]

jobs:
call:
permissions:
contents: read
actions: write
uses: control-toolbox/CTActions/.github/workflows/label-dispatch.yml@main
with:
# The scope of the CI depends on these labels (tools/ci/scope.py): added while
# `run ci github-runner` is on the pull request, they run the CI again.
restart_labels: '["release"]'
restart_prefix: 'test '
4 changes: 4 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ request changes** (#405), and the scope labels only **add** to it:
| `test convergence` | add the convergence report (argument `convergence`): the convergence tests of the selected environments run after the others, and report without failing |

Adding or removing a label reruns the CI when a runner label is set. `core` always runs.
A label starts its own run through `Labels.yml` (CTActions
[label dispatch](https://github.com/control-toolbox/CTActions/blob/main/docs/workflows/label-dispatch.md)):
the run is in the Actions tab and as a commit status of the pull request (`CI / github`), not in
its Checks tab.

**When to add `test convergence`.** When the pull request can change what a solve returns
(a model, an initial guess, a solver option, a scheme), or changes code that only the
Expand Down
Loading