Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use proxy workflow and commit statuses to record testing results #2142

Closed
wants to merge 5 commits into from
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
81 changes: 54 additions & 27 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
name: Regression Suite
run-name : ${{ github.event_name == 'push' && 'CI' || github.event.label.name }} (${{ github.event_name }})
run-name : Run ${{ inputs.event_name == 'push' && 'CI' || inputs.test }} (${{ inputs.event_name }})

on:
push:
branches: [ master, develop ]
# See https://stackoverflow.com/a/78444521 and
# https://github.com/orgs/community/discussions/26874#discussioncomment-3253755
# as well as official (but buried) documentation :
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull-request-events-for-forked-repositories-2
pull_request:
types: [ labeled ]
workflow_dispatch:
inputs:
event_name:
description: Event name that triggered this dispatch
required: false
default: push
type: string
event_number:
description: Event number that triggered this dispatch
required: false
default: 0
type: string
ref:
description: Actual ref to use
required: false
default: null
type: string
test:
description: Test to run
required: true
default: all-tests
type: choice
options:
- all-tests
- compile-tests
- tmp-tests


# https://docs.github.com/en/actions/sharing-automations/reusing-workflows#supported-keywords-for-jobs-that-call-a-reusable-workflow
# Also https://stackoverflow.com/a/74959635
Expand All @@ -30,7 +49,7 @@ on:
# https://stackoverflow.com/a/68940067
jobs:
buildtests:
if : ${{ github.event.label.name == 'compile-tests' || github.event.label.name == 'all-tests' || github.event_name == 'push' }}
if : ${{ contains( fromJson('["compile-tests","all-tests"]'), inputs.test ) || inputs.event_name == 'push' }}
strategy:
max-parallel: 4
fail-fast: false
Expand Down Expand Up @@ -86,26 +105,34 @@ jobs:
args : ${{ matrix.testSet.args }}
pool : ${{ matrix.testSet.pool }}
tpool : ${{ matrix.testSet.tpool }}

# required to emulate event trigger
event_name : ${{ inputs.event_name }}
event_number : ${{ inputs.event_number }}
ref : ${{ inputs.ref }}

# I am leaving this here for posterity if this is to be replicated in private repositories for testing
permissions:
contents: read
pull-requests: write
statuses: write
name : Test ${{ matrix.testSet.name }} on ${{ matrix.testSet.host }}

# In the event that 'all-tests' is used, this final job will be the one to remove
# the label from the PR
removeAllLabel :
if : ${{ !cancelled() && github.event.label.name == 'all-tests' }}
name : Remove 'all-tests' label
runs-on: ubuntu-latest
needs : [ buildtests ] # Put tests here to make this wait for the tests to complete
steps:
- name : Remove '${{ github.event.label.name }}' label
env:
PR_NUMBER: ${{ github.event.number }}
run: |
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
-H 'Authorization: token ${{ github.token }}' \
https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/labels/${{ github.event.label.name }}

# # In the event that 'all-tests' is used, this final job will be the one to remove
# # the label from the PR
# removeAllLabel :
# if : ${{ !cancelled() && github.event.label.name == 'all-tests' }}
# name : Remove 'all-tests' label
# runs-on: ubuntu-latest
# needs : [ buildtests ] # Put tests here to make this wait for the tests to complete
# steps:
# - name : Remove '${{ github.event.label.name }}' label
# env:
# PR_NUMBER: ${{ github.event.number }}
# run: |
# curl \
# -X DELETE \
# -H "Accept: application/vnd.github.v3+json" \
# -H 'Authorization: token ${{ github.token }}' \
# https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/labels/${{ github.event.label.name }}
43 changes: 43 additions & 0 deletions .github/workflows/entry_point.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Regression Suite Entry Point CI/CD
run-name : Queue ${{ github.event_name == 'push' && 'CI' || github.event.label.name }} (${{ github.event_name }})

on:
push:
branches: [ master, develop ]
# See https://stackoverflow.com/a/78444521 and
# https://github.com/orgs/community/discussions/26874#discussioncomment-3253755
# as well as official (but buried) documentation :
# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#pull-request-events-for-forked-repositories-2
pull_request:
types: [ labeled ]

