From 78ec81ba2627ce760adffc4f71cf8aa18973fb4b Mon Sep 17 00:00:00 2001 From: Peter Zaoral Date: Wed, 8 Apr 2026 21:02:11 +0200 Subject: [PATCH] Build Quarkus from source in quarkus-next workflow Closes: #47500 Signed-off-by: Peter Zaoral --- .github/actions/build-keycloak/action.yml | 5 ++ .../actions/quarkus-snapshot-cache/action.yml | 15 +++++ .github/scripts/prepare-quarkus-next.sh | 55 +++---------------- .github/workflows/operator-ci.yml | 12 ++++ .github/workflows/quarkus-next.yml | 43 ++++++++++++++- 5 files changed, 81 insertions(+), 49 deletions(-) create mode 100644 .github/actions/quarkus-snapshot-cache/action.yml diff --git a/.github/actions/build-keycloak/action.yml b/.github/actions/build-keycloak/action.yml index 481a1f34537d..6fc635116a64 100644 --- a/.github/actions/build-keycloak/action.yml +++ b/.github/actions/build-keycloak/action.yml @@ -24,6 +24,11 @@ runs: with: create-cache-if-it-doesnt-exist: true + - id: restore-quarkus-snapshot + name: Restore Quarkus snapshot cache + if: github.ref == 'refs/heads/quarkus-next' || github.base_ref == 'quarkus-next' + uses: ./.github/actions/quarkus-snapshot-cache + - id: pnpm-store-cache name: PNPM store cache uses: ./.github/actions/pnpm-store-cache diff --git a/.github/actions/quarkus-snapshot-cache/action.yml b/.github/actions/quarkus-snapshot-cache/action.yml new file mode 100644 index 000000000000..5f390171b520 --- /dev/null +++ b/.github/actions/quarkus-snapshot-cache/action.yml @@ -0,0 +1,15 @@ +name: Quarkus Snapshot Cache +description: Restores Quarkus snapshot artifacts built from quarkusio/quarkus main branch. + +runs: + using: composite + steps: + - id: restore-quarkus-snapshot + name: Restore Quarkus snapshot cache + uses: actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + with: + path: | + ~/.m2/repository/io/quarkus + key: quarkus-snapshot- + restore-keys: | + quarkus-snapshot- diff --git a/.github/scripts/prepare-quarkus-next.sh b/.github/scripts/prepare-quarkus-next.sh index f8713d879f9c..c8560dd6d2ce 100755 --- a/.github/scripts/prepare-quarkus-next.sh +++ b/.github/scripts/prepare-quarkus-next.sh @@ -1,58 +1,19 @@ #!/usr/bin/env bash set -xeuo pipefail -add_repository() { - local file=$1 - local element=$2 - - local id="sonatype-snapshots" - local name="Sonatype Snapshots" - local url="https://central.sonatype.com/repository/maven-snapshots/" - - # Decide the tag based on the element - local tag - if [ "$element" = "repository" ]; then - tag="repositories" - elif [ "$element" = "pluginRepository" ]; then - tag="pluginRepositories" - fi - - # Repository to be inserted - local repository="<$element> \ - $id \ - $name \ - $url \ - \ - true \ - daily \ - \ - \ - false \ - \ - " - - # Check if the tag exists in the file - if grep -q "<$tag>" "$file"; then - # Insert the element before the closing tag - sed -i "/<\/$tag>/i $repository" "$file" - else - # If the tag doesn't exist, create it and insert the element - sed -i "/<\/project>/i \ - <$tag> \ - $repository \ - " "$file" - fi -} - git checkout -b new-quarkus-next origin/main -add_repository "pom.xml" "repository" -add_repository "quarkus/pom.xml" "pluginRepository" -add_repository "operator/pom.xml" "pluginRepository" +# Use io.quarkus:quarkus-bom built from source +sed -i 's|io.quarkus.platform|io.quarkus|g' pom.xml ./quarkus/set-quarkus-version.sh git commit -am "Set quarkus version to 999-SNAPSHOT" +if ! git rev-parse origin/quarkus-next &>/dev/null; then + echo "No existing quarkus-next branch, skipping cherry-pick." + exit 0 +fi + snapshot_version_hash=$(git log origin/quarkus-next --grep="Set quarkus version to 999-SNAPSHOT" --format="%H" -n 1) commits_to_cherry_pick=$(git rev-list --right-only --no-merges --reverse new-quarkus-next...origin/quarkus-next | grep -vE "$snapshot_version_hash" || echo "") @@ -68,4 +29,4 @@ else exit 1 fi done -fi \ No newline at end of file +fi diff --git a/.github/workflows/operator-ci.yml b/.github/workflows/operator-ci.yml index d5a0da83ebe1..4526d234628f 100644 --- a/.github/workflows/operator-ci.yml +++ b/.github/workflows/operator-ci.yml @@ -69,6 +69,10 @@ jobs: - name: Setup Java uses: ./.github/actions/java-setup + - name: Restore Quarkus snapshot cache + if: github.ref == 'refs/heads/quarkus-next' || github.base_ref == 'quarkus-next' + uses: ./.github/actions/quarkus-snapshot-cache + - name: Test operator running locally run: | ./mvnw install -Poperator -pl :keycloak-operator -am @@ -90,6 +94,10 @@ jobs: - name: Setup Java uses: ./.github/actions/java-setup + - name: Restore Quarkus snapshot cache + if: github.ref == 'refs/heads/quarkus-next' || github.base_ref == 'quarkus-next' + uses: ./.github/actions/quarkus-snapshot-cache + - name: Setup Minikube-Kubernetes uses: manusa/actions-setup-minikube@96202dee4ae1c2f46a62fe197273aaf22b83f42d # v2.16.1 with: @@ -138,6 +146,10 @@ jobs: - name: Setup Java uses: ./.github/actions/java-setup + - name: Restore Quarkus snapshot cache + if: github.ref == 'refs/heads/quarkus-next' || github.base_ref == 'quarkus-next' + uses: ./.github/actions/quarkus-snapshot-cache + - name: Setup Minikube-Kubernetes uses: manusa/actions-setup-minikube@96202dee4ae1c2f46a62fe197273aaf22b83f42d # v2.16.1 with: diff --git a/.github/workflows/quarkus-next.yml b/.github/workflows/quarkus-next.yml index 96f419963f9e..a44b350935fb 100644 --- a/.github/workflows/quarkus-next.yml +++ b/.github/workflows/quarkus-next.yml @@ -16,12 +16,48 @@ concurrency: permissions: contents: read - + jobs: + build-quarkus-snapshot: + name: Build Quarkus snapshot + if: github.event_name != 'schedule' || github.repository == 'keycloak/keycloak' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + repository: quarkusio/quarkus + ref: main + + # JDK 17 to match how Quarkus builds and publishes its own snapshots + - name: Setup Java + uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 + with: + distribution: temurin + java-version: 17 + + - name: Key for daily rotation of cache + id: cache-key + run: echo "date=$(date -u +%Y-%m-%d)" >> $GITHUB_OUTPUT + + - name: Quarkus snapshot cache + id: quarkus-cache + uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3 + with: + path: | + ~/.m2/repository/io/quarkus + key: quarkus-snapshot-${{ steps.cache-key.outputs.date }} + + - name: Build Quarkus snapshot + if: steps.quarkus-cache.outputs.cache-hit != 'true' + run: | + ./mvnw -B -e --no-transfer-progress \ + -Dquickly -Dno-test-modules -Prelocations \ + clean install + update-quarkus-next-branch: name: Update quarkus-next branch - if: github.event_name != 'schedule' || github.repository == 'keycloak/keycloak' runs-on: ubuntu-latest + needs: build-quarkus-snapshot permissions: contents: write # Required to push changes to the repository steps: @@ -30,6 +66,9 @@ jobs: ref: main fetch-depth: 0 + - name: Setup Java + uses: ./.github/actions/java-setup + - name: Configure Git run: | git config --global user.email "github-actions[bot]@users.noreply.github.com"