Skip to content

Commit

Permalink
Create workflow to test quickstarts with nightly keycloak/keycloak-cl…
Browse files Browse the repository at this point in the history
…ient

Closes #35439

Signed-off-by: rmartinc <[email protected]>
  • Loading branch information
rmartinc committed Nov 29, 2024
1 parent 813687f commit 1300f48
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 153 deletions.
14 changes: 8 additions & 6 deletions .github/scripts/prepare-local-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

mkdir keycloak-dist

if [[ ( -n "$GITHUB_BASE_REF" && "$GITHUB_BASE_REF" == "latest" ) ]] || [[ ( -n "$QUICKSTART_BRANCH" && "$QUICKSTART_BRANCH" != "main" ) ]]; then
VERSION=$(grep -oPm1 "(?<=<version>)[^<]+" pom.xml)
echo "Using corresponding Keycloak version: $VERSION"
URL="https://github.com/keycloak/keycloak/releases/download/${VERSION}/keycloak-${VERSION}.tar.gz"
else
echo "Downloading nightly Keycloak release"
if [ "$NIGHTLY_TEST" == "true" ]; then
# the nighly version is used
echo "Downloading Keycloak release nightly"
URL="https://github.com/keycloak/keycloak/releases/download/nightly/keycloak-999.0.0-SNAPSHOT.tar.gz"
else
# normal execution with current keycloak versions
VERSION=$(grep -oPm1 "(?<=<version.keycloak>)[^<]+" pom.xml)
echo "Downloading Keycloak release $VERSION"
URL="https://github.com/keycloak/keycloak/releases/download/${VERSION}/keycloak-${VERSION}.tar.gz"
fi

