Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(version): build image as quay.io/cryostat/cryostat with lowercase version tag #144

Merged
merged 16 commits into from
Nov 7, 2023
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
20 changes: 8 additions & 12 deletions .github/workflows/ci.yaml → .github/workflows/pr-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -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' }}
132 changes: 132 additions & 0 deletions .github/workflows/push-ci.yaml
Original file line number Diff line number Diff line change
@@ -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' || '' }}
andrewazores marked this conversation as resolved.
Show resolved Hide resolved
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' }}
24 changes: 24 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
</distributionManagement>

<properties>
<quarkus.application.version>${cryostat.imageVersionLower}</quarkus.application.version>
<java.version>17</java.version>
<maven.compiler.release>${java.version}</maven.compiler.release>
<maven.compiler.source>${java.version}</maven.compiler.source>
Expand All @@ -43,6 +44,7 @@
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.2.4.Final</quarkus.platform.version>
<quarkus-quinoa.version>2.2.1</quarkus-quinoa.version>
<org.codehaus.mojo.build.helper.plugin.version>3.4.0</org.codehaus.mojo.build.helper.plugin.version>

<com.github.spotbugs.version>4.8.0</com.github.spotbugs.version>
<com.github.spotbugs.plugin.version>4.7.3.6</com.github.spotbugs.plugin.version>
Expand Down Expand Up @@ -286,6 +288,28 @@
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>${org.codehaus.mojo.build.helper.plugin.version}</version>
<executions>
<execution>
<id>image-tag-to-lower</id>
<phase>validate</phase>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>cryostat.imageVersionLower</name>
<regex>^.*$</regex>
<value>${project.version}</value>
<replacement>${project.version}</replacement>
<toLowerCase>true</toLowerCase>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/test/java/itest/HealthIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading