Skip to content

Commit

Permalink
Make the CI more modular to allow for testing also against CXF and also
Browse files Browse the repository at this point in the history
against branches other than main
  • Loading branch information
ppalaga committed Nov 20, 2024
1 parent 33356d9 commit 3c8d91a
Show file tree
Hide file tree
Showing 7 changed files with 197 additions and 139 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
name: build-and-run-jvm-tests
description: 'Build the project and run JVM tests'
name: build-and-test
description: 'Build the project and run tests, optionally also native tests'

inputs:
java-version:
description: 'Java version'
required: true

run-native-tests:
description: 'If true, the native tests will be run, otherwise only JVM tests will be run'
required: true
default: false
upload-antora-site:
description: 'If true, the Antora documentation site will be zipped and uploaded to the workflow run storage; otherwise it will not be uploaded'
required: true
default: false

runs:
using: 'composite'
steps:
Expand All @@ -22,18 +30,19 @@ runs:
./mvnw cq:sync-versions -Dcq.simpleElementWhitespace=AUTODETECT_PREFER_SPACE -N -ntp
[[ -z $(git status --porcelain | grep -v antora.yml) ]] || { echo 'There are uncommitted changes'; git status; git diff; exit 1; }
- name: mvn -B formatter:validate install
- name: mvn -B formatter:validate install ${{ inputs.run-native-tests && '-Pnative -Dquarkus.native.container-build' || '' }}
shell: bash
run: ./mvnw -B formatter:validate install -fae -ntp
run: ./mvnw -B formatter:validate install ${{ inputs.run-native-tests && '-Pnative -Dquarkus.native.container-build' || '' }} -fae -ntp

# Same as the previous but only JVM tests and different default ConduitFactory
- name: QUARKUS_CXF_DEFAULT_HTTP_CONDUIT_FACTORY=URLConnectionHTTPConduitFactory mvn -B test
- name: QUARKUS_CXF_DEFAULT_HTTP_CONDUIT_FACTORY=URLConnectionHTTPConduitFactory mvn clean install ${{ inputs.run-native-tests && '-Pnative -Dquarkus.native.container-build' || '' }}
shell: bash
env:
QUARKUS_CXF_DEFAULT_HTTP_CONDUIT_FACTORY: URLConnectionHTTPConduitFactory
run: ./mvnw -B clean install -fae -ntp
run: ./mvnw -B clean install ${{ inputs.run-native-tests && '-Pnative -Dquarkus.native.container-build' || '' }} -fae -ntp

- name: 'Upload generated Antora docs site'
if: ${{ inputs.upload-antora-site }}
uses: actions/upload-artifact@v4
with:
name: docs
Expand Down
116 changes: 116 additions & 0 deletions .github/actions/build-integration-branch/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: build-integration-branch
description: 'Build and test an integration branch such as quarkus-main, quarkus-3.15, cxf-main or cxf-4.0 against Quarkus or CXF freshly built from the respective maintenance branch'

inputs:
java-version:
description: 'Java version'
required: true
base-branch:
description: "The name of the branch in our git repository, such as main or 3.15, on top of which the given integration branch, such as quarkus-main, quarkus-3.15, cxf-main or cxf-4.0, should be rebased"
required: true
default: main
integration-branch:
description: "The name of the integration branch in our git repository, such as quarkus-main or quarkus-3.15, which should be rebased on top of the given base branch"
required: true
default: main
dependency-git-repo-url:
description: "The URL of the dependency's git repository to checkout and build from"
required: true
dependency-short-name:
description: "The short lower case name of the dependency as quarkus or cxf"
required: true
dependency-branch:
description: "The name of the dependency branch in the dependency git repository to build and test against, such as main or 3.15 for Quarkus or main or 4.0.x-fixes for CXF"
required: true
default: main
issue-id:
description: "The issue number where to report any rebase or build issues"
required: true
token:
description: "The token to use to authenticate against GitHub API"
required: true

runs:
using: 'composite'
steps:

- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: rebase-integration-branch
uses: ./.github/actions/rebase-integration-branch
id: rebase-integration-branch
with:
java-version: ${{ inputs.java-version }}
base-branch: ${{ inputs.base-branch }}
integration-branch: ${{ inputs.integration-branch }}
dependency-git-repo-url: ${{ inputs.dependency-git-repo-url }}
dependency-short-name: ${{ inputs.dependency-short-name }}
dependency-branch: ${{ inputs.dependency-branch }}
issue-id: ${{ inputs.issue-id }}
token: "${{ inputs.token }}"

- name: Show steps.rebase-integration-branch.outputs.exit-status
if: ${{ !cancelled() }}
shell: bash
run: |
echo "steps.rebuild-dependency.outputs.exit-status: ${{ steps.rebase-integration-branch.outputs.exit-status }}"
- name: build-and-test
uses: ./.github/actions/build-and-test
with:
java-version: ${{ inputs.java-version }}
run-native-tests: true
upload-antora-site: false

- name: git push origin ${{ inputs.dependency-integration-branch }} -f
shell: bash
run: |
lastCommitMessage="$(git log -1 --pretty=%B)"
echo "Comparing last commit message '$lastCommitMessage' with '${{ steps.rebase-integration-branch.outputs.upgrade-message }}'"
if [[ "$lastCommitMessage" == "${{ steps.rebase-integration-branch.outputs.upgrade-message }}" ]]; then
echo "Removing last commit '$lastCommitMessage'"
git reset --hard HEAD~1
else
echo "Not removing the last commit because its message is not '${{ steps.rebase-integration-branch.outputs.upgrade-message }}' but '$lastCommitMessage'"
fi
git push origin ${{ inputs.dependency-integration-branch }} -f
- name: Reopen issue https://github.com/${{ github.repository }}/issues/${{ inputs.issue-id }}
if: ${{ steps.rebase-integration-branch.outputs.exit-status != 'success' && failure() }}
shell: bash
run: |
oldState=$(gh issue view ${{ inputs.issue-id }} --json state -q .state -R ${{ github.repository }})
echo "oldState = $oldState"
msg="❌ Build with ${{ inputs.dependency-short-name }} ${{ steps.rebase-integration-branch.outputs.dependency-commit }} failed in ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
if [[ "$oldState" == "OPEN" ]] ; then
gh issue comment \
--repo ${{ github.repository }} \
--body "$msg" \
${{ inputs.issue-id }}
else
gh issue reopen \
--repo ${{ github.repository }} \
--comment "$msg" \
${{ inputs.issue-id }}
fi
env:
GH_TOKEN: ${{ inputs.token }}

- name: Close issue https://github.com/${{ github.repository }}/issues/${{ inputs.issue-id }}
if: ${{ success() }}
shell: bash
run: |
oldState=$(gh issue view ${{ inputs.issue-id }} --json state -q .state -R ${{ github.repository }})
echo "oldState = $oldState"
msg="✅ Build with ${{ inputs.dependency-short-name }} ${{ steps.rebase-integration-branch.outputs.dependency-commit }} succeeded in ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
if [[ "$oldState" != "CLOSED" ]] ; then
gh issue close \
--repo ${{ github.repository }} \
--comment "$msg" \
${{ inputs.issue-id }}
fi
env:
GH_TOKEN: ${{ inputs.token }}

Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
name: rebase-dependency-main-branch
description: 'Rebase a maintenenance branch such as quarkus-main or cxf-main, rebuild it and report the status in a dedicated issue'
name: rebase-integration-branch
description: 'Rebase an integration branch such as quarkus-main, quarkus-3.15, cxf-main or cxf-4.0, rebuild it and report the status in a dedicated issue'

