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

ci(multiarch): improve build times #581

Merged
merged 19 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from 14 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
1 change: 1 addition & 0 deletions .dockerignore.builder
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
!target/*-runner.jar
!target/lib/*
!target/quarkus-app/*
!target/quinoa
42 changes: 16 additions & 26 deletions .github/workflows/pr-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,10 @@ jobs:
needs: [checkout-branch]
# runs-on: ubuntu-latest
runs-on: ubuntu-24.04
strategy:
matrix:
# java: [ '17', '21' ]
java: ['17']
env:
cache-name: cache-yarn
name: Build and test Java ${{ matrix.java }}
deps-cache-name: cache-yarn
build-cache-name: cache-webpack
name: Build and test
permissions:
packages: write
contents: read
Expand All @@ -113,17 +110,26 @@ jobs:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- 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') }}
key: ${{ runner.os }}-build-${{ env.deps-cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-${{ env.deps-cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache frontend build
uses: actions/cache@v3
with:
path: "./src/main/webui/.build_cache"
key: ${{ runner.os }}-build-${{ env.build-cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.build-cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Initialize web assets
Expand All @@ -144,7 +150,6 @@ jobs:
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: Add workflow result as comment on PR
uses: actions/github-script@v6
Expand All @@ -154,8 +159,7 @@ jobs:
const name = '${{github.workflow}}';
const url = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}';
const success = '${{ job.status }}' === 'success';
const javaVersion = '${{matrix.java}}';
const body = `${name}: ${success ? 'All tests pass ✅' : 'At least one test failed ❌'} (JDK${javaVersion})\n${url}`;
const body = `${name}: ${success ? 'All tests pass ✅' : 'At least one test failed ❌'}\n${url}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
Expand Down Expand Up @@ -192,20 +196,6 @@ jobs:
distribution: 'temurin'
cache: 'maven'
- 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: Update schemas
id: schema-update
run: |
Expand Down
29 changes: 16 additions & 13 deletions .github/workflows/push-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,11 @@ jobs:
# runs-on: ubuntu-latest
runs-on: ubuntu-24.04
needs: [get-pom-properties]
strategy:
matrix:
# java: [ '17', '21' ]
java: ['17']
env:
IMAGE_VERSION: ${{ needs.get-pom-properties.outputs.image-version }}
cache-name: cache-yarn
name: Build and test Java ${{ matrix.java }}
deps-cache-name: cache-yarn
build-cache-name: cache-webpack
name: Build and test
permissions:
packages: write
contents: read
Expand All @@ -64,17 +61,26 @@ jobs:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- 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') }}
key: ${{ runner.os }}-build-${{ env.deps-cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-${{ env.deps-cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache frontend build
uses: actions/cache@v3
with:
path: "./src/main/webui/.build_cache"
key: ${{ runner.os }}-build-${{ env.build-cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.build-cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Initialize web assets
Expand All @@ -95,17 +101,16 @@ jobs:
run: echo "DOCKER_HOST=unix:///run/user/$(id -u)/podman/podman.sock" >> "$GITHUB_ENV"
- name: Build application
run: ./mvnw -B -U -Dquarkus.container-image.additional-tags= clean verify
continue-on-error: ${{ matrix.java != '17' }}
- name: Delete local integration test image
run: podman rmi ${{ 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 }}
oci: true
layers: true
archs: amd64, arm64
tags: ${{ env.IMAGE_VERSION }} ${{ github.ref == 'refs/heads/main' && 'latest' || '' }}
extra-args: |
Expand All @@ -123,7 +128,5 @@ jobs:
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' }}
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>jmc-libs</id>
<name>Adoptium JDK Mission Control Core Libraries</name>
<url>https://adoptium.jfrog.io/artifactory/jmc-libs</url>
<layout>default</layout>
</repository>
</repositories>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion schema/update.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
DIR="$(dirname "$(readlink -f "$0")")"

"${DIR}"/../mvnw -f "${DIR}/../pom.xml" -B -U clean compile test-compile
"${DIR}"/../mvnw -f "${DIR}/../pom.xml" -B -U -DskipTests -Dspotless.check.skip -Dquarkus.smallrye-openapi.info-title="Cryostat API" clean quarkus:dev &
"${DIR}"/../mvnw -f "${DIR}/../pom.xml" -B -U -Dmaven.test.skip -Dquarkus.quinoa=false -Dspotless.check.skip -Dquarkus.smallrye-openapi.info-title="Cryostat API" clean quarkus:dev &
pid="$!"
function cleanup() {
kill $pid
Expand Down
4 changes: 3 additions & 1 deletion src/main/docker/Dockerfile.builder
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ USER root
WORKDIR /tmp/build
COPY .mvn/ .mvn
COPY pom.xml mvnw .
RUN --mount=type=cache,target=/root/.m2 ./mvnw -B -U dependency:go-offline
COPY src/main/java src/main/java
COPY src/main/resources src/main/resources
COPY src/main/webui src/main/webui
COPY src/main/docker/include src/main/docker/include
RUN ./mvnw -Dmaven.repo.local=/tmp/build/m2/repository -B -U -Dmaven.test.skip=true -Dlicense.skip=true -Dspotless.check.skip=true -Dquarkus.container-image.build=false -Dbuild.arch=$TARGETARCH package
COPY target target
RUN --mount=type=cache,target=/root/.m2 ./mvnw -B -Dmaven.test.skip=true -Dlicense.skip=true -Dspotless.check.skip=true -Dquarkus.container-image.build=false -Dbuild.arch=$TARGETARCH package

FROM registry.access.redhat.com/ubi8/openjdk-17-runtime:1.20-3.1721231685

Expand Down
Loading