Skip to content

Commit b5ab9c6

Browse files
dnestorovjovanov
authored andcommitted
Run parallel job for each library
1 parent 513a008 commit b5ab9c6

File tree

5 files changed

+159
-234
lines changed

5 files changed

+159
-234
lines changed
Lines changed: 104 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,70 @@
1-
name: Check new library versions for batch
1+
name: "Check new libraries versions"
22

33
on:
4-
workflow_call:
5-
inputs:
6-
items:
7-
required: true
8-
type: string
9-
batch_id:
10-
required: true
11-
type: string
124
workflow_dispatch:
13-
inputs:
14-
items:
15-
required: true
16-
description: "JSON array of batch items"
17-
type: string
18-
batch_id:
19-
required: true
20-
description: "Represents the unique id of this batch"
21-
type: string
22-
23-
permissions: write-all
5+
6+
permissions:
7+
contents: write
8+
actions: write
249

2510
concurrency:
26-
group: "workflow = ${{ github.workflow }}, batch = ${{ inputs.batch_id }}"
27-
cancel-in-progress: false
11+
group: "workflow=${{ github.workflow }},ref=${{ github.event.ref }},pr=${{ github.event.pull_request.id }}"
12+
cancel-in-progress: true
2813

2914
jobs:
30-
process-batch:
15+
get-all-libraries:
16+
name: "📋 Get list of all supported libraries with newer versions"
3117
if: github.repository == 'oracle/graalvm-reachability-metadata'
32-
name: "🧪 Processing ${{ matrix.item }}"
18+
runs-on: ubuntu-22.04
19+
timeout-minutes: 5
3320
permissions: write-all
21+
outputs:
22+
matrix: ${{ steps.set-matrix.outputs.matrix }}
23+
branch: ${{ steps.set-branch-name.outputs.branch }}
24+
steps:
25+
- name: "☁️ Checkout repository"
26+
uses: actions/checkout@v4
27+
28+
- name: "🔧 Prepare environment"
29+
uses: graalvm/setup-graalvm@v1
30+
with:
31+
java-version: '21'
32+
distribution: 'graalvm'
33+
github-token: ${{ secrets.GITHUB_TOKEN }}
34+
35+
- name: "📅 Set branch name"
36+
id: set-branch-name
37+
run: |
38+
BRANCH_NAME="check-new-library-versions/$(date '+%Y-%m-%d')"
39+
echo "branch=$BRANCH_NAME" >> $GITHUB_OUTPUT
40+
41+
- name: "🕸️ Populate matrix"
42+
id: set-matrix
43+
run: |
44+
echo "matrix=$(./gradlew fetchExistingLibrariesWithNewerVersions --matrixLimit=5000 --quiet | sed -n '/\[/,$p')" >> $GITHUB_OUTPUT
45+
46+
- name: "🔨 Create branch"
47+
run: |
48+
git config --local user.email "[email protected]"
49+
git config --local user.name "Github Actions"
50+
git checkout -b "${{ steps.set-branch-name.outputs.branch }}"
51+
git push origin "${{ steps.set-branch-name.outputs.branch }}"
52+
53+
test-all-metadata:
54+
name: "🧪 ${{ matrix.item.name }}"
3455
runs-on: ubuntu-22.04
35-
timeout-minutes: 20
56+
needs: get-all-libraries
57+
permissions: write-all
3658
env:
37-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3860
strategy:
3961
fail-fast: false
4062
matrix:
41-
item: ${{ fromJson(inputs.items) }}
63+
item: ${{ fromJson(needs.get-all-libraries.outputs.matrix) }}
4264
steps:
4365
- name: "☁️ Checkout repository"
4466
uses: actions/checkout@v4
4567

46-
- name: "Install tools"
47-
run: |
48-
sudo apt-get update
49-
sudo apt-get install -y jq
50-
5168
- name: "🔧 Setup java"
5269
uses: actions/setup-java@v4
5370
with:
@@ -64,8 +81,9 @@ jobs:
6481
native-image-job-reports: 'true'
6582