wget -q -O keycloak-dist.tar.gz "$URL"
Expand Down
11 changes: 8 additions & 3 deletions .github/scripts/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ run_tests() {
else
args="$args -Dwebdriver.chrome.driver=/usr/local/bin/chromedriver"
fi
if [ -n "$KEYCLOAK_VERSION" ]; then
args="$args -Dversion.keycloak=$KEYCLOAK_VERSION"
fi
if [ -n "$KEYCLOAK_CLIENT_VERSION" ]; then
args="$args -Dversion.keycloak.client=$KEYCLOAK_CLIENT_VERSION"
fi
args="$args -D$module"
log_file=${module////_}.log
if ! mvn clean install -Dnightly $args -B 2>&1 | tee test-logs/$log_file; then
Expand All @@ -50,10 +56,9 @@ print_failed_tests() {
fi
}

if [[ ( -n "$GITHUB_BASE_REF" && "$GITHUB_BASE_REF" == "latest" ) ]] || [[ ( -n "$QUICKSTART_BRANCH" && "$QUICKSTART_BRANCH" != "main" ) ]]; then
export KEYCLOAK_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
else
if [ "$NIGHTLY_TEST" == "true" ]; then
export KEYCLOAK_VERSION="999.0.0-SNAPSHOT"
export KEYCLOAK_CLIENT_VERSION="999.0.0-SNAPSHOT"
fi

if [ -n "$KEYCLOAK_VERSION" ]; then
Expand Down
142 changes: 3 additions & 139 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,147 +1,11 @@
name: Keycloak Integration CI

on:
on:
push:
pull_request:
workflow_dispatch:

env:
DEFAULT_JDK_VERSION: 17
DEFAULT_JDK_DIST: temurin

jobs:

tests:
name: Jakarta
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: ${{ env.DEFAULT_JDK_DIST }}
java-version: ${{ env.DEFAULT_JDK_VERSION }}
- name: Update maven settings
run: mkdir -p ~/.m2 ; cp .github/maven-settings.xml ~/.m2/

- name: Cache Maven repo
uses: actions/cache@v2
with:
path: |
~/.m2/repository
!~/.m2/repository/org/keycloak
key: cache-1-${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: cache-1-${{ runner.os }}-m2

- name: Get Keycloak
run: .github/scripts/prepare-local-server.sh

- name: Start Keycloak
run: .github/scripts/start-local-server.sh

- name: Run unit tests
run: .github/scripts/run-tests.sh jakarta

tests-spring:
name: Spring
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: ${{ env.DEFAULT_JDK_DIST }}
java-version: ${{ env.DEFAULT_JDK_VERSION }}
- name: Update maven settings
run: mkdir -p ~/.m2 ; cp .github/maven-settings.xml ~/.m2/

- name: Cache Maven repo
uses: actions/cache@v2
with:
path: |
~/.m2/repository
!~/.m2/repository/org/keycloak
key: cache-1-${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: cache-1-${{ runner.os }}-m2

- name: Get Keycloak
run: .github/scripts/prepare-local-server.sh

- name: Start Keycloak
run: .github/scripts/start-local-server.sh

- name: Run unit tests
run: .github/scripts/run-tests.sh spring

tests-nodejs:
name: Node.js
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: actions/setup-java@v3
with:
distribution: ${{ env.DEFAULT_JDK_DIST }}
java-version: ${{ env.DEFAULT_JDK_VERSION }}

- name: Get Keycloak
run: .github/scripts/prepare-local-server.sh

- name: Start Keycloak
run: .github/scripts/start-local-server.sh

- name: Run unit tests
run: .github/scripts/run-tests.sh nodejs

tests-js:
name: JavaScript
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: actions/setup-java@v3
with:
distribution: ${{ env.DEFAULT_JDK_DIST }}
java-version: ${{ env.DEFAULT_JDK_VERSION }}

- name: Get Keycloak
run: .github/scripts/prepare-local-server.sh

- name: Start Keycloak
run: .github/scripts/start-local-server.sh

- name: Run unit tests
run: .github/scripts/run-tests.sh js

tests-extension:
name: Extension
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: ${{ env.DEFAULT_JDK_DIST }}
java-version: ${{ env.DEFAULT_JDK_VERSION }}
- name: Update maven settings
run: mkdir -p ~/.m2 ; cp .github/maven-settings.xml ~/.m2/

- name: Cache Maven repo
uses: actions/cache@v2
with:
path: |
~/.m2/repository
!~/.m2/repository/org/keycloak
key: cache-1-${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: cache-1-${{ runner.os }}-m2

- name: Get Keycloak
run: .github/scripts/prepare-local-server.sh

- name: Start Keycloak
run: .github/scripts/start-local-server.sh extension

- name: Run unit tests
run: .github/scripts/run-tests.sh extension

call-ci-workflow:
uses: ./.github/workflows/workflow-ci.yml
13 changes: 13 additions & 0 deletions .github/workflows/nightly-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Keycloak Integration CI Nightly

on:
push:
pull_request:
workflow_dispatch:

jobs:

call-ci-workflow:
uses: ./.github/workflows/workflow-ci.yml
with:
nightly-test: 'true'
152 changes: 152 additions & 0 deletions .github/workflows/workflow-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
name: Reusable Keycloak Integration CI

on:
workflow_call:
inputs:
nightly-test:
description: 'if true nightly 999.0.0-SNAPSHOT version is used for keycloak and keycloak-client, otherwise the current versions in pom.xml'
default: 'false'
required: false
type: string

env:
DEFAULT_JDK_VERSION: 17
DEFAULT_JDK_DIST: temurin
NIGHTLY_TEST: ${{ inputs.nightly-test }}

jobs:

tests:
name: Jakarta
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: ${{ env.DEFAULT_JDK_DIST }}
java-version: ${{ env.DEFAULT_JDK_VERSION }}
- name: Update maven settings
run: mkdir -p ~/.m2 ; cp .github/maven-settings.xml ~/.m2/

- name: Cache Maven repo
uses: actions/cache@v2
with:
path: |
~/.m2/repository
!~/.m2/repository/org/keycloak
key: cache-1-${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: cache-1-${{ runner.os }}-m2

- name: Get Keycloak
run: .github/scripts/prepare-local-server.sh

- name: Start Keycloak
run: .github/scripts/start-local-server.sh

- name: Run unit tests
run: .github/scripts/run-tests.sh jakarta

tests-spring:
name: Spring
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: ${{ env.DEFAULT_JDK_DIST }}
java-version: ${{ env.DEFAULT_JDK_VERSION }}
- name: Update maven settings
run: mkdir -p ~/.m2 ; cp .github/maven-settings.xml ~/.m2/

- name: Cache Maven repo
uses: actions/cache@v2
with:
path: |
~/.m2/repository
!~/.m2/repository/org/keycloak
key: cache-1-${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: cache-1-${{ runner.os }}-m2

- name: Get Keycloak
run: .github/scripts/prepare-local-server.sh

- name: Start Keycloak
run: .github/scripts/start-local-server.sh

- name: Run unit tests
run: .github/scripts/run-tests.sh spring

tests-nodejs:
name: Node.js
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: actions/setup-java@v3
with:
distribution: ${{ env.DEFAULT_JDK_DIST }}
java-version: ${{ env.DEFAULT_JDK_VERSION }}

- name: Get Keycloak
run: .github/scripts/prepare-local-server.sh

- name: Start Keycloak
run: .github/scripts/start-local-server.sh

- name: Run unit tests
run: .github/scripts/run-tests.sh nodejs

tests-js:
name: JavaScript
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: actions/setup-java@v3
with:
distribution: ${{ env.DEFAULT_JDK_DIST }}
java-version: ${{ env.DEFAULT_JDK_VERSION }}

- name: Get Keycloak
run: .github/scripts/prepare-local-server.sh

- name: Start Keycloak
run: .github/scripts/start-local-server.sh

- name: Run unit tests
run: .github/scripts/run-tests.sh js

tests-extension:
name: Extension
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: ${{ env.DEFAULT_JDK_DIST }}
java-version: ${{ env.DEFAULT_JDK_VERSION }}
- name: Update maven settings
run: mkdir -p ~/.m2 ; cp .github/maven-settings.xml ~/.m2/

- name: Cache Maven repo
uses: actions/cache@v2
with:
path: |
~/.m2/repository
!~/.m2/repository/org/keycloak
key: cache-1-${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: cache-1-${{ runner.os }}-m2

- name: Get Keycloak
run: .github/scripts/prepare-local-server.sh

- name: Start Keycloak
run: .github/scripts/start-local-server.sh extension

- name: Run unit tests
run: .github/scripts/run-tests.sh extension

4 changes: 0 additions & 4 deletions jakarta/servlet-authz-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@
</license>
</licenses>

<properties>
<version.keycloak>${project.version}</version.keycloak>
</properties>

<dependencies>
<dependency>
<groupId>jakarta.servlet</groupId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@
<feature-pack>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-saml-adapter-galleon-pack</artifactId>
<version>${project.version}</version>
<version>${version.keycloak}</version>
</feature-pack>
</feature-packs>
<pluginOptions>
Expand Down

0 comments on commit 1300f48

Please sign in to comment.