Skip to content

Commit 05540a2

Browse files
committed
chore: add trigger condition for test binaries
1 parent ea22cd6 commit 05540a2

File tree

1 file changed

+65
-10
lines changed

1 file changed

+65
-10
lines changed

.github/workflows/test-binaries.yml

Lines changed: 65 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
name: Test Binaries
22

33
on:
4-
pull_request:
5-
branches:
6-
- dev
7-
paths:
8-
- '.github/workflows/test-binaries.yml'
9-
- '.github/workflows/menlo-build.yml'
4+
workflow_run:
5+
workflows: ["CI"]
6+
types: [completed]
107
workflow_dispatch:
118
inputs:
129
version:
@@ -21,6 +18,8 @@ jobs:
2118
test-binaries:
2219
runs-on: ${{ matrix.runs-on }}
2320
timeout-minutes: 30
21+
# Only run if the triggering workflow succeeded
22+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name != 'workflow_run' }}
2423
strategy:
2524
fail-fast: false
2625
matrix:
@@ -69,6 +68,40 @@ jobs:
6968
artifact-name: "llama-win-avx2-x64"
7069

7170
steps:
71+
- name: Get version from workflow run
72+
if: github.event_name == 'workflow_run'
73+
id: get_version
74+
run: |
75+
# Extract version from the triggering workflow run
76+
# Get the tag that was created by the menlo-build workflow
77+
# The tag format is b{commit_count}
78+
echo "Getting version from workflow run..."
79+
echo "Workflow run ID: ${{ github.event.workflow_run.id }}"
80+
81+
# Get the latest tag from the repository
82+
LATEST_TAG=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
83+
"https://api.github.com/repos/${{ github.repository }}/tags" | \
84+
jq -r '.[0].name' | grep -E '^b[0-9]+$' | head -1)
85+
86+
if [ -n "$LATEST_TAG" ] && [ "$LATEST_TAG" != "null" ]; then
87+
echo "Found latest tag: $LATEST_TAG"
88+
echo "TEST_VERSION=$LATEST_TAG" >> $GITHUB_ENV
89+
echo "version=$LATEST_TAG" >> $GITHUB_OUTPUT
90+
else
91+
echo "No valid tag found, using default"
92+
echo "version=${{ env.TEST_VERSION }}" >> $GITHUB_OUTPUT
93+
fi
94+
95+
- name: Set test version
96+
id: set_version
97+
run: |
98+
if [ "${{ github.event_name }}" = "workflow_run" ] && [ -n "${{ steps.get_version.outputs.version }}" ]; then
99+
echo "TEST_VERSION=${{ steps.get_version.outputs.version }}" >> $GITHUB_ENV
100+
echo "Using version from workflow run: ${{ steps.get_version.outputs.version }}"
101+
else
102+
echo "Using default version: ${{ env.TEST_VERSION }}"
103+
fi
104+
72105
- name: Checkout
73106
uses: actions/checkout@v3
74107

@@ -84,8 +117,13 @@ jobs:
84117
85118
- name: Show testing version
86119
run: |
87-
echo "Testing hardcoded version: ${{ env.TEST_VERSION }}"
120+
echo "Testing version: ${{ env.TEST_VERSION }}"
88121
echo "This will download binaries from release: ${{ env.TEST_VERSION }}"
122+
echo "Triggered by: ${{ github.event_name }}"
123+
if [ "${{ github.event_name }}" = "workflow_run" ]; then
124+
echo "Triggering workflow run ID: ${{ github.event.workflow_run.id }}"
125+
echo "Triggering workflow conclusion: ${{ github.event.workflow_run.conclusion }}"
126+
fi
89127
90128
- name: Download release binaries (Linux/macOS)
91129
if: runner.os != 'Windows'
@@ -554,7 +592,7 @@ jobs:
554592
uses: actions/upload-artifact@v4
555593
if: always()
556594
with:
557-
name: test-results-${{ matrix.os }}-${{ matrix.name }}-${{ env.TEST_VERSION }}
595+
name: test-results-${{ matrix.os }}-${{ matrix.name }}-${{ env.TEST_VERSION }}-${{ github.run_id }}
558596
path: |
559597
response.json
560598
*.log
@@ -568,9 +606,26 @@ jobs:
568606
steps:
569607
- name: Test Summary
570608
run: |
571-
echo "## CPU Binary Test Results for ${{ env.TEST_VERSION }}" >> $GITHUB_STEP_SUMMARY
609+
# Get the actual version that was tested
610+
TESTED_VERSION="${{ env.TEST_VERSION }}"
611+
if [ "${{ github.event_name }}" = "workflow_run" ]; then
612+
# Try to get the version from the workflow run context
613+
LATEST_TAG=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
614+
"https://api.github.com/repos/${{ github.repository }}/tags" | \
615+
jq -r '.[0].name' | grep -E '^b[0-9]+$' | head -1)
616+
if [ -n "$LATEST_TAG" ] && [ "$LATEST_TAG" != "null" ]; then
617+
TESTED_VERSION="$LATEST_TAG"
618+
fi
619+
fi
620+
621+
echo "## CPU Binary Test Results for $TESTED_VERSION" >> $GITHUB_STEP_SUMMARY
572622
echo "Tested CPU-only builds (Vulkan builds excluded due to lack of GPU hardware)" >> $GITHUB_STEP_SUMMARY
573-
echo "**Version tested:** ${{ env.TEST_VERSION }}" >> $GITHUB_STEP_SUMMARY
623+
echo "**Version tested:** $TESTED_VERSION" >> $GITHUB_STEP_SUMMARY
624+
echo "**Triggered by:** ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
625+
if [ "${{ github.event_name }}" = "workflow_run" ]; then
626+
echo "**Triggering workflow:** ${{ github.event.workflow_run.name }}" >> $GITHUB_STEP_SUMMARY
627+
echo "**Triggering workflow run ID:** ${{ github.event.workflow_run.id }}" >> $GITHUB_STEP_SUMMARY
628+
fi
574629
echo "" >> $GITHUB_STEP_SUMMARY
575630
576631
if [ "${{ needs.test-binaries.result }}" = "success" ]; then

0 commit comments

Comments
 (0)