6683
- name: "Extract test path and library version"
84+
id: extract-params
6785
run: |
68-
LIBRARY_PATH=$(echo ${{ matrix.item }} | cut -d ':' -f1-2 | sed 's/:/\//g')
86+
LIBRARY_PATH=$(echo "${{ matrix.item.name }}" | sed 's/:/\//g')
6987
LATEST_VERSION=$(find tests/src/$LIBRARY_PATH/* -maxdepth 1 -type d | sort -V | tail -1 | cut -d '/' -f5)
7088
TEST_PATH="$LIBRARY_PATH/$LATEST_VERSION"
7189
TEST_COORDINATES=$(echo "$TEST_PATH" | tr / :)
@@ -75,8 +93,7 @@ jobs:
7593
echo "TEST_COORDINATES=$TEST_COORDINATES" >> ${GITHUB_ENV}
7694
7795
- name: "Pull allowed docker images"
78-
run: |
79-
./gradlew pullAllowedDockerImages --coordinates=${{ env.TEST_COORDINATES }}
96+
run: ./gradlew pullAllowedDockerImages --coordinates="${{ env.TEST_COORDINATES }}"
8097

8198
- name: "Disable docker"
8299
run: |
@@ -89,101 +106,76 @@ jobs:
89106
sudo systemctl restart docker
90107
91108
- name: "🧪 Run '${{ env.TEST_COORDINATES }}' tests"
109+
id: runtests
92110
run: |
93-
TESTING_VERSION=$(echo ${{ matrix.item }} | cut -d ":" -f3)
94-
export GVM_TCK_LV=$TESTING_VERSION
111+
bash ./.github/workflows/run-consecutive-tests.sh "${{ env.TEST_COORDINATES }}" '${{ toJson(matrix.item.versions) }}' 2>&1 | tee test_results.txt || true
112+
113+
# Extract successful versions
114+
grep "^PASSED:" test_results.txt | sed 's/PASSED://g' > successful_versions.txt
115+
echo "successful_versions<<EOF" >> $GITHUB_OUTPUT
116+
cat successful_versions.txt >> $GITHUB_OUTPUT
117+
echo "EOF" >> $GITHUB_OUTPUT
95118
96-
./gradlew test -Pcoordinates=${{ env.TEST_COORDINATES }}
119+
# Extract failed version
120+
FAILED_VERSION=$(grep "^FAILED:" test_results.txt | sed 's/FAILED://g')
121+
echo "failed_version=$FAILED_VERSION" >> $GITHUB_OUTPUT
97122
98123
- name: "✔️ New library is supported"
99-
if: success()
124+
if: steps.runtests.outputs.successful_versions != ''
100125
run: |
101-
bash ./.github/workflows/tryPushVersionsUpdate.sh ${{ matrix.item }} ${{ env.LATEST_VERSION }} ${{ inputs.batch_id }}
126+
git config --local user.email "[email protected]"
127+
git config --local user.name "Github Actions"
128+
git fetch origin ${{ needs.get-all-libraries.outputs.branch }}
129+
git checkout ${{ needs.get-all-libraries.outputs.branch }}
130+
131+
while read version; do
132+
if [ -n "$version" ]; then
133+
./gradlew addTestedVersion --coordinates="${{ matrix.item.name }}:$version" --lastSupportedVersion="${{ env.LATEST_VERSION }}"
134+
fi
135+
done < successful_versions.txt
136+
137+
git add -u
138+
git commit -m "Update tested versions for ${{ matrix.item.name }}"
139+
git push origin ${{ needs.get-all-libraries.outputs.branch }}
102140
103141
- name: "❗ New library is not supported"
104-
if: failure()
142+
if: steps.runtests.outputs.failed_version != ''
105143
run: |
106-
LIB=$(echo "${{ matrix.item }}" | sed 's/:/_/g')
107-
touch $LIB
108-
echo "UNSUPPORTED_LIB=$LIB" >> $GITHUB_ENV
109-
110-
- name: "Upload artifacts"
111-
if: failure()
112-
id: upload
113-
continue-on-error: true
114-
uses: actions/upload-artifact@v4
115-
with:
116-
name: ${{ env.UNSUPPORTED_LIB }}
117-
path: ${{ env.UNSUPPORTED_LIB }}
118-
retention-days: 1
144+
git config --local user.email "[email protected]"
145+
git config --local user.name "Github Actions"
146+
147+
FAILED_VERSION="${{ steps.runtests.outputs.failed_version }}"
148+
REPO="${{ github.repository }}"
149+
TITLE="Failure detected for ${{ matrix.item.name }}"
150+
BODY="First failing version ${{ matrix.item.name }}:$FAILED_VERSION"
151+
152+
ISSUE_NUMBER=$(gh issue list --repo "$REPO" --state open --search "$TITLE" --json number,title --jq '.[] | select(.title == "'"$TITLE"'") | .number')
153+
if [ -n "$ISSUE_NUMBER" ]; then
154+
echo "Updating existing issue #$ISSUE_NUMBER"
155+
gh issue edit "$ISSUE_NUMBER" --repo "$REPO" --body "$BODY"
156+
else
157+
echo "Creating new issue"
158+
gh issue create --repo "$REPO" --title "$TITLE" --body "$BODY"
159+
fi
119160
120161
process-results:
121162
name: "🧪 Process results"
122-
runs-on: "ubuntu-22.04"
123-
if: ${{ always() }}
124-
needs:
125-
- process-batch
163+
runs-on: ubuntu-22.04
126164
permissions: write-all
127165
env:
128-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
166+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
167+
if: ${{ always() }}
168+
needs:
169+
- get-all-libraries
170+
- test-all-metadata
129171
steps:
130172
- name: "☁️ Checkout repository"
131173
uses: actions/checkout@v4
132-
- name: "🔧 Setup java"
133-
uses: actions/setup-java@v4
134-
with:
135-
distribution: 'oracle'
136-
java-version: '21'
174+
137175
- name: "✏️ PR for supported versions"
138176
run: |
139177
git config --local user.email "[email protected]"
140178
git config --local user.name "Github Actions"
141-
git fetch origin check-new-library-versions/batch-id-${{ inputs.batch_id }}/$(date '+%Y-%m-%d')
142-
git checkout check-new-library-versions/batch-id-${{ inputs.batch_id }}/$(date '+%Y-%m-%d')
179+
git fetch origin ${{ needs.get-all-libraries.outputs.branch }}
180+
git checkout ${{ needs.get-all-libraries.outputs.branch }}
143181
gh pr create --title "Update supported library versions" --body "This pull request updates supported versions of the existing libraries in the repo"
144-
- name: "Download artifacts for unsupported versions"
145-
uses: actions/download-artifact@v4
146-
with:
147-
path: ./unsupported
148-
- name: "✏️ Issue for unsupported versions"
149-
run: |
150-
if [ -d "unsupported" ]; then
151-
152-
cd unsupported
153-
git config --local user.email "[email protected]"
154-
git config --local user.name "Github Actions"
155-
156-
# Map from <group_artifact> to list of versions
157-
declare -A failures
158-
159-
for FILENAME in *; do
160-
GROUPID=$(echo "$FILENAME" | cut -d'_' -f1)
161-
ARTIFACTID=$(echo "$FILENAME" | cut -d'_' -f2)
162-
VERSION=$(echo "$FILENAME" | cut -d'_' -f3)
163-
GA="${GROUPID}:${ARTIFACTID}"
164-
failures["$GA"]+="${VERSION}"$'\n'
165-
done
166-
167-
for GA in "${!failures[@]}"; do
168-
TITLE="Failure for $GA"
169-
EXISTING_ISSUE_URL=$(gh issue list --state "open" --search "$TITLE" --json title,url | jq -r ".[] | select(.title==\"$TITLE\") | .url")
170-
171-
BODY="${failures[$GA]}"
172-
173-
if [ -n "$EXISTING_ISSUE_URL" ]; then
174-
# issue exists, just append new failures
175-
EXISTING_BODY=$(gh issue view "$EXISTING_ISSUE_URL" --json body -q .body)
176-
177-
for VERSION in ${failures[$GA]}; do
178-
if ! grep -q "$VERSION" <<< "$EXISTING_BODY"; then
179-
EXISTING_BODY="${EXISTING_BODY}"$'\n'"$VERSION"
180-
fi
181-
done
182-
183-
gh issue edit "$EXISTING_ISSUE_URL" --body "$EXISTING_BODY"
184-
else
185-
# Create new issue with all versions
186-
gh issue create --title "$TITLE" --body "$BODY" --label library-update
187-
fi
188-
done
189-
fi

.github/workflows/new-libraries-orchestrator.yml

Lines changed: 0 additions & 66 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
# Usage: ./run-consecutive-tests.sh "<test-coordinates>" '[ "1.0", "2.0", "3.0" ]'
4+
5+
set -u
6+
set -x
7+
8+
if [ $# -ne 2 ]; then
9+
echo "Usage: $0 <test-coordinates> <versions-json-array>"
10+
exit 1
11+
fi
12+
13+
# Input parameters
14+
TEST_COORDINATES="$1"
15+
VERSIONS_JSON="$2"
16+
PASSED_VERSIONS=()
17+
FAILED_VERSION=""
18+
19+
# Parse JSON array into Bash array using jq
20+
if ! command -v jq &> /dev/null; then
21+
echo "jq is required but not installed."
22+
exit 1
23+
fi
24+
25+
# Remove surrounding single quotes if present (when called from workflow)
26+
VERSIONS_JSON="${VERSIONS_JSON#"${VERSIONS_JSON%%[!\']*}"}"
27+
VERSIONS_JSON="${VERSIONS_JSON%"${VERSIONS_JSON##*[!\']}"}"
28+
29+
# Parse versions with jq
30+
readarray -t VERSIONS < <(echo "$VERSIONS_JSON" | jq -r '.[]')
31+
32+
for VERSION in "${VERSIONS[@]}"; do
33+
echo "Running test with GVM_TCK_LV=$VERSION and coordinates=$TEST_COORDINATES"
34+
GVM_TCK_LV="$VERSION" ./gradlew test -Pcoordinates="$TEST_COORDINATES"
35+
RESULT=$?
36+
if [ "$RESULT" -eq 0 ]; then
37+
PASSED_VERSIONS+=("$VERSION")
38+
echo "PASSED:$VERSION"
39+
else
40+
FAILED_VERSION="$VERSION"
41+
echo "FAILED:$VERSION"
42+
break
43+
fi
44+
done
45+
46+
# Script ends here; output already provided in loop for workflows to process
47+
exit 0

0 commit comments

Comments
 (0)