diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index 3f0ccf3..0000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1,2 +0,0 @@ -# https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax -* @sschnabe @rpahli @fabian-schlegel @jschwarze @wistefan @monotek diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 415bfca..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: 2 -updates: - - package-ecosystem: maven - directory: / - schedule: - interval: daily - allow: - - dependency-name: io.kokuwa.maven:maven-parent - - dependency-name: org.keycloak:keycloak-quarkus-server - - package-ecosystem: github-actions - directory: / - schedule: - interval: monthly - day: monday diff --git a/.github/settings.xml b/.github/settings.xml deleted file mode 100644 index 44fd9ea..0000000 --- a/.github/settings.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - sonatype-nexus - ${env.SERVER_USERNAME} - ${env.SERVER_PASSWORD} - - - github.com - nope - ${env.GIT_ACTION_TOKEN} - - - diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index 4da10a5..0000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,50 +0,0 @@ -name: Build - -on: - push: - branches: [main] - -jobs: - - build: - runs-on: ubuntu-latest - env: - MAVEN_ARGS: --batch-mode --color=always --no-transfer-progress --settings=.github/settings.xml - steps: - - name: docker/login-action docker.io - uses: docker/login-action@v3.4.0 - with: - registry: docker.io - username: ${{ secrets.DOCKERIO_USERNAME }} - password: ${{ secrets.DOCKERIO_TOKEN }} - - name: docker/login-action ghcr.io - uses: docker/login-action@v3.4.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GIT_ACTION_TOKEN }} - - run: git config --global user.name "${{ vars.KOKUWA_IO_BOT_NAME }}" - - run: git config --global user.email "${{ vars.KOKUWA_IO_BOT_EMAIL }}" - - uses: actions/checkout@v4 - with: - token: ${{ secrets.GIT_ACTION_TOKEN }} - - uses: crazy-max/ghaction-import-gpg@v6 - with: - gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} - passphrase: ${{ secrets.GPG_PASSPHRASE }} - git_user_signingkey: true - git_commit_gpgsign: true - - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - cache: maven - server-id: sonatype-nexus - server-username: SERVER_USERNAME - server-password: SERVER_PASSWORD - gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} - gpg-passphrase: GPG_PASSPHRASE - - run: mvn $MAVEN_ARGS deploy - env: - SERVER_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }} - SERVER_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml deleted file mode 100644 index 3548e88..0000000 --- a/.github/workflows/pr.yaml +++ /dev/null @@ -1,58 +0,0 @@ -name: PullRequest - -on: pull_request - -env: - MAVEN_ARGS: --batch-mode --color=always --no-transfer-progress - -jobs: - - yaml: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ibiqlik/action-yamllint@v3 - with: - format: colored - strict: true - - markdown: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: avto-dev/markdown-lint@v1 - with: - args: /github/workspace - - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - cache: maven - - run: mvn $MAVEN_ARGS verify - - versions: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - version: - - 22.0.5 - - 23.0.7 - - 24.0.5 - - 25.0.6 - - 26.0.8 - - 26.1.5 - - 26.2.5 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - cache: maven - - run: mvn $MAVEN_ARGS verify -Dcheck.skip -Dversion.org.keycloak.test=${{ matrix.version }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index e3240ed..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,50 +0,0 @@ -name: Release - -on: workflow_dispatch - -jobs: - build: - runs-on: ubuntu-latest - env: - MAVEN_ARGS: --batch-mode --color=always --no-transfer-progress --settings=.github/settings.xml - steps: - - name: docker/login-action docker.io - uses: docker/login-action@v3.4.0 - with: - registry: docker.io - username: ${{ secrets.DOCKERIO_USERNAME }} - password: ${{ secrets.DOCKERIO_TOKEN }} - - name: docker/login-action ghcr.io - uses: docker/login-action@v3.4.0 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GIT_ACTION_TOKEN }} - - run: git config --global user.name "${{ vars.KOKUWA_IO_BOT_NAME }}" - - run: git config --global user.email "${{ vars.KOKUWA_IO_BOT_EMAIL }}" - - uses: actions/checkout@v4 - with: - token: ${{ secrets.GIT_ACTION_TOKEN }} - - uses: crazy-max/ghaction-import-gpg@v6 - with: - gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} - passphrase: ${{ secrets.GPG_PASSPHRASE }} - git_user_signingkey: true - git_commit_gpgsign: true - - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - cache: maven - server-id: sonatype-nexus - server-username: SERVER_USERNAME - server-password: SERVER_PASSWORD - gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} - gpg-passphrase: GPG_PASSPHRASE - - run: mvn $MAVEN_ARGS release:prepare -Darguments="$MAVEN_ARGS" - - run: mvn $MAVEN_ARGS release:perform -Darguments="$MAVEN_ARGS" - env: - SERVER_USERNAME: ${{ secrets.SONATYPE_NEXUS_USERNAME }} - SERVER_PASSWORD: ${{ secrets.SONATYPE_NEXUS_PASSWORD }} - GIT_ACTION_TOKEN: ${{ secrets.GIT_ACTION_TOKEN }} - GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml new file mode 100644 index 0000000..fb9f9c7 --- /dev/null +++ b/.github/workflows/verify.yaml @@ -0,0 +1,60 @@ +name: Verify + +on: + - pull_request + - push: + branches: [main] + +env: + MAVEN_ARGS: --batch-mode --color=always --no-transfer-progress + +jobs: + + renovate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - uses: docker://kokuwaio/renovate-config-validator + + markdownlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - uses: docker://kokuwaio/markdownlint + + yamllint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - uses: docker://kokuwaio/yamllint + + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + - uses: actions/setup-java@main + with: + distribution: temurin + java-version: 17 + cache: maven + - run: mvn verify + + versions: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + version: + - 22.0.5 + - 23.0.7 + - 24.0.5 + - 25.0.6 + - 26.2.5 + steps: + - uses: actions/checkout@main + - uses: actions/setup-java@main + with: + distribution: temurin + java-version: 17 + cache: maven + - run: mvn verify -Dversion.org.keycloak.test=${{ matrix.version }} diff --git a/.woodpecker/build.yaml b/.woodpecker/build.yaml new file mode 100644 index 0000000..8ee769e --- /dev/null +++ b/.woodpecker/build.yaml @@ -0,0 +1,22 @@ +when: + event: [manual, push] + branch: main + path: [.woodpecker/build.yaml, pom.xml, src/main/**] + +services: + - name: dockerd + image: kokuwaio/dockerd + ports: [2375, 8080] + +steps: + + deploy: + image: maven:3.9.9-eclipse-temurin-17 + commands: mvn deploy --settings=.woodpecker/maven/settings.xml + environment: + SONATYPE_ORG_USERNAME: {from_secret: sonatype_org_username} + SONATYPE_ORG_PASSWORD: {from_secret: sonatype_org_password} + DOCKER_IO_USERNAME: {from_secret: docker_io_username} + DOCKER_IO_PASSWORD: {from_secret: docker_io_password} + GHCR_IO_USERNAME: {from_secret: ghcr_io_username} + GHCR_IO_PASSWORD: {from_secret: ghcr_io_password} diff --git a/.woodpecker/lint.yaml b/.woodpecker/lint.yaml new file mode 100644 index 0000000..74bb114 --- /dev/null +++ b/.woodpecker/lint.yaml @@ -0,0 +1,21 @@ +when: + event: [manual, pull_request, push] + branch: main + path: [.woodpecker/lint.yaml, renovate.json, "**/*.y*ml", "**/*.md"] + +steps: + + renovate: + image: kokuwaio/renovate-config-validator + depends_on: [] + when: [path: [.woodpecker/lint.yaml, renovate.json]] + + yaml: + image: kokuwaio/yamllint + depends_on: [] + when: [path: [.woodpecker/lint.yaml, .yamllint.yaml, "**/*.y*ml"]] + + markdown: + image: kokuwaio/markdownlint + depends_on: [] + when: [path: [.woodpecker/lint.yaml, .markdownlint.yaml, "**/*.md"]] diff --git a/.woodpecker/maven/settings.xml b/.woodpecker/maven/settings.xml new file mode 100644 index 0000000..c4ae37f --- /dev/null +++ b/.woodpecker/maven/settings.xml @@ -0,0 +1,28 @@ + + + false + /woodpecker/.m2 + + + sonatype.org + ${env.SONATYPE_ORG_USERNAME} + ${env.SONATYPE_ORG_PASSWORD} + + + docker.io + ${env.DOCKER_IO_USERNAME} + ${env.DOCKER_IO_PASSWORD} + + + ghcr.io + ${env.GHCR_IO_USERNAME} + ${env.GHCR_IO_PASSWORD} + + + + + http://mirror.woodpecker.svc/maven2 + central + + + diff --git a/.woodpecker/verify.yaml b/.woodpecker/verify.yaml new file mode 100644 index 0000000..298ace2 --- /dev/null +++ b/.woodpecker/verify.yaml @@ -0,0 +1,21 @@ +when: + event: [manual, pull_request] + path: [.woodpecker/verify.yaml, pom.xml, src/**] + +matrix: + KEYCLOAK_VERSION: + - 22.0.5 + - 23.0.7 + - 24.0.5 + - 25.0.6 + - 26.2.5 + +services: + - name: dockerd + image: kokuwaio/dockerd + ports: [2375, 8080] + +steps: + verify: + image: maven:3.9.9-eclipse-temurin-17 + commands: mvn verify --settings=.woodpecker/maven/settings.xml -Dversion.org.keycloak.test=$KEYCLOAK_VERSION diff --git a/README.md b/README.md index d57d9b6..0489e31 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Keycloak Metrics -Provides metrics for Keycloak user/admin events and user/client/session count. Tested on Keycloak [22-26](.github/workflows/pr.yaml#L48-L53). +Provides metrics for Keycloak user/admin events and user/client/session count. Tested on Keycloak [22-26](.woodpecker/verify.yaml#L7-L11). [![Apache License, Version 2.0, January 2004](https://img.shields.io/github/license/kokuwaio/keycloak-event-metrics.svg?label=License)](http://www.apache.org/licenses/) [![Maven Central](https://img.shields.io/maven-central/v/io.kokuwa.keycloak/keycloak-event-metrics.svg?label=Maven%20Central)](https://central.sonatype.com/search?namespace=io.kokuwa.keycloak&q=keycloak-event-metrics) -[![Build](https://img.shields.io/github/actions/workflow/status/kokuwaio/keycloak-event-metrics/build.yaml?label=Build)](https://github.com/kokuwaio/keycloak-event-metrics/actions/workflows/build.yaml) +[![Build](https://ci.kokuwa.io/api/badges/keycloak/keycloak-event-metrics/status.svg)](https://ci.kokuwa.io/api/badges/keycloak/keycloak-event-metrics/) ## Why? @@ -114,7 +114,7 @@ If scrapping takes less than `KC_METRICS_STATS_INFO_THRESHOLD` duration will be ### Grafana Dashboard -Can be found here: [kokuwaio/keycloak keycloak-metrics.json](https://github.com/kokuwaio/keycloak/blob/main/src/test/k3s/dev/grafana/files/dashboards/keycloak-metrics.json) +Can be found here: [keycloak-metrics.json](https://git.kokuwa.io/keycloak/keycloak/blob/main/src/test/k3s/dev/grafana/files/dashboards/keycloak-metrics.json) ### Testcontainers @@ -131,7 +131,7 @@ This images are based on busybox, so you can use cp to copy the jar into your ke ### Docker -Check: [kokuwaio/keycloak](https://github.com/kokuwaio/keycloak) +Check: [kowaio/keycloak](https://git.kokuwa.io/keycloak/keycloak) Dockerfile: @@ -145,7 +145,7 @@ FROM debian:stable-slim AS metrics RUN apt-get -qq update RUN apt-get -qq install --yes --no-install-recommends ca-certificates wget -ARG METRICS_VERSION=1.0.0 +ARG METRICS_VERSION=1.1.1 ARG METRICS_FILE=keycloak-event-metrics-${METRICS_VERSION}.jar ARG METRICS_URL=https://repo1.maven.org/maven2/io/kokuwa/keycloak/keycloak-event-metrics/${METRICS_VERSION} @@ -159,7 +159,7 @@ RUN mv ${METRICS_FILE} /opt/keycloak/providers ### build keycloak with metrics ### -FROM quay.io/keycloak/keycloak:25.0.1 +FROM quay.io/keycloak/keycloak:25.2.5 ENV KEYCLOAK_ADMIN=admin ENV KEYCLOAK_ADMIN_PASSWORD=password diff --git a/pom.xml b/pom.xml index 8e26d7f..3118890 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ Keycloak Metrics Provides metrics for Keycloak user/admin events - https://github.com/kokuwaio/keycloak-event-metrics + https://git.kokuwa.io/keycloak/keycloak-event-metrics 2023 Kokuwa.io @@ -33,27 +33,23 @@ - https://github.com/kokuwaio/keycloak-event-metrics - scm:git:https://github.com/kokuwaio/keycloak-event-metrics.git - scm:git:https://github.com/kokuwaio/keycloak-event-metrics.git + https://git.kokuwa.io/keycloak/keycloak-event-metrics + https://git.kokuwa.io/keycloak/keycloak-event-metrics.git + https://git.kokuwa.io/keycloak/keycloak-event-metrics.git HEAD - github - https://github.com/kokuwaio/keycloak-event-metrics/issues + forgejo + https://git.kokuwa.io/keycloak/keycloak-event-metrics/issues - github - https://github.com/kokuwaio/keycloak-event-metrics/actions + woodpecker + https://ci.kokuwa.io/repos/keycloak/keycloak-event-metrics - - sonatype-nexus - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - sonatype-nexus - https://oss.sonatype.org/content/repositories/snapshots/ + sonatype.org + https://central.sonatype.com/repository/maven-snapshots/ @@ -97,7 +93,7 @@ 3.5.3 1.4.0 2.18.0 - 1.7.0 + 0.7.0 2.26.0 1.12.0 0.46.0 @@ -324,9 +320,9 @@ - org.sonatype.plugins - nexus-staging-maven-plugin - ${version.org.sonatype.plugins.nexus} + org.sonatype.central + central-publishing-maven-plugin + ${version.org.sonatype.central} net.revelc.code.formatter @@ -507,7 +503,20 @@ - javadoc-no-fork + jar + + + + + + + + org.apache.maven.plugins + maven-gpg-plugin + + + + sign @@ -609,32 +618,16 @@ release - - - org.apache.maven.plugins - maven-gpg-plugin - - - - sign - - - - - - - - org.sonatype.plugins - nexus-staging-maven-plugin + org.sonatype.central + central-publishing-maven-plugin true - sonatype-nexus - https://oss.sonatype.org/ - true + sonatype.org + true + published - diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..942e54b --- /dev/null +++ b/renovate.json @@ -0,0 +1,33 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "labels": ["renovate", "renovate-manager/{{{manager}}}", "renovate-type/{{{updateType}}}"], + "dependencyDashboard": true, + "dependencyDashboardLabels": ["renovate"], + "dependencyDashboardApproval": true, + "dependencyDashboardOSVVulnerabilitySummary": "all", + "separateMajorMinor": true, + "separateMinorPatch": true, + "separateMultipleMinor": true, + "separateMultipleMajor": true, + "pinDigests": true, + "automerge": false, + "automergeStrategy": "fast-forward", + "rebaseWhen": "behind-base-branch", + "packageRules": [ + { + "matchUpdateTypes": ["digest"], + "dependencyDashboardApproval": false, + "automergeType": "branch" + },{ + "matchUpdateTypes": ["patch"], + "dependencyDashboardApproval": false, + "automerge": true + },{ + "matchUpdateTypes": ["minor"], + "dependencyDashboardApproval": false + },{ + "matchManagers": ["woodpecker"], + "pinDigests": false + } + ] +} diff --git a/src/test/java/io/kokuwa/keycloak/metrics/junit/KeycloakExtension.java b/src/test/java/io/kokuwa/keycloak/metrics/junit/KeycloakExtension.java index 91f013f..820ae8b 100644 --- a/src/test/java/io/kokuwa/keycloak/metrics/junit/KeycloakExtension.java +++ b/src/test/java/io/kokuwa/keycloak/metrics/junit/KeycloakExtension.java @@ -15,6 +15,7 @@ import org.junit.jupiter.api.extension.ParameterContext; import org.junit.jupiter.api.extension.ParameterResolver; import org.keycloak.admin.client.Keycloak; import org.keycloak.admin.client.token.TokenService; +import org.testcontainers.containers.FixedHostPortGenericContainer; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.wait.strategy.Wait; import org.testcontainers.utility.MountableFile; @@ -45,28 +46,30 @@ public class KeycloakExtension implements BeforeAllCallback, ParameterResolver { throw new Exception("Failed to read properties", e); } var version = properties.getProperty("version"); + var image = "quay.io/keycloak/keycloak:" + version; var jar = properties.getProperty("jar"); var timeout = properties.getProperty("timeout"); // create and start container - @SuppressWarnings("resource") - var container = new GenericContainer<>("quay.io/keycloak/keycloak:" + version) - .withEnv("KEYCLOAK_ADMIN", "admin") - .withEnv("KEYCLOAK_ADMIN_PASSWORD", "password") - .withEnv("KC_LOG_LEVEL", "io.kokuwa:trace") - // otherwise port 9000 will be used, with this config we can test different keycloak versions - .withEnv("KC_LEGACY_OBSERVABILITY_INTERFACE", "true") - .withEnv("KC_HEALTH_ENABLED", "true") - .withEnv("KC_METRICS_ENABLED", "true") - .withEnv("KC_METRICS_STATS_ENABLED", "true") - .withEnv("KC_METRICS_STATS_INTERVAL", "PT1s") - .withCopyFileToContainer(MountableFile.forHostPath(jar), "/opt/keycloak/providers/metrics.jar") - .withLogConsumer(out -> System.out.print(out.getUtf8String())) - .withExposedPorts(8080) - .withStartupTimeout(Duration.parse(timeout)) - .waitingFor(Wait.forHttp("/health").forPort(8080)) - .withCommand("start-dev"); + @SuppressWarnings({ "resource", "deprecation" }) + var container = System.getenv("CI") == null + ? new GenericContainer<>(image).withExposedPorts(8080) + : new FixedHostPortGenericContainer<>(image).withFixedExposedPort(8080, 8080) + .withEnv("KEYCLOAK_ADMIN", "admin") + .withEnv("KEYCLOAK_ADMIN_PASSWORD", "password") + .withEnv("KC_LOG_LEVEL", "io.kokuwa:trace") + // otherwise port 9000 will be used, with this config we can test different keycloak versions + .withEnv("KC_LEGACY_OBSERVABILITY_INTERFACE", "true") + .withEnv("KC_HEALTH_ENABLED", "true") + .withEnv("KC_METRICS_ENABLED", "true") + .withEnv("KC_METRICS_STATS_ENABLED", "true") + .withEnv("KC_METRICS_STATS_INTERVAL", "PT1s") + .withCopyFileToContainer(MountableFile.forHostPath(jar), "/opt/keycloak/providers/metrics.jar") + .withLogConsumer(out -> System.out.print(out.getUtf8String())) + .withStartupTimeout(Duration.parse(timeout)) + .waitingFor(Wait.forHttp("/health").forPort(8080).withStartupTimeout(Duration.ofMinutes(10))) + .withCommand("start-dev"); try { container.start(); } catch (RuntimeException e) {