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

Initial implementation #1

Merged
merged 14 commits into from
Sep 17, 2024
Merged

Initial implementation #1

merged 14 commits into from
Sep 17, 2024

Conversation

omus
Copy link
Member

@omus omus commented Aug 16, 2024

Creates a new public repository for hosting a new GitHub action. This action will allow the currently running job to determine the job name and job ID allowing improved usage of the GitHub API.

A quick overview of the implementation: in order to determine the job ID we need to use the GitHub API to list jobs for a workflow run attempt. In order to determine which job from the API results is the currently running job we need some kind of alternate way of uniquely selecting the job. I looked at the GitHub Actions context information and the only overlap I found was the runner.name context which according to the docs may not be unique. Alternatively, I chose to use the job name for the selection criteria which also isn't guaranteed to be unique but typically is and it is reasonable to require users to define unique job name within a user provided workflow. Unfortunately, the job name also isn't available via contexts so to get the job name we need to perform three steps:

  1. Access the YAML workflow file which defined this currently running job
  2. Use the ${{ github.job }} which is the job YAML key in the workflow to determine the job name template (the job name as defined in YAML can contain GitHub expressions).
  3. Render any GHA expressions in the job name template

With these steps we know the name of the job and can use that information to determine the job ID. If a job name happens to not be unique we can detect that and cause the action to fail and request that the user makes the job name unique.

In the future we may choose to use runner.name as a first pass in selecting the job from the GitHub API job list. I would consider this an optimization though as we would still need to the job name as either a fallback or as part of the selection criteria.

Various issues asking for the job name or ID feature:

@iamed2
Copy link
Member

iamed2 commented Sep 3, 2024

What's the motivation for this?

@omus
Copy link
Member Author

omus commented Sep 3, 2024

What's the motivation for this?

Knowing the job_id as used by the GitHub API is important for the new matrix-output GHA which requires this information to ensure that the last executed job in the matrix has a complete set of outputs. For more details see this design document: https://github.com/beacon-biosignals/matrix-output/pull/1/files#diff-be587c6fc5d417e1f9d10be50292738384b9df23b4699c8852c990612d3374a6

Copy link
Member

@kleinschmidt kleinschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems really really cursed but with reasonable test coverage I'm okay with it.

.github/workflows/integration-tests.yaml Outdated Show resolved Hide resolved
.github/workflows/integration-tests.yaml Show resolved Hide resolved
@omus
Copy link
Member Author

omus commented Sep 13, 2024

Thanks Dave. I'll merge this and make the first release on Monday!

@omus omus merged commit abc4b53 into main Sep 17, 2024
13 checks passed
@omus omus deleted the cv/initial branch September 17, 2024 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants