diff --git a/.github/workflows/ci.yaml b/.github/workflows/pr-ci.yaml similarity index 83% rename from .github/workflows/ci.yaml rename to .github/workflows/pr-ci.yaml index fa9e45aba..192268c2d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/pr-ci.yaml @@ -5,12 +5,6 @@ concurrency: cancel-in-progress: true on: - push: - branches: - - main - - v[0-9]+ - - v[0-9]+.[0-9]+ - - cryostat-v[0-9]+.[0-9]+ pull_request_target: types: - opened @@ -25,8 +19,10 @@ on: - cryostat-v[0-9]+.[0-9]+ env: - OPENSUSE_UNOFFICIAL_LIBCONTAINERS_KEY_URL: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04/Release.key" - OPENSUSE_UNOFFICIAL_LIBCONTAINERS_SOURCE_URL: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04" + OPENSUSE_UNOFFICIAL_LIBCONTAINERS_KEY_URL: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04/Release.key" + OPENSUSE_UNOFFICIAL_LIBCONTAINERS_SOURCE_URL: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04" + REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }} + REF: ${{ github.event.pull_request.head.ref }} jobs: build-and-test: @@ -48,8 +44,8 @@ jobs: run: exit 1 - uses: actions/checkout@v3 with: - repository: ${{ github.event.pull_request.head.repo.full_name }} - ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ env.REPOSITORY }} + ref: ${{ env.REF }} submodules: true fetch-depth: 0 - uses: actions/setup-java@v3 @@ -95,6 +91,6 @@ jobs: run: systemctl --user enable --now podman.socket - name: Set DOCKER_HOST environment variable run: echo "DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock" >> "$GITHUB_ENV" - - name: Run tests - run: ./mvnw -B -U clean verify + - name: Build application + run: ./mvnw -B -U -Dquarkus.container-image.build=false clean verify continue-on-error: ${{ matrix.java != '17' }} diff --git a/.github/workflows/push-ci.yaml b/.github/workflows/push-ci.yaml new file mode 100644 index 000000000..d0ace9eb5 --- /dev/null +++ b/.github/workflows/push-ci.yaml @@ -0,0 +1,132 @@ +name: CI build and push + +concurrency: + group: ci-${{ github.run_id }} + cancel-in-progress: true + +on: + push: + branches: + - main + - v[0-9]+ + - v[0-9]+.[0-9]+ + - cryostat-v[0-9]+.[0-9]+ + +env: + OPENSUSE_UNOFFICIAL_LIBCONTAINERS_KEY_URL: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04/Release.key" + OPENSUSE_UNOFFICIAL_LIBCONTAINERS_SOURCE_URL: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/unstable/xUbuntu_22.04" + CI_USER: cryostat+bot + CI_REGISTRY: quay.io/cryostat + CI_IMG: quay.io/cryostat/cryostat + +jobs: + get-pom-properties: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 + - id: query-pom + name: Get properties from POM + # Query POM image version and save as output parameter + run: | + IMAGE_VERSION="$(mvn -q -DforceStdout validate help:evaluate -Dexpression=quarkus.application.version)" + echo "::set-output name=image-version::$IMAGE_VERSION" + outputs: + image-version: ${{ steps.query-pom.outputs.image-version }} + + build-and-test: + runs-on: ubuntu-latest + needs: [get-pom-properties] + strategy: + matrix: + java: [ '17', '21' ] + env: + IMAGE_VERSION: ${{ needs.get-pom-properties.outputs.image-version }} + TESTCONTAINERS_RYUK_DISABLED: true + cache-name: cache-yarn + name: Build and test Java ${{ matrix.java }} + permissions: + packages: write + contents: read + if: ${{ github.repository_owner == 'cryostatio' }} + steps: + - uses: actions/checkout@v3 + with: + submodules: true + fetch-depth: 0 + - uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java }} + distribution: 'temurin' + cache: 'maven' + - name: maven-settings + uses: s4u/maven-settings-action@v2 + with: + servers: '[{"id": "github", "username": "dummy", "password": "${{ secrets.GITHUB_TOKEN }}"}]' + githubServer: false + - run: git submodule init && git submodule update + - name: Cache yarn packages + uses: actions/cache@v3 + with: + path: "./src/main/webui/.yarn/cache" + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - name: Initialize web assets + run: | + cd src/main/webui + yarn install && yarn yarn:frzinstall + cd - + - name: Install podman v4 + run: | + echo "deb $OPENSUSE_UNOFFICIAL_LIBCONTAINERS_SOURCE_URL/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:unstable.list + curl -fsSL $OPENSUSE_UNOFFICIAL_LIBCONTAINERS_KEY_URL | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/devel_kubic_libcontainers_unstable.gpg > /dev/null + sudo apt -y purge podman + sudo apt update && sudo apt -y install podman + - name: Emulate docker with podman + run: | + mkdir -p $HOME/.bin + cat <(echo '#!/usr/bin/env bash') <(echo 'exec podman "$@"') > $HOME/.bin/docker + chmod +x $HOME/.bin/docker + echo "PATH=$HOME/.bin:$PATH" >> "$GITHUB_ENV" + - name: Set up testcontainers for podman + run: echo ryuk.container.privileged=true > ~/.testcontainers.properties + - name: Start Podman API + run: systemctl --user enable --now podman.socket + - name: Set DOCKER_HOST environment variable + run: echo "DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock" >> "$GITHUB_ENV" + - name: Build application + run: ./mvnw -B -U clean verify + continue-on-error: ${{ matrix.java != '17' }} + - name: Delete local integration test image + run: | + podman rmi ${{ env.CI_IMG }}:latest ${{ env.CI_IMG }}:dev ${{ env.CI_IMG }}:${{ env.IMAGE_VERSION }} + continue-on-error: true + - name: Build container images and manifest + if: ${{ matrix.java == '17' }} && ${{ github.repository_owner == 'cryostatio' }} + id: buildah-build + uses: redhat-actions/buildah-build@v2 + with: + image: ${{ env.CI_IMG }} + archs: amd64, arm64 + # tags: ${{ env.IMAGE_VERSION }} ${{ github.ref == 'refs/heads/main' && 'latest' || '' }} + tags: ${{ env.IMAGE_VERSION }} + containerfiles: | + ./src/main/docker/Dockerfile.jvm + - name: Push to quay.io + id: push-to-quay + uses: redhat-actions/push-to-registry@v2 + with: + image: cryostat + tags: ${{ steps.buildah-build.outputs.tags }} + registry: ${{ env.CI_REGISTRY }} + username: ${{ env.CI_USER }} + password: ${{ secrets.REGISTRY_PASSWORD }} + if: ${{ matrix.java == '17' }} && ${{ github.repository_owner == 'cryostatio' }} + - name: Print image URL + run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" + if: ${{ matrix.java == '17' }} && ${{ github.repository_owner == 'cryostatio' }} diff --git a/pom.xml b/pom.xml index 1098d62d4..32d64114d 100644 --- a/pom.xml +++ b/pom.xml @@ -22,6 +22,7 @@ + ${cryostat.imageVersionLower} 17 ${java.version} ${java.version} @@ -43,6 +44,7 @@ io.quarkus.platform 3.2.4.Final 2.2.1 + 3.4.0 4.8.0 4.7.3.6 @@ -286,6 +288,28 @@ + + org.codehaus.mojo + build-helper-maven-plugin + ${org.codehaus.mojo.build.helper.plugin.version} + + + image-tag-to-lower + validate + + regex-property + + + cryostat.imageVersionLower + ^.*$ + ${project.version} + ${project.version} + true + false + + + + com.diffplug.spotless spotless-maven-plugin diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 57c1358d9..dc6991955 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -71,6 +71,8 @@ quarkus.container-image.build=true quarkus.container-image.push=false quarkus.container-image.registry=quay.io quarkus.container-image.group=cryostat -quarkus.container-image.additional-tags=latest,dev +quarkus.container-image.name=cryostat +quarkus.container-image.tag=${quarkus.application.version} +quarkus.container-image.additional-tags=dev quarkus.native.additional-build-args=--initialize-at-run-time=org.openjdk.jmc.jdp.client.JDPClient\\,io.cryostat.core.net.discovery.JvmDiscoveryClient\\,java.net.Inet4Address\\,java.net.Inet6Address diff --git a/src/test/java/itest/HealthIT.java b/src/test/java/itest/HealthIT.java index 9f55c0e0c..2ce05b69e 100644 --- a/src/test/java/itest/HealthIT.java +++ b/src/test/java/itest/HealthIT.java @@ -65,7 +65,7 @@ void shouldIncludeApplicationVersion() { response.getString("cryostatVersion"), Matchers.not(Matchers.equalTo("unknown"))); MatcherAssert.assertThat( response.getString("cryostatVersion"), - Matchers.matchesRegex("^v[\\d]\\.[\\d]\\.[\\d](?:-SNAPSHOT)?")); + Matchers.matchesRegex("^v[\\d]\\.[\\d]\\.[\\d](?:-snapshot)?")); } @Disabled("TODO")