diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5db1d6c..8a4cded 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,8 +6,37 @@ on: workflow_dispatch: { } jobs: - build-hotspot: - uses: "./.github/workflows/build-hotspot.yml" - secrets: "inherit" # for Docker image publication + build_variables: + name: "Set build variables" + runs-on: "ubuntu-latest" + outputs: + build_image: "${{ steps.build_variables.outputs.build_image }}" + build_version: "${{ steps.build_variables.outputs.build_version }}" + steps: + - id: "build_variables" + run: | + set -euo pipefail + BUILD_IMAGE="$(echo "ghcr.io/$GITHUB_REPOSITORY" | tr '[:upper:]' '[:lower:]')" + BUILD_VERSION="git-$(date +'%Y%m%d%H%M')-$(git rev-parse --short HEAD)" + 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.build_image }}" + BUILD_REVISION: "${{ needs.build_variables.build_version }}" + + graal: + name: "GraalVM AOT" + needs: [ "build_variables", "hotspot" ] + uses: "./.github/workflows/graal.yml" + secrets: "inherit" with: JDK_VERSION: "23" + BUILD_IMAGE: "${{ needs.build_variables.build_image }}" + BUILD_REVISION: "${{ needs.build_variables.build_version }}" diff --git a/.github/workflows/graal.yml b/.github/workflows/graal.yml new file mode 100644 index 0000000..8d9055e --- /dev/null +++ b/.github/workflows/graal.yml @@ -0,0 +1,39 @@ +on: + workflow_call: + inputs: + JDK_VERSION: + type: string + description: "JDK version to use for build" + required: true + BUILD_IMAGE: + type: string + description: "Build image" + required: true + BUILD_REVISION: + type: string + description: "Build revision" + required: true + +jobs: + build: + runs-on: "ubuntu-latest" + container: "ghcr.io/mangadex-pub/jdk-maven:${{ inputs.JDK_VERSION }}-graal" + steps: + - name: "Checkout repository" + uses: "actions/checkout@v4" + - name: "Cache local Maven repository" + uses: "actions/cache@v4" + with: + path: "~/.m2/repository" + key: "${{ runner.os }}-graal-${{ inputs.JDK_VERSION }}-${{ hashFiles('pom.xml') }}" + restore-keys: | + ${{ runner.os }}-graal-${{ inputs.JDK_VERSION }}- + - name: "Build and test" + run: | + set -euo pipefail + mvn -Pnative -B -e -fae --show-version -Drevision="${{ inputs.BUILD_REVISION }}" -DskipTests package + - name: "Archive executable" + uses: "actions/upload-artifact@v4" + with: + name: "mcw-glibc" + path: "target/mcw" diff --git a/.github/workflows/build-hotspot.yml b/.github/workflows/hotspot.yml similarity index 63% rename from .github/workflows/build-hotspot.yml rename to .github/workflows/hotspot.yml index dbe8fd2..0cee39f 100644 --- a/.github/workflows/build-hotspot.yml +++ b/.github/workflows/hotspot.yml @@ -1,18 +1,21 @@ on: workflow_call: inputs: - JDK_VENDOR: - type: string - description: "JDK vendor to use for build" - required: false - default: "corretto" JDK_VERSION: type: string description: "JDK version to use for build" required: true + BUILD_IMAGE: + type: string + description: "Build image" + required: true + BUILD_REVISION: + type: string + description: "Build revision" + required: true jobs: - build-test: + build: runs-on: "ubuntu-latest" steps: - name: "Checkout repository" @@ -20,20 +23,19 @@ jobs: - name: "Set up JDK" uses: "actions/setup-java@v4" with: - distribution: "${{ inputs.JDK_VENDOR }}" + distribution: "corretto" java-version: "${{ inputs.JDK_VERSION }}" - name: "Cache local Maven repository" uses: "actions/cache@v4" with: path: "~/.m2/repository" - key: "${{ runner.os }}-hotspot-maven-${{ inputs.JDK_VERSION }}-${{ hashFiles('pom.xml') }}" + key: "${{ runner.os }}-hotspot-${{ inputs.JDK_VERSION }}-${{ hashFiles('pom.xml') }}" restore-keys: | - ${{ runner.os }}-hotspot-maven-${{ inputs.JDK_VERSION }}- + ${{ runner.os }}-hotspot-${{ inputs.JDK_VERSION }}- - name: "Build and test" run: | set -euo pipefail - export VERSION="git-$(date +'%Y%m%d%H%M')-$(git rev-parse --short HEAD)" - mvn -B -e -fae --show-version -T$(nproc)C -Drevision="$VERSION" -DsurefireTmpDir="$(pwd)/.github/tmpdir" verify package + mvn -B -e -fae --show-version -Drevision="${{ inputs.BUILD_REVISION }}" -DsurefireTmpDir="$(pwd)/.github/tmpdir" verify package awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, " instructions covered"; print 100*covered/instructions, "% covered" }' target/site/jacoco/jacoco.csv - name: "Archive jarfile" uses: "actions/upload-artifact@v4"