Skip to content

Commit

Permalink
Add start/end data to test and job_id to filename
Browse files Browse the repository at this point in the history
  • Loading branch information
vmilosevic committed Oct 8, 2024
1 parent 685c895 commit 3e88a40
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Build in Docker
on:
workflow_dispatch:
workflow_call:
push:

jobs:

Expand All @@ -26,12 +27,19 @@ jobs:
- /lib/modules:/lib/modules
- /opt/tt_metal_infra/provisioning/provisioning_env:/opt/tt_metal_infra/provisioning/provisioning_env
steps:

- name: Set reusable strings
id: strings
shell: bash
run: |
echo "work-dir=$(pwd)" >> "$GITHUB_OUTPUT"
echo "build-output-dir=$(pwd)/build" >> "$GITHUB_OUTPUT"
# Github job context unfortunately doesn't contain job_id, this is the workaround how to fetch it using GH API
JOB_ID=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" | \
jq -r '.jobs[] | select(.name == "${{ github.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 @@ -83,7 +91,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.build.runs-on }}
path: reports/report.xml
path: reports/report_${{ steps.strings.outputs.job-id }}.xml

- name: Show Test Report
uses: mikepenz/action-junit-report@v4
Expand Down
10 changes: 10 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import pytest
from datetime import datetime

@pytest.fixture(scope="function", autouse=True)
def record_test_timestamp(record_property):
start_timestamp = datetime.strftime(datetime.now(), "%Y-%m-%dT%H:%M:%S%z")
record_property("start_timestamp", start_timestamp)
yield
end_timestamp = datetime.strftime(datetime.now(), "%Y-%m-%dT%H:%M:%S%z")
record_property("end_timestamp", end_timestamp)

0 comments on commit 3e88a40

Please sign in to comment.