Skip to content

Commit 624be5b

Browse files
committed
Simplify by using SHA only
1 parent 267ef20 commit 624be5b

1 file changed

Lines changed: 15 additions & 31 deletions

File tree

.github/workflows/run-bench.yml

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
name: Run Bench Main
22

3-
permissions:
4-
contents: read
5-
pull-requests: read
6-
73
on:
84
workflow_dispatch:
95
inputs:
@@ -28,7 +24,6 @@ on:
2824
- '**/src/main/java/**'
2925
- 'pom.xml'
3026
- '**/pom.xml'
31-
- '.github/workflows/run-bench.yml'
3227

3328
jobs:
3429
# Job to generate the matrix configuration
@@ -46,41 +41,33 @@ jobs:
4641
4742
# Default branches based on event type
4843
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
49-
echo "Pull request detected. Using main and PR branch: ${{ github.head_ref }}"
50-
# Check if PR is from a fork
51-
if [[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]]; then
52-
echo "PR from fork detected: ${{ github.event.pull_request.head.repo.full_name }}"
53-
BRANCHES='[{"branch":"main","repository":"${{ github.repository }}"}, {"branch":"${{ github.head_ref }}","repository":"${{ github.event.pull_request.head.repo.full_name }}"}]'
54-
else
55-
echo "PR from same repository"
56-
BRANCHES='[{"branch":"main","repository":"${{ github.repository }}"}, {"branch":"${{ github.head_ref }}","repository":"${{ github.repository }}"}]'
57-
fi
44+
echo "Pull request detected. Using main and PR commit SHA: ${{ github.event.pull_request.head.sha }}"
45+
BRANCHES='["main", "${{ github.event.pull_request.head.sha }}"]'
5846
elif [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ github.event.inputs.branches }}" ]]; then
5947
# Parse space-separated branches input into JSON array
60-
# All branches from workflow_dispatch are assumed to be from the current repository
6148
echo "Workflow dispatch with branches input detected"
6249
BRANCHES_INPUT="${{ github.event.inputs.branches }}"
6350
BRANCHES="["
6451
for branch in $BRANCHES_INPUT; do
6552
if [[ "$BRANCHES" != "[" ]]; then
6653
BRANCHES="$BRANCHES, "
6754
fi
68-
BRANCHES="$BRANCHES{\"branch\":\"$branch\",\"repository\":\"${{ github.repository }}\"}"
55+
BRANCHES="$BRANCHES\"$branch\""
6956
echo "Adding branch to matrix: $branch"
7057
done
7158
BRANCHES="$BRANCHES]"
7259
else
7360
echo "Default event type. Using main branch only"
74-
BRANCHES='[{"branch":"main","repository":"${{ github.repository }}"}]'
61+
BRANCHES='["main"]'
7562
fi
7663
7764
echo "Generated branches matrix: $BRANCHES"
78-
echo "matrix={\"jdk\":[24],\"isa\":[\"isa-avx512f\"],\"ref\":$BRANCHES}" >> $GITHUB_OUTPUT
65+
echo "matrix={\"jdk\":[24],\"isa\":[\"isa-avx512f\"],\"branch\":$BRANCHES}" >> $GITHUB_OUTPUT
7966
8067
test-avx512:
8168
needs: generate-matrix
8269
concurrency:
83-
group: ${{ matrix.isa }}-${{ matrix.jdk }}-${{ matrix.ref.repository }}-${{ matrix.ref.branch }}
70+
group: ${{ matrix.isa }}-${{ matrix.jdk }}-${{ matrix.branch }}
8471
cancel-in-progress: false
8572
strategy:
8673
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
@@ -128,16 +115,15 @@ jobs:
128115
- name: Print job information
129116
run: |
130117
echo "Running benchmark for:"
131-
echo " - Branch: ${{ matrix.ref.branch }}"
118+
echo " - Branch: ${{ matrix.branch }}"
132119
echo " - JDK: ${{ matrix.jdk }}"
133120
echo " - ISA: ${{ matrix.isa }}"
134121
135122
# Checkout the branch specified in the matrix
136123
- name: Checkout branch
137124
uses: actions/checkout@v4
138125
with:
139-
repository: ${{ matrix.ref.repository }}
140-
ref: ${{ matrix.ref.branch }}
126+
ref: ${{ matrix.branch }}
141127
fetch-depth: 0
142128

