Skip to content

Commit

Permalink
Use a single workflow with a reusable maven build action
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan971 committed Jan 11, 2025
1 parent a9f17d8 commit d5aca76
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 112 deletions.
36 changes: 36 additions & 0 deletions .github/actions/maven-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "HotSpot Build"

inputs:
BUILD_REVISION:
description: "Canonical build revision for this execution"
required: true
MAVEN_JOB_ARGS:
description: "Maven arguments to add"
required: true

runs:
using: composite
steps:
- name: "Checkout repository"
uses: "actions/checkout@v4"
- name: "Cache local Maven repository"
uses: "actions/cache@v4"
with:
path: "~/.m2/repository"
key: "${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('pom.xml') }}"
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-
- name: "Build and test"
shell: "/bin/bash"
run: |
set -euo pipefail
mvn -B -e -fae --show-version \
-Dmaven.repo.local="$HOME/.m2/repository" \
-DsurefireTmpDir="$(pwd)/.github/tmpdir" \
-Drevision="${{ inputs.BUILD_REVISION }}" \
${{ inputs.MAVEN_JOB_ARGS }}
if [ -f "target/jacoco/jacoco.csv" ]; then
awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, " instructions covered"; print 100*covered/instructions, "% covered" }' target/site/jacoco/jacoco.csv
fi
59 changes: 40 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ on:
paths-ignore: [ "README.md" ]
workflow_dispatch: { }

env:
JAVA_VERSION: "23"

jobs:
build_variables:
set_variables:
name: "Set build variables"
runs-on: "ubuntu-latest"
outputs:
Expand All @@ -21,22 +24,40 @@ jobs:
echo "build_image=$BUILD_IMAGE" | tee -a "$GITHUB_OUTPUT"
echo "build_version=$BUILD_VERSION" | tee -a "$GITHUB_OUTPUT"
hotspot:
name: "HotSpot JIT"
needs: "build_variables"
uses: "./.github/workflows/hotspot.yml"
secrets: "inherit"
with:
JDK_VERSION: "23"
BUILD_IMAGE: "${{ needs.build_variables.outputs.build_image }}"
BUILD_REVISION: "${{ needs.build_variables.outputs.build_version }}"
build_hotspot:
name: "HotSpot"
runs-on: "ubuntu-latest"
needs: [ "set_variables" ]
container:
image: "ghcr.io/mangadex-pub/jdk-maven:${{ env.JAVA_VERSION }}-corretto"
options: "--user root" # this is sad, but Github CI is (once again) very silly
steps:
- name: "Maven Build (JIT)"
uses: "./.github/actions/maven-build.yml"
with:
BUILD_REVISION: "${{ needs.build_variables.outputs.build_version }}"
MAVEN_JOB_ARGS: "verify package"
- name: "Archive jarfile"
uses: "actions/upload-artifact@v4"
with:
name: "mcw.jar"
path: "target/mcw.jar"

graal:
name: "GraalVM AOT"
needs: [ "build_variables", "hotspot" ]
uses: "./.github/workflows/graal.yml"
secrets: "inherit"
with:
JDK_VERSION: "23"
BUILD_IMAGE: "${{ needs.build_variables.outputs.build_image }}"
BUILD_REVISION: "${{ needs.build_variables.outputs.build_version }}"
build_graal:
name: "GraalVM"
runs-on: "ubuntu-latest"
needs: [ "set_variables", "build_hotspot" ]
container:
image: "ghcr.io/mangadex-pub/jdk-maven:${{ env.JAVA_VERSION }}-graal"
options: "--user root" # this is sad, but Github CI is (once again) very silly
steps:
- name: "Maven Build (AOT)"
uses: "./.github/actions/maven-build.yml"
with:
BUILD_REVISION: "${{ needs.build_variables.outputs.build_version }}"
MAVEN_JOB_ARGS: "package -Pnative -DskipTests"
- name: "Archive binary"
uses: "actions/upload-artifact@v4"
with:
name: "mcw-${{ runner.os }}-${{ runner.arch }}"
path: "target/mcw"
41 changes: 0 additions & 41 deletions .github/workflows/graal.yml

This file was deleted.

44 changes: 0 additions & 44 deletions .github/workflows/hotspot.yml

This file was deleted.

14 changes: 6 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
FROM ghcr.io/mangadex-pub/jdk-maven:23-corretto AS hotspot-corretto
FROM amazoncorretto:23-headless AS hotspot

USER root
RUN mkdir -pv /opt/mcw
COPY target/mcw.jar /opt/mcw/mcw.jar
RUN mkdir -pv /opt/mcw/bin
COPY target/mcw.jar /opt/mcw/bin/mcw.jar

USER mangadex
RUN java -jar /opt/mcw/mcw.jar --version
RUN java -jar /opt/mcw/bin/mcw.jar --version

FROM ghcr.io/mangadex-pub/containers-base/rockylinux:9 AS aot-glibc
FROM ghcr.io/mangadex-pub/containers-base/rockylinux:9 AS graal

USER root
RUN mkdir -pv /opt/mcw
RUN mkdir -pv /opt/mcw/bin
COPY target/mcw /opt/mcw/mcw

USER mangadex
RUN /opt/mcw/mcw --version

0 comments on commit d5aca76

Please sign in to comment.