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

Make the CI more modular to allow for testing also against CXF and branches other than main #1610

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
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 @@ -16,39 +24,25 @@ runs:
distribution: temurin
java-version: ${{ inputs.java-version }}

- name: Build CXF
if: github.ref == 'refs/heads/cxf-main' || github.base_ref == 'cxf-main' || github.head_ref == 'cxf-main'
uses: ./.github/actions/rebuild-dependency
id: rebuild-cxf
with:
dependency-git-repo-url: https://github.com/apache/cxf.git
dependency-short-name: cxf
- name: Build Quarkus
if: github.ref == 'refs/heads/quarkus-main' || github.base_ref == 'quarkus-main' || github.head_ref == 'quarkus-main'
uses: ./.github/actions/rebuild-dependency
id: rebuild-quarkus
with:
dependency-git-repo-url: https://github.com/quarkusio/quarkus.git
dependency-short-name: quarkus

- name: Ensure mvn cq:sync-versions -N causes no changes
shell: bash
run: |
./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 }}

40 changes: 40 additions & 0 deletions .github/actions/maintenance-branch-info/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: maintenance-branch-info
description: 'Figure out some information about the underlying maintenance branch of the current PR, merge or manually triggered event'

inputs:
dependency-short-name:
description: "The short lower case name of the dependency as quarkus or cxf"
required: true

outputs:
is-maintenance-branch:
description: "'true' if the underlying branch of the PR, merge or manually triggered build is a maintenance branch, such as quarkus-main, quarkus-3.15; otherwise 'false'"
value: '${{ steps.maintenance-branch-info-step.outputs.is-maintenance-branch }}'
dependency-stream:
description: "The name of the stream in the dependency git repository, such as main or 3.15 for Quarkus or main or 4.0 for CXF. The caller may map the stream to a remote branch that may be called differently, such as 4.0.x-fixes in case of CXF."
value: '${{ steps.maintenance-branch-info-step.outputs.dependency-stream }}'

runs:
using: 'composite'
steps:

- name: Detect maintenance branch info
id: maintenance-branch-info-step
shell: bash
run: |
refs=('${{ github.ref }}' '${{ github.base_ref }}' '${{ github.head_ref }}')
regex="${{ inputs.dependency-short-name }}-(main|[0-9]+\.[0-9]+)$"

isMaintenanceBranch=false
dependencyStream=''
for ref in "${refs[@]}"; do
if [[ $ref =~ $regex ]]; then
isMaintenanceBranch=true
dependencyStream="${BASH_REMATCH[1]}"
break
fi
done
echo "isMaintenanceBranch = ${isMaintenanceBranch}"
echo "is-maintenance-branch='${isMaintenanceBranch}'" >> $GITHUB_OUTPUT
echo "dependencyStream = ${dependencyStream}"
echo "dependency-stream='$(echo "$dependencyStream")'" >> $GITHUB_OUTPUT
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
name: rebase-dependency-main-branch
description: 'Rebase a dependency main 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 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
Expand All @@ -20,7 +32,7 @@ inputs:

outputs:
dependency-commit:
description: "The SHA1 of the dependency main branch"
description: "The SHA1 of the branch specified in inputs.dependency-branch against which the current build was run"
value: ${{ steps.rebuild-dependency.outputs.dependency-commit }}
dependency-version:
description: "The version of the dependency as present in the top pom.xml of its main branch"
Expand All @@ -35,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 @@ -47,32 +59,34 @@ runs:
distribution: temurin
java-version: ${{ inputs.java-version }}

- name: rebase ${{ inputs.dependency-short-name }}-main
- uses: actions/checkout@v4
with:
fetch-depth: 0

- 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 main
git checkout main
git reset --hard origin/main
git fetch origin ${{ inputs.dependency-short-name }}-main
git checkout ${{ inputs.dependency-short-name }}-main >/dev/null 2>&1 || git checkout -b ${{ inputs.dependency-short-name }}-main origin/main
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 }}-main is at $(git rev-parse HEAD)"
git rebase main
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 }}
- 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 }}-main 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 @@ -93,20 +107,16 @@ runs:
with:
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.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
Loading
Loading