143129
# ==========================================
@@ -168,14 +154,14 @@ jobs:
168154
run: |
169155
# Check if jvector-examples directory and AutoBenchYAML class exist
170156
if [ ! -d "jvector-examples" ]; then
171-
echo "Warning: jvector-examples directory not found in branch ${{ matrix.ref.branch }}. Skipping benchmark."
157+
echo "Warning: jvector-examples directory not found in branch ${{ matrix.branch }}. Skipping benchmark."
172158
exit 0
173159
fi
174160
175161
# Check if the jar with dependencies was built
176162
JAR_COUNT=$(ls jvector-examples/target/jvector-examples-*-jar-with-dependencies.jar 2>/dev/null | wc -l)
177163
if [ "$JAR_COUNT" -eq 0 ]; then
178-
echo "Warning: No jar with dependencies found in branch ${{ matrix.ref.branch }}. Skipping benchmark."
164+
echo "Warning: No jar with dependencies found in branch ${{ matrix.branch }}. Skipping benchmark."
179165
exit 0
180166
fi
181167
@@ -194,7 +180,7 @@ jobs:
194180
echo "Total memory: ${TOTAL_MEM_GB}GB, using ${HALF_MEM_GB}GB for Java heap"
195181
196182
# Run the benchmark
197-
echo "Running benchmark for branch ${{ matrix.ref.branch }}"
183+
echo "Running benchmark for branch ${{ matrix.branch }}"
198184
199185
# Determine optional benchmark config argument from workflow input
200186
BENCH_ARG="${{ github.event.inputs.benchmark_config }}"
@@ -219,11 +205,9 @@ jobs:
219205
echo "No custom configuration provided, using default autoDefault.yml"
220206
fi
221207
222-
# Sanitize branch name and repository for filenames: replace any non-alphanumeric, dash or underscore with underscore
223-
SAFE_BRANCH=$(echo "${{ matrix.ref.branch }}" | sed 's/[^A-Za-z0-9_-]/_/g')
224-
SAFE_REPO=$(echo "${{ matrix.ref.repository }}" | sed 's/[^A-Za-z0-9_-]/_/g')
208+
# Sanitize branch name for filenames: replace any non-alphanumeric, dash or underscore with underscore
209+
SAFE_BRANCH=$(echo "${{ matrix.branch }}" | sed 's/[^A-Za-z0-9_-]/_/g')
225210
echo "safe_branch=$SAFE_BRANCH" >> $GITHUB_OUTPUT
226-
echo "safe_repo=$SAFE_REPO" >> $GITHUB_OUTPUT
227211
228212
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
229213
java ${{ matrix.jdk >= 20 && '--enable-native-access=ALL-UNNAMED --add-modules=jdk.incubator.vector' || '' }} \
@@ -241,12 +225,12 @@ jobs:
241225
mv ${SAFE_BRANCH}-bench-results.csv benchmark_results/ || true
242226
mv ${SAFE_BRANCH}-bench-results.json benchmark_results/ || true
243227
244-
echo "Completed benchmarks for branch: ${{ matrix.ref.branch }}"
228+
echo "Completed benchmarks for branch: ${{ matrix.branch }}"
245229
246230
- name: Upload Individual Benchmark Results
247231
uses: actions/upload-artifact@v4
248232
with:
249-
name: benchmark-results-${{ matrix.isa }}-jdk${{ matrix.jdk }}-${{ steps.run-benchmark.outputs.safe_repo }}-${{ steps.run-benchmark.outputs.safe_branch }}
233+
name: benchmark-results-${{ matrix.isa }}-jdk${{ matrix.jdk }}-${{ steps.run-benchmark.outputs.safe_branch }}
250234
path: |
251235
benchmark_results/*.csv
252236
benchmark_results/*.json

0 commit comments

Comments
 (0)