Skip to content

Commit

Permalink
Add status control to main test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
islas committed Dec 10, 2024
1 parent a5d87d2 commit da67c44
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 47 deletions.
49 changes: 2 additions & 47 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ jobs:
permissions:
contents: read
pull-requests: write
statuses: write
name : Test ${{ matrix.testSet.name }} on ${{ matrix.testSet.host }}

tmp_tests:
Expand Down Expand Up @@ -174,45 +175,6 @@ jobs:
state: 'pending'
})
# const checks = await github.rest.checks.listForRef({
# owner: context.repo.owner,
# repo: context.repo.repo,
# ref: context.sha,
# check_name : '${{ inputs.test }}'
# })

# core.info( JSON.stringify( checks ) )

# if ( checks.data.total_count > 0 )
# {
# await core.info( "Check run already exists, updating..." )
# github.rest.checks.update({
# owner: context.repo.owner,
# repo: context.repo.repo,
# check_run_id: checks.check_runs[0].id,
# status:'in_progress',
# details_url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
# })

# return checks.check_runs[0].id
# }
# else
# {
# core.info( "Check run dose not exist, creating..." )
# response = await github.rest.checks.create({
# owner: context.repo.owner,
# repo: context.repo.repo,
# head_sha: context.sha,
# name: '${{ inputs.test }}',
# status: 'in_progress',
# details_url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}'
# })

# core.info( JSON.stringify( response ) )

# return response.data.id
# }

- name: dummy
id: dummy
run: |
Expand All @@ -234,14 +196,7 @@ jobs:
state: '${{ contains( fromJson('["success","failure","error"]'),steps.dummy.outcome ) && steps.dummy.outcome || 'error' }}'
})
# github.rest.checks.update({
# owner: context.repo.owner,
# repo: context.repo.repo,
# check_run_id: ${{ steps.check_run_start.outputs.result }},
# status: 'completed',
# details_url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}',
# conclusion: "${{ steps.dummy.outcome }}"
# })
# # In the event that 'all-tests' is used, this final job will be the one to remove
# # the label from the PR
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/test_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,30 @@ 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.label }}',
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 @@ -146,6 +166,21 @@ jobs:
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
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.label }}',
state: '${{ 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

0 comments on commit da67c44

Please sign in to comment.