Merge pull request #3820 from kubernetes-client/dependabot/maven/com.… #5236
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build a Java project with Maven | |
# For more information see: https://docs.github.com/actions/automating-builds-and-tests/building-and-testing-java-with-maven | |
name: build | |
on: | |
push: | |
branches: [ "master", "master-java8", "release-**" ] | |
pull_request: | |
branches: [ "master", "master-java8", "release-**" ] | |
jobs: | |
verify-format: | |
runs-on: ubuntu-latest | |
name: Verify Source Format | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 11 | |
- name: Verify Format and License | |
run: ./mvnw spotless:check | |
build: | |
name: Java ${{ matrix.java }} Maven Test on ${{ matrix.os }} | |
strategy: | |
matrix: | |
java: [ 11.0.x, 17.0.x, 21.0.x ] | |
os: [ macos-latest, windows-latest, ubuntu-latest ] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: ${{ matrix.java }} | |
- name: Cache local Maven repository | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ matrix.java }}-${{ hashFiles('pom.xml', '**/pom.xml') }} | |
- name: Build with Maven | |
shell: bash | |
run: | | |
if [ $(grep -E '^(8|11)\.' <<< '${{ matrix.java }}') ]; then | |
# some module doesn't compile on java platform lower than 17, need to skip them by specifying a profile | |
MODS_OVERRIDES='-pl !spring,!spring-aot' | |
EXCLUDED_EXAMPLE_MODULES=`ls examples | grep examples | xargs -I {} echo '!examples/{}' | tr '\n' ',' | sed 's/.$//'` | |
MODS_OVERRIDES=$MODS_OVERRIDES,$EXCLUDED_EXAMPLE_MODULES | |
fi | |
./mvnw -q -B --define=org.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn $MODS_OVERRIDES clean test | |
build-graalvm: | |
runs-on: ubuntu-latest | |
name: GraalVM Maven Test | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: graalvm/setup-graalvm@v1 | |
with: | |
version: '22.3.0' | |
java-version: '17' | |
components: 'native-image' | |
- name: Build with Maven | |
run: ./mvnw -q test -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn | |
e2e: | |
runs-on: ubuntu-latest | |
name: End-to-End Test Against Real Cluster | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create k8s Kind Cluster | |
uses: helm/[email protected] | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 17.0.x | |
- name: Run E2E with Maven | |
run: | | |
./mvnw clean install \ | |
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ | |
-q \ | |
-Dmaven.test.skip=true | |
cd e2e | |
../mvnw test \ | |
-B \ | |
-De2e.skip=false \ | |
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn | |
env: | |
mvnw: ${{ github.workspace }}/mvnw | |
examples: | |
runs-on: ubuntu-latest | |
name: Examples smoke test | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: 17.0.x | |
- name: Cache local Maven repository | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Build with Maven | |
run: | | |
./mvnw clean install \ | |
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ | |
-q \ | |
-Dmaven.test.skip=true | |
- name: Build Cert Manager Contrib | |
run: | | |
cd client-java-contrib/cert-manager | |
../../mvnw clean install \ | |
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ | |
-q \ | |
-Dmaven.test.skip=true | |
- name: Build Prometheus Contrib | |
run: | | |
cd client-java-contrib/prometheus-operator | |
../../mvnw clean install \ | |
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \ | |
-q \ | |
-Dmaven.test.skip=true | |
- name: Examples | |
run: | | |
for d in $(find examples* -maxdepth 1 -type d) | |
do | |
${MVNW} clean install -Dmaven.test.skip=true -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn | |
done | |
env: | |
MVNW: ${{ github.workspace }}/mvnw | |
codegen: | |
runs-on: ubuntu-latest | |
services: | |
registry: | |
image: registry:2 | |
ports: | |
- 5000:5000 | |
name: CRD Java Models Code Generation | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Publish to Registry | |
uses: elgohr/Publish-Docker-Github-Action@v5 | |
with: | |
name: kubernetes-client/java/crd-model-gen | |
tags: gh-action-tmp | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
registry: docker.pkg.github.com | |
workdir: client-java-contrib | |
no_push: true | |
- name: Run Code-gen for Cert-Manager | |
working-directory: ${{ github.workspace }}/client-java-contrib/cert-manager | |
run: IMAGE_TAG=gh-action-tmp ./update.sh | |
- name: Run Code-gen for Prometheus-Operator | |
working-directory: ${{ github.workspace }}/client-java-contrib/prometheus-operator | |
run: IMAGE_TAG=gh-action-tmp ./update.sh | |