Skip to content

Commit

Permalink
Use external job-context
Browse files Browse the repository at this point in the history
  • Loading branch information
omus committed Aug 16, 2024
1 parent d3aac25 commit c5de515
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 274 deletions.
114 changes: 0 additions & 114 deletions .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -231,117 +231,3 @@ jobs:
"index": 2
}
]
test-job-name:
name: Job Name
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- uses: ./job-context/
id: job
- name: Matches expected name
run: '[[ "${output}" == "${expected}" ]] || exit 1'
env:
output: ${{ steps.job.outputs.name }}
expected: "Job Name"
- name: Has Job ID
run: '[[ -n "${job_id}" ]] || exit 1'
env:
job_id: ${{ steps.job.outputs.id }}

test-job-name-matrix:
name: Job Name
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
strategy:
fail-fast: false
matrix:
build:
- name: App One
repo: user/app1
- name: App Two
repo: user/app2
version:
- "1.0"
- "2.0"
steps:
- uses: actions/checkout@v4
- uses: ./job-context/
id: job
- name: Matches expected name
run: '[[ "${output}" == "${expected}" ]] || exit 1'
env:
output: ${{ steps.job.outputs.name }}
expected: "Job Name (${{ matrix.build.name }}, ${{ matrix.build.repo }}, ${{ matrix.version }})"
- name: Matches GitHub API name
run: |
jobs="$(gh api -X GET "/repos/{owner}/{repo}/actions/runs/${run_id:?}/attempts/${run_attempt:?}/jobs")"
if [[ $(jq --arg name "$job_name" '.jobs | map(select(.name == $name)) | length' <<<"${jobs}") -ne 1 ]]; then
jq '.jobs[].name' <<<"${jobs}"
exit 1
fi
env:
GH_TOKEN: ${{ github.token }}
run_id: ${{ github.run_id }}
run_attempt: ${{ github.run_attempt }}
job_name: ${{ steps.job.outputs.name }}

test-job-name-matrix-expr:
# TODO: Using `github.job` with any expressions results in it being empty
name: ${{ github.event_name }} - ${{ matrix.dne }} - ${{ matrix.index }} - ${{ strategy.job-index }}
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
strategy:
fail-fast: false
matrix:
index:
- 1
- 2
steps:
- uses: actions/checkout@v4
- uses: ./job-context/
id: job
- name: Matches expected name
run: '[[ "${output}" == "${expected}" ]] || exit 1'
env:
output: ${{ steps.job.outputs.name }}
expected: ${{ github.event_name }} - - ${{ matrix.index }} - ${{ strategy.job-index }}
- name: Matches GitHub API name
run: |
jobs="$(gh api -X GET "/repos/{owner}/{repo}/actions/runs/${run_id:?}/attempts/${run_attempt:?}/jobs")"
if [[ $(jq --arg name "$job_name" '.jobs | map(select(.name == $name)) | length' <<<"${jobs}") -ne 1 ]]; then
jq '.jobs[].name' <<<"${jobs}"
exit 1
fi
env:
GH_TOKEN: ${{ github.token }}
run_id: ${{ github.run_id }}
run_attempt: ${{ github.run_attempt }}
job_name: ${{ steps.job.outputs.name }}

test-job-name-ambiguous:
name: ${{ github.job }}
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
strategy:
fail-fast: false
matrix:
index:
- 1
- 2
steps:
- uses: actions/checkout@v4
- uses: ./job-context/
id: job
continue-on-error: true
- name: Action failed
if: ${{ steps.job.outcome != 'failure' }}
run: exit 1
2 changes: 1 addition & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ outputs:
runs:
using: composite
steps:
- uses: beacon-biosignals/matrix-output/job-context@058ddcc071ab25d68906c3a32ed7ab9f0b50464e
- uses: beacon-biosignals/job-context@ed905aa02f3f5e78f3d963d974aee0ac9f97219f
id: job
with:
path: ${{ github.action_path }}/repo
Expand Down
60 changes: 0 additions & 60 deletions job-context/README.md

This file was deleted.

99 changes: 0 additions & 99 deletions job-context/action.yaml

This file was deleted.

0 comments on commit c5de515

Please sign in to comment.