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 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
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
2 changes: 1 addition & 1 deletion .github/workflows/ci-code-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- uses: skjolber/maven-cache-github-action@v1
with:
step: restore
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
Expand Down
84 changes: 37 additions & 47 deletions .github/workflows/pr-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ jobs:
&& (!contains(github.event.issue.labels.*.name, 'safe-to-test') || github.event.issue.user.name != github.event.comment.user.name)
run: exit 1
- name: React to comment
uses: actions/github-script@v4
uses: actions/github-script@v7
with:
script: |
const {owner, repo} = context.issue
github.reactions.createForIssueComment({
github.rest.reactions.createForIssueComment({
owner,
repo,
comment_id: context.payload.comment.id,
Expand All @@ -57,11 +57,11 @@ jobs:
permissions:
pull-requests: read
steps:
- uses: actions/github-script@v4
- uses: actions/github-script@v7
id: comment-branch
with:
script: |
const result = await github.pulls.get ({
const result = await github.rest.pulls.get ({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
Expand All @@ -75,7 +75,7 @@ jobs:
pull-requests: write
steps:
- name: Leave Actions Run Comment
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: |
const runURL = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${{ github.run_id }}`;
Expand All @@ -92,38 +92,44 @@ 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
pull-requests: write
statuses: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: ${{ needs.checkout-branch.outputs.PR_repo }}
ref: ${{ needs.checkout-branch.outputs.PR_head_ref }}
submodules: true
fetch-depth: 0
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
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
uses: actions/cache@v4
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.deps-cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache frontend build
uses: actions/cache@v4
with:
path: "./src/main/webui/.build_cache"
key: ${{ runner.os }}-build-${{ env.build-cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-${{ env.build-cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Initialize web assets
Expand All @@ -144,18 +150,16 @@ 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
uses: actions/github-script@v7
if: always()
with:
script: |
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 All @@ -180,32 +184,18 @@ jobs:
GRAPHQL_STATUS: ${{ steps.schema-update.outputs.graphql_status }}
GRAPHQL_DIFF_FILE: ${{ steps.schema-update.outputs.graphql_diff_file }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
repository: ${{ needs.checkout-branch.outputs.PR_repo }}
ref: ${{ needs.checkout-branch.outputs.PR_head_ref }}
submodules: true
fetch-depth: 0
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
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') }}
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 All @@ -222,11 +212,11 @@ jobs:
git diff -U10 --exit-code /home/runner/work/cryostat/cryostat/schema/schema.graphql > /home/runner/work/graphql.diff
echo "graphql_status=$?" >> "$GITHUB_OUTPUT"
echo "graphql_diff_file=graphql.diff" >> "$GITHUB_OUTPUT"
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: openapi-diff
path: /home/runner/work/openapi.diff
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: graphql-diff
path: /home/runner/work/graphql.diff
Expand All @@ -237,11 +227,11 @@ jobs:
permissions:
pull-requests: write
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: openapi-diff
- name: Comment schema check result
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: |
const diffFmt = s => {
Expand All @@ -263,11 +253,11 @@ jobs:
permissions:
pull-requests: write
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: graphql-diff
- name: Comment schema check result
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: |
const diffFmt = s => {
Expand All @@ -289,7 +279,7 @@ jobs:
if: needs.update-schemas.outputs.OPENAPI_STATUS != '0' || needs.update-schemas.outputs.GRAPHQL_STATUS != '0'
steps:
- name: Check out PR branch
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ needs.checkout-branch.outputs.PR_repo }}
ref: ${{ needs.checkout-branch.outputs.PR_head_ref }}
Expand All @@ -303,12 +293,12 @@ jobs:
git_user_signingkey: true
git_commit_gpgsign: true
- name: Download OpenAPI diff
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: openapi-diff
path: diffs
- name: Download GraphQL diff
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: graphql-diff
path: diffs
Expand All @@ -332,7 +322,7 @@ jobs:
git commit -S -m "chore(schema): automatic update"
git push origin ${{ needs.checkout-branch.outputs.PR_head_ref }}
- name: Comment on schema update
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: |
const prNumber = ${{ needs.checkout-branch.outputs.PR_num }};
Expand Down
37 changes: 20 additions & 17 deletions .github/workflows/push-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
get-pom-properties:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
Expand All @@ -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 @@ -58,23 +55,32 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
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
uses: actions/cache@v4
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@v4
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