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
68 changes: 68 additions & 0 deletions .github/actions/setup-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: 'Setup Build Environment'
description: 'Sets up JDK(s), Maven Develocity, and optionally SoftHSM'
inputs:
java-version-tests:
description: 'The primary/test Java version'
required: false
default: '17'
distribution:
description: 'JDK distribution to use'
required: false
default: 'zulu'
java-version-maven:
description: 'The Java version used to execute Maven'
required: false
default: '17'
develocity-access-key:
description: 'Develocity access key'
required: false
setup-softhsm:
description: 'Whether to set up SoftHSM'
required: false
default: 'true'

runs:
using: 'composite'
steps:

- name: Set up JDK ${{ inputs.java-version-tests }} (Runs Tests)
if: ${{ inputs.java-version != inputs.java-version-maven }}
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: ${{ inputs.distribution }}
java-version: ${{ inputs.java-version-tests }}
cache: 'maven'
check-latest: true

- name: Set up JDK ${{ inputs.java-version-maven }} (Runs Maven)
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
distribution: ${{ inputs.distribution }}
java-version: ${{ inputs.java-version-maven }}
cache: 'maven'
check-latest: true

- name: Set up OSS Community Develocity Instance for Maven
uses: gradle/develocity-actions/setup-maven@974e8dbcbda40db6828fc35f349c80a7c0e71529 #v2.1
with:
develocity-access-key: ${{ inputs.develocity-access-key }}

- name: Install softhsm2
if: ${{ inputs.setup-softhsm == 'true' }}
run: sudo apt-get install -y softhsm2
shell: bash

- name: Install opensc
if: ${{ inputs.setup-softhsm == 'true' }}
run: sudo apt-get install -y opensc
shell: bash

- name: Ensure SoftHSM user configuration
if: ${{ inputs.setup-softhsm == 'true' }}
run: impl/src/test/scripts/softhsm configure
shell: bash

- name: Populate SoftHSM with JJWT test keys
if: ${{ inputs.setup-softhsm == 'true' }}
run: impl/src/test/scripts/softhsm import
shell: bash
153 changes: 31 additions & 122 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: CI

on:
workflow_dispatch:
workflow_dispatch:
pull_request: # all pull requests
push:
branches:
Expand All @@ -11,151 +11,60 @@ env:
MVN_CMD: ./mvnw --no-transfer-progress -B

jobs:
oracle:
strategy:
matrix:
java: [ '17' ]
build:
runs-on: 'ubuntu-latest'
name: jdk-${{ matrix.java }}-oracle
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4.7.0
with:
distribution: oracle
java-version: ${{ matrix.java }}
- name: Set up OSS Community Develocity Instance for Maven
uses: gradle/develocity-actions/setup-maven@v2.1
with:
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- name: Install softhsm2
run: sudo apt-get install -y softhsm2
- name: Install opensc
run: sudo apt-get install -y opensc
- name: Ensure SoftHSM user configuration
run: impl/src/test/scripts/softhsm configure
- name: Populate SoftHSM with JJWT test keys
run: impl/src/test/scripts/softhsm import
- name: Build
# run a full build, just as we would for a release (i.e. the `ossrh` profile), but don't use gpg
# to sign artifacts, since we don't want to mess with storing signing credentials in CI:
run: ${{env.MVN_CMD}} verify -Possrh -Dgpg.skip=true