# Write our tests out this way for easier legibility
# testsSet :
# - key : value
# key : value
# tests :
# - value
# - value
# - < next test >
# https://stackoverflow.com/a/68940067
jobs:
queue_tests:
if : ${{ contains( fromJson('["compile-tests","all-tests"]'), github.event.label.name ) || github.event_name == 'push' }}
name: Queue Test (${{ github.event_name == 'push' && github.ref_name || github.event.label.name }})
runs-on: ubuntu-latest
permissions:
actions: write
steps:
- name: Test
run : |
echo "Hello World!"
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ github.token }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/workflows/ci.yml/dispatches \
-d '{"ref":"${{ github.event_name == 'push' && github.ref_name || github.event.pull_request.head.ref }}","inputs":{"event_name":"${{ github.event_name }}", "event_number" : "${{ github.event.number }}", "test":"${{ github.event.label.name }}", "ref":"${{ github.ref }}"}}'



55 changes: 51 additions & 4 deletions .github/workflows/test_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ on :
required : false
type : number
default : 1

event_name :
required : true
type : string
event_number:
required : true
type : string
ref :
required : true
type : string



Expand All @@ -57,12 +67,33 @@ jobs:
name: Test ${{ inputs.name }} on ${{ inputs.host }}
runs-on: ${{ inputs.host }}
env :
LOG_SUFFIX : ${{ github.event_name == 'push' && 'master' || github.event.number }}
LOG_SUFFIX : ${{ inputs.event_name == 'push' && github.ref_name || inputs.event_number }}
steps:
# Don't use gh checks as they are woefully underdeveloped as a feature leading
# to confusing UI and misplaced metrics
# https://github.com/orgs/community/discussions/24616
- name: Set pending status
id: check_run_start
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
target_url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}',
description: '${{ inputs.name }}',
context: '${{ inputs.host }}/${{ inputs.id }}',
state: 'pending'
})

- uses: actions/checkout@v4
with:
path : main
submodules: true
ref: ${{ inputs.ref }}


# Immediately copy out to # of tests to do
- name: Create testing directories
Expand Down Expand Up @@ -90,7 +121,7 @@ jobs:
-t ${{ join( fromJson( inputs.tests ), ' ' ) }} \
-a "${{ inputs.account }}" \
-p ${{ inputs.pool}} -tp ${{ inputs.tpool }} \
-jn ${{ github.event_name == 'push' && github.ref_name || github.event.number }}-${{ inputs.id }} \
-jn ${{ inputs.event_name == 'push' && github.ref_name || inputs.event_number }}-${{ inputs.id }} \
${{ inputs.args }} $ALT_DIRS


Expand Down Expand Up @@ -133,9 +164,25 @@ jobs:
# *documented* functionality doesn't work as expected. Wow, bravo
# can't use ${{ env. }} as somehow this combination of matrix->reusable workflow->call step is too complex
# and expands to nothing
name: ${{ github.event_name == 'push' && github.ref_name || github.event.number }}-${{ inputs.id }}_logfiles
path: ${{ inputs.archive }}/${{ github.event_name == 'push' && github.ref_name || github.event.number }}/${{ inputs.id }}/
name: ${{ inputs.event_name == 'push' && github.ref_name || inputs.event_number }}-${{ inputs.id }}_logfiles
path: ${{ inputs.archive }}/${{ inputs.event_name == 'push' && github.ref_name || inputs.event_number }}/${{ inputs.id }}/
include-hidden-files: true

- name: Set completed status
if: ${{ always() }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
target_url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}',
description: '${{ inputs.name }}',
context: '${{ inputs.host }}/${{ inputs.id }}',
state: '${{ job.status == 'success' && 'success' || 'failure' }}'
})
# As noted in ci.yml, this will need to be moved to a separate workflow with pull_request_target
# and strictly controlled usage of the GH token
# - name : Remove '${{ inputs.label }}' label
Expand Down
Loading