From 0d35337618977cb85f45da1f793e927a77c8e22c Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 12 Dec 2024 13:52:39 -0700 Subject: [PATCH 01/17] Convert to dispatch workflow and switch context vars to inputs --- .github/workflows/ci.yml | 45 ++++++++++++++++++++++------- .github/workflows/test_workflow.yml | 21 +++++++++++--- 2 files changed, 52 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 087f9eba34..9348e6124f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 @@ -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 @@ -86,6 +105,12 @@ 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 diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index e80d6f3392..4da30cd38c 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -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 @@ -57,12 +67,14 @@ 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: - uses: actions/checkout@v4 with: path : main submodules: true + ref: ${{ inputs.ref }} + # Immediately copy out to # of tests to do - name: Create testing directories @@ -90,7 +102,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 @@ -133,8 +145,9 @@ 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 # 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 From 653302e60952c413026e406f13887a897bef585f Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 12 Dec 2024 13:53:14 -0700 Subject: [PATCH 02/17] Add commit status to dispatch sha --- .github/workflows/ci.yml | 1 + .github/workflows/test_workflow.yml | 34 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9348e6124f..62521047f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -115,6 +115,7 @@ jobs: 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 diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 4da30cd38c..3b576e99a8 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -69,6 +69,25 @@ jobs: env : 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 @@ -149,6 +168,21 @@ jobs: 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 From a6e12811b82df1ea6e0315f41020a6b4ebf7422b Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 12 Dec 2024 13:53:35 -0700 Subject: [PATCH 03/17] Comment out skipped step for now --- .github/workflows/ci.yml | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62521047f9..7cf4c5e8bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -118,20 +118,21 @@ jobs: 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 }} From 371998e5defd1c6f8a71468b83397ea3bb87cfdc Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 12 Dec 2024 13:54:14 -0700 Subject: [PATCH 04/17] Create proxy workflow to act as label/ci/cd trigger entry point --- .github/workflows/entry_point.yml | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/entry_point.yml diff --git a/.github/workflows/entry_point.yml b/.github/workflows/entry_point.yml new file mode 100644 index 0000000000..ace2743add --- /dev/null +++ b/.github/workflows/entry_point.yml @@ -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.head_ref }}","inputs":{"event_name":"${{ github.event_name }}", "event_number" : "${{ github.event.number }}", "test":"${{ github.event.label.name }}", "ref":"${{ github.ref }}"}}' + + + From d53ef5110308f8de99ac42c9478fda91730fc673 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 12 Dec 2024 15:03:41 -0700 Subject: [PATCH 05/17] Try to use pr merge ref --- .github/workflows/entry_point.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/entry_point.yml b/.github/workflows/entry_point.yml index ace2743add..cbec4f3bde 100644 --- a/.github/workflows/entry_point.yml +++ b/.github/workflows/entry_point.yml @@ -37,7 +37,7 @@ jobs: -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.head_ref }}","inputs":{"event_name":"${{ github.event_name }}", "event_number" : "${{ github.event.number }}", "test":"${{ github.event.label.name }}", "ref":"${{ github.ref }}"}}' + -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 }}"}}' From a8c66dac001736cf1371c056b827702a035c49dd Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 12 Dec 2024 17:28:47 -0700 Subject: [PATCH 06/17] Switch dispatch ref to utilize the base of the PR This change makes usage of the dispatch on label paradigm possible at the expense of slowing development by forcing the running in the base of the pull request rather than the merge ref. Ultimately this may be more desirable as it enables the workflows run by self-hosted runners to only execute trusted code from the base ref. --- .github/workflows/ci.yml | 38 +++++++++++++++-------------- .github/workflows/entry_point.yml | 5 ++-- .github/workflows/test_workflow.yml | 23 +++++++++-------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7cf4c5e8bc..36d3dd54b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,7 +88,7 @@ jobs: uses : ./.github/workflows/test_workflow.yml with : - # This should be the only hard-coded value, we don't use ${{ github.event.label.name }} + # This should be the only hard-coded value, we don't use ${{ inputs.test }} # to avoid 'all-tests' to be used in this workflow label : compile-tests @@ -119,20 +119,22 @@ jobs: 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() && inputs.test == '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 + permissions: + pull-requests: write + steps: + - name : Remove '${{ inputs.test }}' label + env: + PR_NUMBER: ${{ inputs.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/${{ inputs.test }} diff --git a/.github/workflows/entry_point.yml b/.github/workflows/entry_point.yml index cbec4f3bde..27c2c0891b 100644 --- a/.github/workflows/entry_point.yml +++ b/.github/workflows/entry_point.yml @@ -28,16 +28,15 @@ jobs: permissions: actions: write steps: - - name: Test + - name: Dispatch Regression Suite 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 }}"}}' + -d '{"ref":"${{ github.event_name == 'push' && github.ref_name || github.event.pull_request.base.ref }}","inputs":{"event_name":"${{ github.event_name }}", "event_number" : "${{ github.event.number }}", "test":"${{ github.event.label.name }}", "ref":"${{ github.ref }}"}}' diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 3b576e99a8..358a3b3566 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -183,18 +183,17 @@ jobs: 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 - # if : ${{ !cancelled() && github.event.label.name == inputs.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/${{ inputs.label }} + + - name : Remove '${{ inputs.label }}' label + if : ${{ !cancelled() && github.event.label.name == inputs.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/${{ inputs.label }} From 6ba40132ad2a4922b74e2477791287e8f6a8c462 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 12 Dec 2024 17:54:22 -0700 Subject: [PATCH 07/17] Use the proxy sha to create the status --- .github/workflows/ci.yml | 5 +++++ .github/workflows/entry_point.yml | 14 +++++++++++++- .github/workflows/test_workflow.yml | 9 ++++++--- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 36d3dd54b1..1b562deb98 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,11 @@ on: required: false default: null type: string + sha: + description: Actual sha to use + required: false + default: null + type: string test: description: Test to run required: true diff --git a/.github/workflows/entry_point.yml b/.github/workflows/entry_point.yml index 27c2c0891b..05baed8b0b 100644 --- a/.github/workflows/entry_point.yml +++ b/.github/workflows/entry_point.yml @@ -36,7 +36,19 @@ jobs: -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.base.ref }}","inputs":{"event_name":"${{ github.event_name }}", "event_number" : "${{ github.event.number }}", "test":"${{ github.event.label.name }}", "ref":"${{ github.ref }}"}}' + --data-binary @- << EOF + { + "ref" : "${{ github.event_name == 'push' && github.ref_name || github.event.pull_request.base.ref }}", + "inputs" : + { + "event_name" : "${{ github.event_name }}", + "event_number" : "${{ github.event.number }}", + "test" : "${{ github.event.label.name }}", + "ref" : "${{ github.ref }}" + "sha" : "${{ github.sha }}" + } + } + EOF diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 358a3b3566..370d56ee30 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -56,6 +56,9 @@ on : ref : required : true type : string + sha : + required : true + type : string @@ -81,7 +84,7 @@ jobs: github.rest.repos.createCommitStatus({ owner: context.repo.owner, repo: context.repo.repo, - sha: context.sha, + sha: '${{ inputs.event_name == 'push' && github.sha || inputs.sha }}', target_url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}', description: '${{ inputs.name }}', context: '${{ inputs.host }}/${{ inputs.id }}', @@ -92,7 +95,7 @@ jobs: with: path : main submodules: true - ref: ${{ inputs.ref }} + ref: ${{ inputs.event_name == 'push' && github.ref || inputs.ref }} # Immediately copy out to # of tests to do @@ -177,7 +180,7 @@ jobs: github.rest.repos.createCommitStatus({ owner: context.repo.owner, repo: context.repo.repo, - sha: context.sha, + sha: '${{ inputs.event_name == 'push' && github.sha || inputs.sha }}', target_url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}', description: '${{ inputs.name }}', context: '${{ inputs.host }}/${{ inputs.id }}', From c0aad9b37df68c20b2acd62e7729248442752bfa Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 12 Dec 2024 17:57:49 -0700 Subject: [PATCH 08/17] Correctly set EOF location --- .github/workflows/entry_point.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/entry_point.yml b/.github/workflows/entry_point.yml index 05baed8b0b..02c98c9e5b 100644 --- a/.github/workflows/entry_point.yml +++ b/.github/workflows/entry_point.yml @@ -48,7 +48,7 @@ jobs: "sha" : "${{ github.sha }}" } } - EOF + EOF From 9b59668c9f95be26f7dce6a7bb44aa0d8df5d096 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 12 Dec 2024 18:01:43 -0700 Subject: [PATCH 09/17] Missing comma --- .github/workflows/entry_point.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/entry_point.yml b/.github/workflows/entry_point.yml index 02c98c9e5b..f61aeca8a6 100644 --- a/.github/workflows/entry_point.yml +++ b/.github/workflows/entry_point.yml @@ -44,7 +44,7 @@ jobs: "event_name" : "${{ github.event_name }}", "event_number" : "${{ github.event.number }}", "test" : "${{ github.event.label.name }}", - "ref" : "${{ github.ref }}" + "ref" : "${{ github.ref }}", "sha" : "${{ github.sha }}" } } From 56642d71a2dd1a993f7c8f090c8246fd7c80b2d0 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 12 Dec 2024 18:03:29 -0700 Subject: [PATCH 10/17] Provide sha --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b562deb98..faaf3c37e9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -115,6 +115,7 @@ jobs: event_name : ${{ inputs.event_name }} event_number : ${{ inputs.event_number }} ref : ${{ inputs.ref }} + sha : ${{ inputs.sha }} # I am leaving this here for posterity if this is to be replicated in private repositories for testing permissions: From c327a7dcdba381f60182c61d6894ac302e3bb647 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Thu, 12 Dec 2024 18:09:19 -0700 Subject: [PATCH 11/17] Use head SHA not merge commit sha --- .github/workflows/entry_point.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/entry_point.yml b/.github/workflows/entry_point.yml index f61aeca8a6..f4f1f4fb50 100644 --- a/.github/workflows/entry_point.yml +++ b/.github/workflows/entry_point.yml @@ -45,7 +45,7 @@ jobs: "event_number" : "${{ github.event.number }}", "test" : "${{ github.event.label.name }}", "ref" : "${{ github.ref }}", - "sha" : "${{ github.sha }}" + "sha" : "${{ github.event_name == 'push' && github.sha || github.event.pull_request.head.sha }}" } } EOF From 1bd681d98ee0c2ec2b5c675d6233afe1f48c2b7c Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 13 Dec 2024 11:45:11 -0700 Subject: [PATCH 12/17] Making sure label can be removed --- .github/workflows/ci.yml | 1 + .github/workflows/test_workflow.yml | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index faaf3c37e9..94404ff2c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,6 +114,7 @@ jobs: # required to emulate event trigger event_name : ${{ inputs.event_name }} event_number : ${{ inputs.event_number }} + event_label : ${{ inputs.test }} ref : ${{ inputs.ref }} sha : ${{ inputs.sha }} diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 370d56ee30..c98f4db43b 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -141,6 +141,8 @@ jobs: ./main/${{ inputs.hpc-workflows_path }}/.ci/reporter.py ${{ inputs.archive }}/$LOG_SUFFIX/${{ inputs.id }}/$masterlogLoc/${{ inputs.fileroot }}.log \ -e ./${{ inputs.hpc-workflows_path }}/.ci/runner.py \ -o GITHUB -m # only mark fail steps with gh syntax + + echo "Relaying results to summary..." # report on them echo "# Summary for ${{ join( fromJson( inputs.tests ), ' ' ) }}" >> $GITHUB_STEP_SUMMARY @@ -188,7 +190,7 @@ jobs: }) - name : Remove '${{ inputs.label }}' label - if : ${{ !cancelled() && github.event.label.name == inputs.label }} + if : ${{ !cancelled() && inputs.test == inputs.label }} env: PR_NUMBER: ${{ github.event.number }} run: | From c58e9e27a03f1efa792d8aaf7e26756dc7ae16bc Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 13 Dec 2024 11:54:16 -0700 Subject: [PATCH 13/17] Provide input pararm --- .github/workflows/test_workflow.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index c98f4db43b..3bf97a9ede 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -53,6 +53,9 @@ on : event_number: required : true type : string + event_label: + required : true + type : string ref : required : true type : string @@ -190,7 +193,7 @@ jobs: }) - name : Remove '${{ inputs.label }}' label - if : ${{ !cancelled() && inputs.test == inputs.label }} + if : ${{ !cancelled() && inputs.event_label == inputs.label }} env: PR_NUMBER: ${{ github.event.number }} run: | From 45ec5746ef355c8a0ea1c50b494e4056f39f0c4a Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 13 Dec 2024 12:22:47 -0700 Subject: [PATCH 14/17] Force no exit early --- .github/workflows/test_workflow.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 3bf97a9ede..294747442f 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -143,7 +143,7 @@ jobs: fi ./main/${{ inputs.hpc-workflows_path }}/.ci/reporter.py ${{ inputs.archive }}/$LOG_SUFFIX/${{ inputs.id }}/$masterlogLoc/${{ inputs.fileroot }}.log \ -e ./${{ inputs.hpc-workflows_path }}/.ci/runner.py \ - -o GITHUB -m # only mark fail steps with gh syntax + -o GITHUB -m -n # only mark fail steps with gh syntax echo "Relaying results to summary..." @@ -152,8 +152,10 @@ jobs: echo "\`\`\`" >> $GITHUB_STEP_SUMMARY ./main/${{ inputs.hpc-workflows_path }}/.ci/reporter.py ${{ inputs.archive }}/$LOG_SUFFIX/${{ inputs.id }}/$masterlogLoc/${{ inputs.fileroot }}.log \ -e ./${{ inputs.hpc-workflows_path }}/.ci/runner.py \ - -s >> $GITHUB_STEP_SUMMARY + -s -n >> $GITHUB_STEP_SUMMARY echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + # We know this is a failure + exit 1 - name: Clean up testing directories if : ${{ success() }} From b0bc977c9544e6e13b46f893f398e74e0e6c92f6 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 13 Dec 2024 12:24:27 -0700 Subject: [PATCH 15/17] Use inputs.event_number --- .github/workflows/test_workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 294747442f..8b05e750e6 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -197,7 +197,7 @@ jobs: - name : Remove '${{ inputs.label }}' label if : ${{ !cancelled() && inputs.event_label == inputs.label }} env: - PR_NUMBER: ${{ github.event.number }} + PR_NUMBER: ${{ inputs.event_number }} run: | curl \ -X DELETE \ From 58466a693c961222c82d7bd46b5748591d5a24e4 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 13 Dec 2024 13:23:11 -0700 Subject: [PATCH 16/17] Improve reporting --- .ci/hpc-workflows | 2 +- .github/workflows/test_workflow.yml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.ci/hpc-workflows b/.ci/hpc-workflows index dfc8e6d823..043a4b6711 160000 --- a/.ci/hpc-workflows +++ b/.ci/hpc-workflows @@ -1 +1 @@ -Subproject commit dfc8e6d823b80497ea41bab94e1fdf3f4594ad18 +Subproject commit 043a4b6711e7f7d6dd41bd932e6e7336334e9a53 diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 8b05e750e6..a4060dcb6c 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -142,16 +142,16 @@ jobs: masterlogLoc=main/.ci fi ./main/${{ inputs.hpc-workflows_path }}/.ci/reporter.py ${{ inputs.archive }}/$LOG_SUFFIX/${{ inputs.id }}/$masterlogLoc/${{ inputs.fileroot }}.log \ - -e ./${{ inputs.hpc-workflows_path }}/.ci/runner.py \ + -e ./${{ inputs.hpc-workflows_path }}/.ci/runner.py -p ./.ci \ -o GITHUB -m -n # only mark fail steps with gh syntax echo "Relaying results to summary..." # report on them - echo "# Summary for ${{ join( fromJson( inputs.tests ), ' ' ) }}" >> $GITHUB_STEP_SUMMARY + echo "# Summary for ${{ inputs.name }}" >> $GITHUB_STEP_SUMMARY echo "\`\`\`" >> $GITHUB_STEP_SUMMARY ./main/${{ inputs.hpc-workflows_path }}/.ci/reporter.py ${{ inputs.archive }}/$LOG_SUFFIX/${{ inputs.id }}/$masterlogLoc/${{ inputs.fileroot }}.log \ - -e ./${{ inputs.hpc-workflows_path }}/.ci/runner.py \ + -e ./${{ inputs.hpc-workflows_path }}/.ci/runner.py -p ./.ci \ -s -n >> $GITHUB_STEP_SUMMARY echo "\`\`\`" >> $GITHUB_STEP_SUMMARY # We know this is a failure From 636a8edc03e9449989da188f359995c2cdc75238 Mon Sep 17 00:00:00 2001 From: Anthony Islas Date: Fri, 13 Dec 2024 16:09:18 -0700 Subject: [PATCH 17/17] Allow non-fork PRs to run in the context of the incoming branch --- .github/workflows/entry_point.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/entry_point.yml b/.github/workflows/entry_point.yml index f4f1f4fb50..ed4ce200cd 100644 --- a/.github/workflows/entry_point.yml +++ b/.github/workflows/entry_point.yml @@ -38,7 +38,7 @@ jobs: https://api.github.com/repos/${GITHUB_REPOSITORY}/actions/workflows/ci.yml/dispatches \ --data-binary @- << EOF { - "ref" : "${{ github.event_name == 'push' && github.ref_name || github.event.pull_request.base.ref }}", + "ref" : "${{ github.event_name == 'push' && github.ref_name || github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.head.ref || github.event.pull_request.base.ref }}", "inputs" : { "event_name" : "${{ github.event_name }}",