Skip to content

Commit

Permalink
Embed job id in test report path for tt-github-actions (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
nsmithtt authored Dec 3, 2024
1 parent 51e3b6b commit c4ba51e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/run-model-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,20 @@ jobs:
- name: Set reusable strings
id: strings
shell: bash
env:
job-name: "${{ github.job }} (${{ matrix.build.runs-on }}, ${{ matrix.build.name }}, ${{ matrix.build.test_names }})"
run: |
echo "work-dir=$(pwd)" >> "$GITHUB_OUTPUT"
echo "build-output-dir=$(pwd)/build" >> "$GITHUB_OUTPUT"
echo "install-output-dir=$(pwd)/install" >> "$GITHUB_OUTPUT"
echo "test-output-dir=$(pwd)/results/models/tests/" >> "$GITHUB_OUTPUT"
# Github job context unfortunately doesn't contain job_id, this is the workaround how to fetch it using GH API
echo "Expected job name: ${{ env.job-name }}"
JOB_ID=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}/jobs" | \
jq -r '.jobs[] | select(.name | contains("${{ env.job-name }}")) | .id ')
echo "Current job id: $JOB_ID"
echo "job-id=$JOB_ID" >> "$GITHUB_OUTPUT"
- name: Git safe dir
run: git config --global --add safe.directory ${{ steps.strings.outputs.work-dir }}
Expand Down Expand Up @@ -91,10 +100,10 @@ jobs:
shell: bash
working-directory: ${{ steps.strings.outputs.test-output-dir }}
run: |
tar cvf ${{ matrix.build.name }}.tar .
tar cvf ${{ matrix.build.name }}_${{ steps.strings.outputs.job-id }}.tar .
- name: Upload test folder to archive
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.build.name }}.tar
path: ${{ steps.strings.outputs.test-output-dir }}/${{ matrix.build.name }}.tar
name: test-reports-${{ matrix.build.name }}.tar
path: ${{ steps.strings.outputs.test-output-dir }}/${{ matrix.build.name }}_${{ steps.strings.outputs.job-id }}.tar

0 comments on commit c4ba51e

Please sign in to comment.