inputs:
java-version:
description: 'Java version'
required: true
base-branch:
description: "The name of the branch in our git repository, such as main or 3.15, on top of which the given integration branch, such as quarkus-main, quarkus-3.15, cxf-main or cxf-4.0, should be rebased"
required: true
default: main
integration-branch:
description: "The name of the integration branch in our git repository, such as quarkus-main or quarkus-3.15, which should be rebased on top of the given base branch"
required: true
default: main
dependency-git-repo-url:
description: "The URL of the dependency's git repository to checkout and build from"
required: true
dependency-short-name:
description: "The short lower case name of the dependency as quarkus or cxf"
required: true
dependency-branch:
description: "The name of the dependency branch to build against, such as main or 3.15"
description: "The name of the dependency branch in the dependency git repository to build and test against, such as main or 3.15 for Quarkus or main or 4.0.x-fixes for CXF"
required: true
default: main
issue-id:
Expand All @@ -39,7 +47,7 @@ outputs:
* success
* rebase-failed
* dependency-build-failed
value: ${{ env.REBASE_DEPENDENCY_MAIN_EXIT_STATUS }}
value: ${{ steps.rebase.outputs.exit-status != 'success' && steps.rebase.outputs.exit-status || steps.rebuild-dependency.outputs.exit-status }}

runs:
using: 'composite'
Expand All @@ -55,30 +63,30 @@ runs:
with:
fetch-depth: 0

- name: rebase ${{ inputs.dependency-short-name }}-${{ inputs.dependency-branch }}
- name: rebase ${{ inputs.integration-branch }}
id: rebase
shell: bash
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
echo "REBASE_DEPENDENCY_MAIN_EXIT_STATUS=success" >> $GITHUB_ENV
git fetch origin ${{ inputs.dependency-short-name }}-${{ inputs.dependency-branch }} \
&& git checkout ${{ inputs.dependency-short-name }}-${{ inputs.dependency-branch }} >/dev/null 2>&1 \
|| git checkout -b ${{ inputs.dependency-short-name }}-${{ inputs.dependency-branch }} origin/${{ github.head_ref || github.ref_name }}
git fetch origin ${{ inputs.integration-branch }} \
&& git checkout ${{ inputs.integration-branch }} >/dev/null 2>&1 \
|| git checkout -b ${{ inputs.integration-branch }} origin/${{ inputs.base-branch }}
git status
echo "${{ inputs.dependency-short-name }}-${{ github.head_ref || github.ref_name }} is at $(git rev-parse HEAD)"
git rebase ${{ github.head_ref || github.ref_name }}
echo "${{ inputs.integration-branch }} is at $(git rev-parse HEAD)"
git rebase ${{ inputs.base-branch }}
rebaseExitCode=$?
echo "rebaseExitCode = $rebaseExitCode"
echo "exit-status=$( [[ $rebaseExitCode == 0 ]] && echo 'success' || echo 'rebase-failed' )" >> $GITHUB_OUTPUT
exit $rebaseExitCode
- name: Reopen or comment on issue https://github.com/${{ github.repository }}/issues/${{ inputs.issue-id }}
if: ${{ failure() }}
shell: bash
run: |
echo "REBASE_DEPENDENCY_MAIN_EXIT_STATUS=rebase-failed" >> $GITHUB_ENV
oldState=$(gh issue view ${{ inputs.issue-id }} --json state -q .state -R ${{ github.repository }})
echo "oldState = $oldState"
msg="❌ Could not rebase ${{ inputs.dependency-short-name }}-${{ github.head_ref || github.ref_name }} in ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
msg="❌ Could not rebase ${{ inputs.integration-branch }} on top of ${{ inputs.base-branch }}}} in ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
if [[ "$oldState" == "OPEN" ]] ; then
gh issue comment \
--repo ${{ github.repository }} \
Expand All @@ -104,16 +112,11 @@ runs:
token: "${{ inputs.token }}"

- name: Show steps.rebuild-dependency.outputs.exit-status
if: ${{ !cancelled() }}
shell: bash
run: |
echo "steps.rebuild-dependency.outputs.exit-status: ${{ steps.rebuild-dependency.outputs.exit-status }}"
- name: Set status
if: ${{ failure() && steps.rebuild-dependency.outputs.exit-status == 'dependency-build-failed' }}
shell: bash
run: |
echo "REBASE_DEPENDENCY_MAIN_EXIT_STATUS=dependency-build-failed" >> $GITHUB_ENV
- name: Set ${{ inputs.dependency-short-name }}.version to ${{ steps.rebuild-dependency.outputs.dependency-version }}
shell: bash
id: set-version
Expand Down
12 changes: 3 additions & 9 deletions .github/actions/rebuild-dependency/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ outputs:
It can be one of the following:
* success
* dependency-build-failed
value: ${{ env.REBUILD_DEPENDENCY_EXIT_STATUS }}
value: ${{ steps.set-outputs.outputs.exit-status }}

