From f67b14c9088f81f7e7b481986c7355bccd2f18b1 Mon Sep 17 00:00:00 2001 From: Okke Harsta Date: Mon, 28 Oct 2024 15:33:44 +0100 Subject: [PATCH] Jdk21 --- .github/workflows/deploy.yml | 113 +++++++++++++++++++++++++++++++++++ .github/workflows/maven.yml | 26 ++++++++ README.md | 4 +- docker/Dockerfile | 4 ++ pom.xml | 18 +++--- 5 files changed, 154 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/maven.yml create mode 100644 docker/Dockerfile diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..dd06ee5 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,113 @@ +name: Deploy + +on: + push: + tags: + - "*" + workflow_dispatch: + + +jobs: + deployment: + permissions: + packages: write + environment: deploy + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: 21 + distribution: "temurin" + server-id: openconext-releases + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + + - name: Set up cache + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Determine the version + run: echo "version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_OUTPUT + id: versioncheck + + - name: Exit when workflow_dispatch is triggered, and the version does not contain SNAPSHOT in it's name + run: | + echo "Only SNAPSHOT releases can be triggered with the workflow_dispatch" + exit 1 + if: github.event_name == 'workflow_dispatch' && ( !endsWith(steps.versioncheck.outputs.version, '-SNAPSHOT')) + + - name: Exit when a production build is triggered, and the github tag is not the same as the version in pom.xml + run: | + echo "Project version ${{ steps.versioncheck.outputs.version }} does not match git tag ${{ github.ref_name }}" + exit 1 + if: github.event_name != 'workflow_dispatch' && steps.versioncheck.outputs.version != github.ref_name + + - name: Set up JDK 21 for snapshots + uses: actions/setup-java@v4 + with: + java-version: "21" + distribution: "temurin" + cache: "maven" + server-id: openconext-snapshots + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + if: ( endsWith(steps.versioncheck.outputs.version, '-SNAPSHOT')) + + - name: Set up JDK 21 for releases + uses: actions/setup-java@v4 + with: + java-version: "21" + distribution: "temurin" + cache: "maven" + server-id: openconext-releases + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + if: ${{!( endsWith(steps.versioncheck.outputs.version, '-SNAPSHOT')) }} + + - name: Deploy with Maven + run: mvn --batch-mode deploy -DskipTests + env: + MAVEN_USERNAME: ${{ secrets.BUILD_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.BUILD_PASSWORD }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/openconext/openconext-monitoring/monitoring + flavor: | + latest=false + tags: | + type=ref,event=tag + type=raw,event=tag,value=latest + type=raw,event=workflow_dispatch,value=snapshot + type=semver,pattern={{version}},value=${{ steps.versioncheck.outputs.version }} + type=sha + + - name: Build and push the monitoring server image + uses: docker/build-push-action@v5 + with: + context: . + file: docker/Dockerfile + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..05527c3 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,26 @@ +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: CI Github + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 21 + uses: actions/setup-java@v2 + with: + java-version: '21' + distribution: 'adopt' + cache: 'maven' + - name: Build with Maven + run: mvn -B package --file pom.xml -DskipTests + - name: Codecov + uses: codecov/codecov-action@v1.3.1 diff --git a/README.md b/README.md index dc25e4b..7f3ccc2 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ OpenConext-monitoring-tests =========================== OpenConext-monitoring-tests provides a standalone Spring Boot Java application that performs tests on an OpenConext instance. -The application can performs different health check tests that can be used to monitor the availability of a OpenConext (production) instance. +The application performs different health check tests that can be used to monitor the availability of a OpenConext (production) instance. The health endpoint is available on 'http://localhost:9000/health' and is secured with username / password. @@ -40,7 +40,7 @@ PDP Installation ============ -Running the application locally requires a Java 11 VM: +Running the application locally requires a Java 21 VM: ```bash mvn clean install diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..daf2c3a --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,4 @@ +FROM eclipse-temurin:21-jdk-alpine +COPY target/*.jar app.jar +EXPOSE 8080 +ENTRYPOINT ["java","-jar","/app.jar"] diff --git a/pom.xml b/pom.xml index 3593273..4287cfe 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.openconext monitoring-tests - 7.0.1 + 8.0.0-SNAPSHOT jar monitoring-tests @@ -14,13 +14,13 @@ org.springframework.boot spring-boot-starter-parent - 2.7.6 + 2.7.18 UTF-8 - 11 + 21 @@ -76,7 +76,7 @@ org.springframework.boot spring-boot-maven-plugin - 2.6.3 + 2.7.18 pl.project13.maven @@ -86,15 +86,15 @@ org.apache.maven.plugins maven-compiler-plugin - 3.9.0 + 3.13.0 - 11 + 12 org.apache.maven.plugins maven-enforcer-plugin - 3.0.0 + 3.5.0 enforce-versions @@ -107,7 +107,7 @@ 3.8.4 - 11 + 21 @@ -119,7 +119,7 @@ org.apache.maven.wagon wagon-webdav-jackrabbit - 3.5.1 + 3.5.3