8000 Build Quarkus from source in quarkus-next workflow by Pepo48 · Pull Request #47892 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/actions/build-keycloak/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions .github/actions/quarkus-snapshot-cache/action.yml
Original file line number Diff line number Diff line change
@@ -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-
55 changes: 8 additions & 47 deletions .github/scripts/prepare-quarkus-next.sh
8BD0
Original file line number Diff line number Diff line change
@@ -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>$id</id> \
<name>$name</name> \
<url>$url</url> \
<snapshots> \
<enabled>true</enabled> \
<updatePolicy>daily</updatePolicy> \
</snapshots> \
<releases> \
<enabled>false</enabled> \
</releases> \
</$element>"

# 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 \
</$tag>" "$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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIU, the plain Quarkus BOM is different from the Quarkus Platform BOM, specifically it includes lower number of transitive dependencies. This might give us inaccurate results. Should we be building Platform too, not just the core Quarkus artifacts?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must use the core BOM. If it doesn't manage some deps, we would need to manage them for the snapshot scenarios manually. I don't think we should build the platform, because you can't be certain it gives you any advantage (e.g. you will probably want the latest released versions anyway). And you can never enforce that every platform dependency already adapted their main branch to the breaking changes in the core anyway (which is super edge case I guess).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember for sure how is it, but I think if you have multiple BOMs it is order dependent, so if we still had platform bom there, it would use the platform versions. anyway, @Pepo48 will give the right answer.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize the fact there are other platform participants like Operator SDK, so good point at any rate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you see why I did the switch at first place - the platform is built in a separate repo, so I didn't want to add any more complexity. I thought that the platform BOM doesn't actually override any core dependency versions - it just re-exports them and adds community extension deps on top. So for our purposes, based on my experience, testing against the core BOM vs the platform one shouldn't make a practical difference for catching breakages.

Actually, our historical data proves it as well. When it makes sense, I add "quarkus-next" label to the commit name - every single one of the issues I could filter out based on that were caused by a core Quarkus change (build step API, config, TLS, OTel, Micrometer, datasources, JOSDK version bump...). None were triggered by a platform-only dependency.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we depend on the Platform BOM with some dependencies in Keycloak (we omit explicitly defining their versions and just rely on the BOM), so I wonder how the quarkus-next build even works with the Core BOM that is missing those dependencies. Moreover, this might be a problem for the Operator, as stated correctly by Michal.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I guess the issue is that with the sed command in prepare-quarkus-next.sh I was targeting only the parent pom.xml and not operator/pom.xml too (+ the fact that the platform bom is still to this day published to Sonatype, see my earlier investigation at #47501 (comment) - https://central.sonatype.com/repository/maven-snapshots/io/quarkus/platform/quarkus-operator-sdk-bom/999-SNAPSHOT/maven-metadata.xml, but we don't know for how long).

So at this point you're right and our only viable is to build the platform from source too. Or wdyt?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I agree (or think if that is not how @Pepo48 meant it) that only building Quarkus 999-SNAPSHOT core BOM and the operator sdk bom (or downloading it from the sonatype, but then we should postpone it to after it is deployed by their nightly) should cover 99 % of scenarios. It should be good-enough only for nightly tests as platform participants shouldn't override deps managed by core. Unless we know about some other dependency managed by other platform participant.

But I don't mind either way, and building platform, apart of raising the execution time will cover all scenarios. So I'll leave it to you to decide. Thanks for your investigation.

sed -i 's|<groupId>io.quarkus.platform</groupId>|<groupId>io.quarkus</groupId>|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 "")

Expand All @@ -68,4 +29,4 @@ else
exit 1
fi
done
fi
fi
12 changes: 12 additions & 0 deletions .github/workflows/operator-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
43 changes: 41 additions & 2 deletions .github/workflows/quarkus-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"
Expand Down
Loading
0