runs:
using: 'composite'
Expand Down Expand Up @@ -66,24 +66,18 @@ runs:
- name: Set outputs
id: set-outputs
if: ${{ !cancelled() }}
shell: bash
run: |
cd ~/${{ inputs.dependency-short-name }}
echo "dependency-commit=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
echo "dependency-version=$(xmllint --xpath "/*[local-name() = 'project']/*[local-name() = 'version']/text()" pom.xml)" >> $GITHUB_OUTPUT
echo "REBUILD_DEPENDENCY_EXIT_STATUS=success" >> $GITHUB_ENV
- name: Set status
if: ${{ failure() }}
shell: bash
run: |
echo "REBUILD_DEPENDENCY_EXIT_STATUS=dependency-build-failed" >> $GITHUB_ENV
echo "exit-status=${{ failed() && 'dependency-build-failed' || 'success' }}" >> $GITHUB_OUTPUT
- name: Reopen or comment on issue https://github.com/${{ github.repository }}/issues/${{ inputs.issue-id }}
if: ${{ failure() && inputs.issue-id != '' }}
shell: bash
run: |
echo "REBASE_DEPENDENCY_MAIN_EXIT_STATUS=rebase-failed" >> $GITHUB_ENV
oldState=$(gh issue view ${{ inputs.issue-id }} --json state -q .state -R ${{ github.repository }})
echo "oldState = $oldState"
gitUrl="${{ inputs.dependency-git-repo-url }}"
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/build-quarkus-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: build-quarkus-main

on:
workflow_dispatch:
schedule:
# Run every day at 2AM
- cron: '0 2 * * *'

env:
LANG: en_US.UTF-8
JAVA_VERSION: 17

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
rebase-quarkus-main:
if: github.repository == 'quarkiverse/quarkus-cxf'
runs-on: ubuntu-latest
steps:

- name: build-integration-branch
uses: ./.github/actions/build-integration-branch
with:
java-version: ${{ env.JAVA_VERSION }}
base-branch: main
integration-branch: quarkus-main
dependency-git-repo-url: https://github.com/quarkusio/quarkus.git
dependency-short-name: quarkus
dependency-branch: main
issue-id: 1287
token: "${{ secrets.QUARKIVERSEBOT_TOKEN }}"
12 changes: 7 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:
cancel-in-progress: true

jobs:
build-and-run-jvm-tests:
build-and-test:
if: startsWith(github.head_ref, 'trigger-release-') == false
runs-on: ubuntu-latest

Expand Down Expand Up @@ -67,18 +67,20 @@ jobs:
dependency-short-name: quarkus
dependency-branch: '${{ steps.quarkus-branch-info.outputs.dependency-stream }}'

- name: build-and-run-jvm-tests
uses: ./.github/actions/build-and-run-jvm-tests
- name: build-and-test
uses: ./.github/actions/build-and-test
with:
java-version: ${{ env.JAVA_VERSION }}
run-native-tests: false
upload-antora-site: true

native-tests:
strategy:
fail-fast: false
matrix:
testModule: ['async-vertx-client', 'client', 'client-server', 'fastinfoset', 'hc5', 'metrics', 'mtls', 'mtls -Djks', 'mtom', 'mtom-awt', 'opentelemetry', 'saaj', 'santuario-xmlsec', 'server', 'ws-rm-client', 'ws-security', 'ws-security -Djks', 'ws-security-policy', 'ws-security-policy -Djks', 'ws-trust', 'wsdl2java', 'wsdl2java-no-config']
name: ${{matrix.testModule}} native tests
needs: build-and-run-jvm-tests
needs: build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -90,7 +92,7 @@ jobs:

windows-tests:
name: Windows tests
needs: build-and-run-jvm-tests
needs: build-and-test
runs-on: windows-latest
steps:

Expand Down
Loading

0 comments on commit 3c8d91a

Please sign in to comment.