Skip to content

Commit

Permalink
[CI] Move build-quarkus to separate reusable workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkak committed Jun 14, 2024
1 parent bf4b30b commit 3b92dd4
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 138 deletions.
62 changes: 13 additions & 49 deletions .github/workflows/base-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -350,57 +350,21 @@ jobs:

build-quarkus:
name: Quarkus build
runs-on: ubuntu-latest
needs:
- get-test-matrix
- build-mandrel
- build-graal
- build-vars
if: always() && (needs.build-graal.result == 'success' || needs.build-mandrel.result == 'success' || fromJson(needs.build-vars.outputs.build-from-source) == false)
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
repository: graalvm/mandrel
fetch-depth: 1
path: workflow-mandrel
- uses: actions/checkout@v4
with:
repository: ${{ inputs.quarkus-repo }}
fetch-depth: 1
ref: ${{ needs.get-test-matrix.outputs.quarkus-version }}
path: quarkus
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: base-windows-${{ needs.get-test-matrix.outputs.quarkus-version }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: base-windows-${{ needs.get-test-matrix.outputs.quarkus-version }}-maven-
- name: Change quarkus.version for Quarkus 2.2 to make mandrel-integration-test not apply quarkus_main.patch
# See https://github.com/Karm/mandrel-integration-tests/pull/64
shell: bash
run: |
if [ "${{ inputs.quarkus-version }}" == "2.2" ]
then
cd quarkus
bash ../workflow-mandrel/.github/update_quarkus_version.sh 2.2.999
fi
# Use Java 17 to build Quarkus as that's the lowest supported JDK version currently
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Build quarkus
run: |
cd quarkus
./mvnw ${COMMON_MAVEN_ARGS} -Dquickly
- name: Tar Maven Repo
shell: bash
run: tar -I 'pigz -9' -cf maven-repo.tgz -C ~ .m2/repository
- name: Persist Maven Repo
uses: actions/upload-artifact@v4
with:
name: win-maven-repo-${{ needs.get-test-matrix.outputs.artifacts-suffix }}
path: maven-repo.tgz
- name: Delete Local Artifacts From Cache
shell: bash
run: rm -r ~/.m2/repository/io/quarkus
uses: ./.github/workflows/build-quarkus.yml
with:
artifacts-suffix: ${{ needs.get-test-matrix.outputs.artifacts-suffix }}
build-from-source: ${{ fromJson(needs.build-vars.outputs.build-from-source) }}
target-os: 'windows'
quarkus-repo: ${{ inputs.quarkus-repo }}
quarkus-version: ${{ needs.get-test-matrix.outputs.quarkus-version }}

native-tests:
name: Q IT ${{ matrix.category }}
Expand Down Expand Up @@ -434,7 +398,7 @@ jobs:
- name: Download Maven Repo
uses: actions/download-artifact@v4
with:
name: win-maven-repo-${{ needs.get-test-matrix.outputs.artifacts-suffix }}
name: windows-maven-repo-${{ needs.get-test-matrix.outputs.artifacts-suffix }}
path: .
- name: Extract Maven Repo
shell: bash
Expand Down Expand Up @@ -576,7 +540,7 @@ jobs:
- name: Download Maven Repo
uses: actions/download-artifact@v4
with:
name: win-maven-repo-${{ needs.get-test-matrix.outputs.artifacts-suffix }}
name: windows-maven-repo-${{ needs.get-test-matrix.outputs.artifacts-suffix }}
path: .
- name: Extract Maven Repo
shell: bash
Expand Down
100 changes: 11 additions & 89 deletions .github/workflows/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -391,99 +391,21 @@ jobs:

build-quarkus:
name: Quarkus build
runs-on: ubuntu-latest
needs:
- get-test-matrix
- build-mandrel
- build-graal
- build-vars
if: always() && (needs.build-graal.result == 'success' || needs.build-mandrel.result == 'success' || fromJson(needs.build-vars.outputs.build-from-source) == false) || inputs.builder-image != 'null'
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
repository: graalvm/mandrel
fetch-depth: 1
path: workflow-mandrel
- uses: actions/checkout@v4
with:
repository: ${{ inputs.quarkus-repo }}
fetch-depth: 1
ref: ${{ needs.get-test-matrix.outputs.quarkus-version }}
path: ${{ env.QUARKUS_PATH }}
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-${{ needs.get-test-matrix.outputs.quarkus-version }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-${{ needs.get-test-matrix.outputs.quarkus-version }}-maven-
- name: Change quarkus.version for Quarkus 2.2 to make mandrel-integration-test not apply quarkus_main.patch
# See https://github.com/Karm/mandrel-integration-tests/pull/64
run: |
if [ "${{ inputs.quarkus-version }}" == "2.2" ]
then
cd quarkus
bash ../workflow-mandrel/.github/update_quarkus_version.sh 2.2.999
fi
# Use Java 17 to build Quarkus as that's the lowest supported JDK version currently
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Download GraalVM Maven Repo
if: ${{ fromJson(needs.build-vars.outputs.build-from-source) == true && inputs.builder-image == 'null' && needs.build-vars.outputs.maven-deploy-local != ''}}
uses: actions/download-artifact@v4
with:
name: org-graalvm-artefacts-${{ needs.get-test-matrix.outputs.artifacts-suffix }}
path: .
- name: Download GraalVM Maven Version
if: ${{ fromJson(needs.build-vars.outputs.build-from-source) == true && inputs.builder-image == 'null' && needs.build-vars.outputs.maven-deploy-local != ''}}
uses: actions/download-artifact@v4
with:
name: mandrel-maven-version-${{ needs.get-test-matrix.outputs.artifacts-suffix }}
path: .
- name: Extract GraalVM Maven Repo and GraalVM Maven Version
if: ${{ fromJson(needs.build-vars.outputs.build-from-source) == true && inputs.builder-image == 'null' && needs.build-vars.outputs.maven-deploy-local != ''}}
shell: bash
run: |
tar -xzvf graalvm-maven-artefacts.tgz -C ~
tar -xzvf graalvm-version.tgz -C $(dirname ${MANDREL_HOME})
- name: Build quarkus with local graalvm version
if: ${{ fromJson(needs.build-vars.outputs.build-from-source) == true && inputs.builder-image == 'null' && needs.build-vars.outputs.maven-deploy-local != ''}}
run: |
rm -f maven_graalvm_before_build.txt maven_graalvm_after_build.txt
find ~/.m2/repository/org/graalvm | sort > maven_graalvm_before_build.txt
GRAAL_MVN_ARTIFACTS_VERS=$(cat ${MANDREL_HOME}/.maven-version)
echo "Building quarkus with locally installed GraalVM maven artefacts in version: ${GRAAL_MVN_ARTIFACTS_VERS}"
cd ${QUARKUS_PATH}
./mvnw -e -B --settings ${QUARKUS_PATH}/.github/mvn-settings.xml -Dquickly -Dgraal-sdk.version="${GRAAL_MVN_ARTIFACTS_VERS}"
cd -
find ~/.m2/repository/org/graalvm | sort > maven_graalvm_after_build.txt
diff -u maven_graalvm_before_build.txt maven_graalvm_after_build.txt
- name: Build quarkus with default graalvm version
if: ${{ fromJson(needs.build-vars.outputs.build-from-source) == false || inputs.builder-image != 'null' || needs.build-vars.outputs.maven-deploy-local == ''}}
run: |
cd ${QUARKUS_PATH}
./mvnw -e -B --settings ${QUARKUS_PATH}/.github/mvn-settings.xml -Dquickly
cd -
- name: Tar Maven Repo
shell: bash
run: |
tar -czvf maven-repo.tgz -C ~ .m2/repository
- name: Persist Maven Repo
uses: actions/upload-artifact@v4
with:
name: maven-repo-${{ needs.get-test-matrix.outputs.artifacts-suffix }}
path: maven-repo.tgz
- name: Delete Local Quarkus Artifacts From Cache
shell: bash
run: |
rm -r ~/.m2/repository/io/quarkus
- name: Delete Local GraalVM Artifacts From Cache
if: ${{ fromJson(needs.build-vars.outputs.build-from-source) == true && inputs.builder-image == 'null' && needs.build-vars.outputs.maven-deploy-local != ''}}
shell: bash
run: |
rm -rf ~/.m2/repository/org/graalvm
uses: ./.github/workflows/build-quarkus.yml
with:
artifacts-suffix: ${{ needs.get-test-matrix.outputs.artifacts-suffix }}
build-from-source: ${{ fromJson(needs.build-vars.outputs.build-from-source) }}
builder-image: ${{ inputs.builder-image }}
maven-deploy-local: ${{ needs.build-vars.outputs.maven-deploy-local }}
target-os: 'linux'
quarkus-repo: ${{ inputs.quarkus-repo }}
quarkus-version: ${{ needs.get-test-matrix.outputs.quarkus-version }}

native-tests:
name: Q IT ${{ matrix.category }}
Expand Down Expand Up @@ -513,7 +435,7 @@ jobs:
- name: Download Maven Repo
uses: actions/download-artifact@v4
with:
name: maven-repo-${{ needs.get-test-matrix.outputs.artifacts-suffix }}
name: linux-maven-repo-${{ needs.get-test-matrix.outputs.artifacts-suffix }}
path: .
- name: Extract Maven Repo
shell: bash
Expand Down Expand Up @@ -667,7 +589,7 @@ jobs:
- name: Download Maven Repo
uses: actions/download-artifact@v4
with:
name: maven-repo-${{ needs.get-test-matrix.outputs.artifacts-suffix }}
name: linux-maven-repo-${{ needs.get-test-matrix.outputs.artifacts-suffix }}
path: .
- name: Extract Maven Repo
run: tar -xzvf maven-repo.tgz -C ~
Expand Down
135 changes: 135 additions & 0 deletions .github/workflows/build-quarkus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
name: Build Quarkus

on:
workflow_call:
inputs:
artifacts-suffix:
type: string
description: 'The maven repo artifact suffix to use'
default: "null"
build-from-source:
type: boolean
description: 'Build from source or use a release'
default: true
builder-image:
type: string
description: 'The builder image to use instead of a release or building from source (e.g. quay.io/quarkus/ubi-quarkus-mandrel:20.3-java11)'
default: "null"
maven-deploy-local:
type: string
description: 'Build flag controlling whether to deploy maven artifacts locally'
default: ""
target-os:
type: string
description: 'The operating system we are building for (linux or windows)'
default: "linux"
quarkus-repo:
type: string
description: 'The Quarkus repository to be used'
default: 'quarkusio/quarkus'
quarkus-version:
type: string
description: 'Quarkus version to test (branch, tag, commit, or "latest")'
# "latest" is replaced by the latest release available in maven
default: "main"
# Builder image can't be tested on Windows due to https://github.com/actions/virtual-environments/issues/1143
# builder-image:
# description: 'The builder image to use instead of a release or building from source (e.g. quay.io/quarkus/ubi-quarkus-mandrel:20.3-java11)'
# default: "null"

env:
QUARKUS_PATH: quarkus
COMMON_MAVEN_ARGS: "-e -B --settings .github/mvn-settings.xml --fail-at-end"
MANDREL_HOME: ${{ github.workspace }}/mandrelvm

jobs:
build-quarkus:
name: Quarkus build
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
repository: graalvm/mandrel
fetch-depth: 1
path: workflow-mandrel
- uses: actions/checkout@v4
with:
repository: ${{ inputs.quarkus-repo }}
fetch-depth: 1
ref: ${{ inputs.quarkus-version }}
path: ${{ env.QUARKUS_PATH }}
- uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ inputs.target-os }}-${{ inputs.quarkus-version }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ inputs.target-os }}-${{ inputs.quarkus-version }}-maven-
- name: Change quarkus.version for Quarkus 2.2 to make mandrel-integration-test not apply quarkus_main.patch
# See https://github.com/Karm/mandrel-integration-tests/pull/64
run: |
if [ "${{ inputs.quarkus-version }}" == "2.2" ]
then
cd quarkus
bash ../workflow-mandrel/.github/update_quarkus_version.sh 2.2.999
fi
# Use Java 17 to build Quarkus as that's the lowest supported JDK version currently
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: Download GraalVM Maven Repo
if: ${{ inputs.build-from-source == true && inputs.builder-image == 'null' && inputs.maven-deploy-local != ''}}
uses: actions/download-artifact@v4
with:
name: org-graalvm-artefacts-${{ inputs.artifacts-suffix }}
path: .
- name: Download GraalVM Maven Version
if: ${{ inputs.build-from-source == true && inputs.builder-image == 'null' && inputs.maven-deploy-local != ''}}
uses: actions/download-artifact@v4
with:
name: mandrel-maven-version-${{ inputs.artifacts-suffix }}
path: .
- name: Extract GraalVM Maven Repo and GraalVM Maven Version
if: ${{ inputs.build-from-source == true && inputs.builder-image == 'null' && inputs.maven-deploy-local != ''}}
run: |
tar -xzvf graalvm-maven-artefacts.tgz -C ~
tar -xzvf graalvm-version.tgz -C $(dirname ${MANDREL_HOME})
- name: Build quarkus with local graalvm version
if: ${{ inputs.build-from-source == true && inputs.builder-image == 'null' && inputs.maven-deploy-local != ''}}
run: |
rm -f maven_graalvm_before_build.txt maven_graalvm_after_build.txt
find ~/.m2/repository/org/graalvm | sort > maven_graalvm_before_build.txt
GRAAL_MVN_ARTIFACTS_VERS=$(cat ${MANDREL_HOME}/.maven-version)
echo "Building quarkus with locally installed GraalVM maven artefacts in version: ${GRAAL_MVN_ARTIFACTS_VERS}"
cd ${QUARKUS_PATH}
./mvnw ${COMMON_MAVEN_ARGS} -Dquickly -Dgraal-sdk.version="${GRAAL_MVN_ARTIFACTS_VERS}"
cd -
find ~/.m2/repository/org/graalvm | sort > maven_graalvm_after_build.txt
diff -u maven_graalvm_before_build.txt maven_graalvm_after_build.txt
- name: Build quarkus with default graalvm version
if: ${{ inputs.build-from-source == false || inputs.builder-image != 'null' || inputs.maven-deploy-local == ''}}
run: |
cd ${QUARKUS_PATH}
./mvnw ${COMMON_MAVEN_ARGS} -Dquickly
cd -
- name: Tar Maven Repo
if: inputs.target-os != 'windows'
run: |
tar -czvf maven-repo.tgz -C ~ .m2/repository
- name: Tar Maven Repo (windows)
if: inputs.target-os == 'windows'
run: |
tar -I 'pigz -9' -cf maven-repo.tgz -C ~ .m2/repository
- name: Persist Maven Repo
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.target-os }}-maven-repo-${{ inputs.artifacts-suffix }}
path: maven-repo.tgz
- name: Delete Local Quarkus Artifacts From Cache
run: |
rm -r ~/.m2/repository/io/quarkus
- name: Delete Local GraalVM Artifacts From Cache
if: ${{ inputs.build-from-source == true && inputs.builder-image == 'null' && inputs.maven-deploy-local != ''}}
run: |
rm -rf ~/.m2/repository/org/graalvm

0 comments on commit 3b92dd4

Please sign in to comment.