temurin:
strategy:
fail-fast: false
matrix:
java: [ '8', '11', '17', '18' ]
runs-on: 'ubuntu-latest'
name: jdk-${{ matrix.java }}-temurin
distribution: [ 'oracle', 'temurin', 'zulu', 'corretto', 'semeru' ]
java-version: [ 8, 11, 17, 21, 25 ]
# Oracle only provides JDK 17+, so exclude earlier versions:
exclude:
- distribution: 'oracle'
java-version: 8
- distribution: 'oracle'
java-version: 11
name: jdk-${{ matrix.java-version }}-${{ matrix.distribution }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'maven'
check-latest: true
- name: Set up OSS Community Develocity Instance for Maven
uses: gradle/develocity-actions/setup-maven@v2.1
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Setup Build Environment
uses: ./.github/actions/setup-build
with:
java-version-tests: ${{ matrix.java-version }}
distribution: ${{ matrix.distribution }}
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- name: Install softhsm2
run: sudo apt-get install -y softhsm2
- name: Install opensc
run: sudo apt-get install -y opensc
- name: Ensure SoftHSM user configuration
run: impl/src/test/scripts/softhsm configure
- name: Populate SoftHSM with JJWT test keys
run: impl/src/test/scripts/softhsm import
- name: Build
# run a full build, just as we would for a release (i.e. the `ossrh` profile), but don't use gpg
# to sign artifacts, since we don't want to mess with storing signing credentials in CI:
run: ${{env.MVN_CMD}} verify -Possrh -Dgpg.skip=true

zulu:
strategy:
matrix:
java: [ '7', '8', '9', '11', '12', '13', '14', '15', '16', '17', '18', '21' ]
runs-on: 'ubuntu-latest'
env:
JDK_MAJOR_VERSION: ${{ matrix.java }}
name: jdk-${{ matrix.java }}-zulu
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: 'zulu'
cache: 'maven'
check-latest: true
- name: Set up OSS Community Develocity Instance for Maven
uses: gradle/develocity-actions/setup-maven@v2.1
with:
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- name: Install softhsm2
run: sudo apt-get install -y softhsm2
- name: Install opensc
run: sudo apt-get install -y opensc
- name: Ensure SoftHSM user configuration
run: impl/src/test/scripts/softhsm configure
- name: Populate SoftHSM with JJWT test keys
run: impl/src/test/scripts/softhsm import
- name: Build
# run a full build, just as we would for a release (i.e. the `ossrh` profile), but don't use gpg
# to sign artifacts, since we don't want to mess with storing signing credentials in CI:
run: |
if [ "$JDK_MAJOR_VERSION" == "7" ]; then export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"; fi
${{env.MVN_CMD}} verify -Possrh -Dgpg.skip=true
run: ${{env.MVN_CMD}} verify -Possrh -Dgpg.skip=true -Dtest.jdk.version=${{ matrix.java-version }}

# ensure all of our files have the correct/updated license header
license-check:
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: 0 # avoid license plugin history warnings (plus it needs full history)
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '8'
cache: 'maven'
check-latest: true
- name: Set up OSS Community Develocity Instance for Maven
uses: gradle/develocity-actions/setup-maven@v2.1
fetch-depth: 0
- name: Setup Build Environment
uses: ./.github/actions/setup-build
with:
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
setup-softhsm: 'false'
- name: License Check
# This adds about 1 minute to any build, which is why we don't want to do it on every other build:
run: |
${{env.MVN_CMD}} license:check
# This adds about 1 minute to any build, which is why we don't want to do it on every build:
run: ${{env.MVN_CMD}} license:check

code-coverage:
needs: [oracle, temurin, zulu]
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
cache: 'maven'
check-latest: true
- name: Set up OSS Community Develocity Instance for Maven
uses: gradle/develocity-actions/setup-maven@v2.1
- name: Checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
- name: Setup Build Environment
uses: ./.github/actions/setup-build
with:
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- name: Install softhsm2
run: sudo apt-get install -y softhsm2
- name: Install opensc
run: sudo apt-get install -y opensc
- name: Ensure SoftHSM user configuration
run: impl/src/test/scripts/softhsm configure
- name: Populate SoftHSM with JJWT test keys
run: impl/src/test/scripts/softhsm import
- name: Code Coverage
# run a full build, just as we would for a release (i.e. the `ossrh` profile), but don't use gpg
# to sign artifacts, since we don't want to mess with storing signing credentials in CI:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,8 @@ class JcaTemplateTest {
template.generatePrivate(new X509EncodedKeySpec(invalid))
fail()
} catch (SecurityException expected) {
boolean jdk11OrLater = Classes.isAvailable('java.security.interfaces.XECPrivateKey')
String msg = 'KeyFactory callback execution failed: key spec not recognized'
if (jdk11OrLater) {
msg = 'KeyFactory callback execution failed: Only PKCS8EncodedKeySpec and XECPrivateKeySpec supported'
}
assertEquals msg, expected.getMessage()
String msg = expected.getMessage()
assertTrue msg, msg.startsWith('KeyFactory callback execution failed:')
}
}

Expand Down
63 changes: 63 additions & 0 deletions install-test-jdks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
# install-test-jdks.sh
#
# Installs all JDK versions needed to run the full multi-JDK test matrix locally via SDKMAN,
# then generates ~/.m2/toolchains.xml from the discovered JDKs.
#
# Usage:
# ./install-test-jdks.sh
#
# After running this script, activate each profile you want to test against, e.g.:
# ./mvnw verify -P jdk-8,jdk-11,jdk-21,jdk-25
#
# The build JDK must be JDK 17+. If you are not already on JDK 17:
# sdk use java <17.x.x-tem>

set -euo pipefail

# ============================================================
# JDK versions to install.
# Update these when new patch releases are available.
# Find current versions with: sdk list java
#
# NOTE: Temurin does not provide JDK 8 on all platforms (e.g.
# macOS/ARM). Zulu is used for JDK 8 as a reliable fallback.
# ============================================================
JDKS=(
"8.0.492-zulu" # JDK 8 - minimum supported runtime
"11.0.31-tem" # JDK 11
"17.0.19-tem" # JDK 17 - required build JDK
"21.0.11-tem" # JDK 21
"25.0.3-tem" # JDK 25
)
# ============================================================

if ! command -v sdk &>/dev/null; then
echo "ERROR: SDKMAN not found. Install it from https://sdkman.io" >&2
exit 1
fi

# Source SDKMAN so 'sdk' commands work in this script
# shellcheck disable=SC1090
source "${SDKMAN_DIR:-$HOME/.sdkman}/bin/sdkman-init.sh"

echo "Installing test JDKs via SDKMAN..."
echo "(Already-installed versions will be skipped)"
echo

for jdk in "${JDKS[@]}"; do
sdk install java "$jdk" || true
done

echo
echo "Done. Generating ~/.m2/toolchains.xml from discovered JDKs..."
./mvnw --no-transfer-progress -q \
org.apache.maven.plugins:maven-toolchains-plugin:3.2.0:generate-jdk-toolchains-xml \
-Dtoolchain.file="${HOME}/.m2/toolchains.xml"

echo
echo "To run the full multi-JDK test matrix:"
echo " ./mvnw verify -P jdk-8,jdk-11,jdk-17,jdk-21,jdk-25"
echo
echo "To run a single JDK profile (e.g., JDK 8 only):"
echo " ./mvnw verify -P jdk-8"
Loading
Loading