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

Conditionally run set-variables job in run-profiling.yaml workflow file #1123

Closed
matt-graham opened this issue Sep 20, 2023 · 1 comment · Fixed by #1236
Closed

Conditionally run set-variables job in run-profiling.yaml workflow file #1123

matt-graham opened this issue Sep 20, 2023 · 1 comment · Fixed by #1236
Labels
enhancement New feature or request gh-actions

Comments

@matt-graham
Copy link
Collaborator

matt-graham commented Sep 20, 2023

At the moment the set-variables job in .github/workflows/run-profiling.yaml runs unconditionally:

set-variables:
name: Create unique output file identifier and artifact name
runs-on: ubuntu-latest
outputs:
profiling-filename: ${{ steps.set-profiling-filename.outputs.name }}
artifact-name: $${{ steps.set-artifact-name.outputs.name }}
steps:
- id: set-profiling-filename
name: Set profiling output file name
run: |
echo "name=${GITHUB_EVENT_NAME}_${GITHUB_RUN_NUMBER}_${GITHUB_SHA}" >> "${GITHUB_OUTPUT}"
- id: set-artifact-name
name: Set artifact name
run: |
echo "name=profiling_results_${GITHUB_RUN_NUMBER}" >> "${GITHUB_OUTPUT}"

which means even if the subsequent steps are skipped we get a workflow success status rather than skipped status, which for example stops us using a query like https://github.com/UCL/TLOmodel/actions/workflows/run-profiling.yaml?query=is%3Asuccess to find successful runs of the workflow (or at least ones in which any profiling was performed!).

I think if we add an if condition something like

if: (github.event_name != 'issue_comment') || ((github.event_name == 'issue_comment') && (github.event.comment.body == '/run profiling')

we should prevent the job being run when the succeeding jobs will be skipped, though then we do end up needing to keep the condition here in sync with the logic in the next jobs.

@matt-graham matt-graham added enhancement New feature or request gh-actions labels Sep 20, 2023
@willGraham01
Copy link
Collaborator

I feel like the if condition is the lesser of two evils - the alternative (which I think we tried when first setting up the profiling) is to put all of the logic in the run-profiling workflow into the command argument to the comment-triggered stuff, which wasn't the most readable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gh-actions
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants