You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2023/05/30 16:44:09 UTC
[camel] branch main updated: Allow to trigger component tests with a comment (#10242)
This is an automated email from the ASF dual-hosted git repository.
nfilotto pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new ee06770bec6 Allow to trigger component tests with a comment (#10242)
ee06770bec6 is described below
commit ee06770bec6146de6d5bbde19365c477de28e900
Author: Nicolas Filotto <es...@users.noreply.github.com>
AuthorDate: Tue May 30 18:44:03 2023 +0200
Allow to trigger component tests with a comment (#10242)
The idea of this PR is to allow to launch component tests thanks to a comment on the PR using the format `/component-test (camel-)component-name1 (camel-)component-name2...`
---
.github/actions/component-test/action.yaml | 47 +++++++++++++++++++++
.github/actions/component-test/component-test.sh | 52 +++++++++++++++++++++++
.github/workflows/pr-comment-main.yml | 54 ++++++++++++++++++++++++
3 files changed, 153 insertions(+)
diff --git a/.github/actions/component-test/action.yaml b/.github/actions/component-test/action.yaml
new file mode 100644
index 00000000000..15ae080b8ca
--- /dev/null
+++ b/.github/actions/component-test/action.yaml
@@ -0,0 +1,47 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+name: "Component Test Runner"
+description: "Runs tests of corresponding to the given comment"
+inputs:
+ comment-body:
+ description: 'Body of the comment to process'
+ required: true
+runs:
+ using: "composite"
+ steps:
+ - id: install-mvnd
+ uses: ./.github/actions/install-mvnd
+ - name: maven build
+ shell: bash
+ run: ${{ github.action_path }}/component-test.sh ${{ steps.install-mvnd.outputs.mvnd-dir }}/mvnd true "${{ inputs.comment-body }}" build.log
+ - name: archive logs
+ uses: actions/upload-artifact@v3
+ if: always()
+ with:
+ name: build.log
+ path: build.log
+ - name: maven test
+ shell: bash
+ run: ${{ github.action_path }}/component-test.sh ${{ steps.install-mvnd.outputs.mvnd-dir }}/mvnd false "${{ inputs.comment-body }}" tests.log
+ - name: archive logs
+ uses: actions/upload-artifact@v3
+ if: always()
+ with:
+ name: tests.log
+ path: tests.log
+
diff --git a/.github/actions/component-test/component-test.sh b/.github/actions/component-test/component-test.sh
new file mode 100755
index 00000000000..54fd13218d7
--- /dev/null
+++ b/.github/actions/component-test/component-test.sh
@@ -0,0 +1,52 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# Modify maven options here if needed
+MVN_DEFAULT_OPTS="-Dmaven.compiler.fork=true -Dsurefire.rerunFailingTestsCount=2 -Dfailsafe.rerunFailingTestsCount=2 -Dci.env.name=github.com"
+MVN_OPTS=${MVN_OPTS:-$MVN_DEFAULT_OPTS}
+
+function main() {
+ local mavenBinary=${1}
+ local fastBuild=${2}
+ local commentBody=${3}
+ local log=${4}
+
+ if [[ ${commentBody} = /component-test* ]] ; then
+ local componentList="${commentBody:16}"
+ else
+ echo "No components has been detected, the expected format is '/component-test (camel-)component-name1 (camel-)component-name2...'"
+ exit 1
+ fi
+ local pl=""
+ for component in ${componentList}
+ do
+ if [[ ${component} = camel-* ]] ; then
+ pl="$pl,components/${component}"
+ else
+ pl="$pl,components/camel-${component}"
+ fi
+ done
+ pl="${pl:1}"
+
+ if [[ ${fastBuild} = "true" ]] ; then
+ $mavenBinary -l $log -Dmvnd.threads=2 -V -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 --no-transfer-progress -e -Pfastinstall install -pl "$pl" -am
+ else
+ $mavenBinary -l $log -Dmvnd.threads=2 -V -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 --no-transfer-progress -e install -pl "$pl"
+ fi
+}
+
+main "$@"
diff --git a/.github/workflows/pr-comment-main.yml b/.github/workflows/pr-comment-main.yml
new file mode 100644
index 00000000000..680c619d1ff
--- /dev/null
+++ b/.github/workflows/pr-comment-main.yml
@@ -0,0 +1,54 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+name: PR Comment Build (Camel 4)
+
+on:
+ issue_comment:
+
+jobs:
+ pr_commented:
+ name: PR comment
+ if: ${{ github.event.issue.pull_request }}
+ permissions:
+ issues: write
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ java: [ '17' ]
+ steps:
+ - name: check for component tests
+ if: contains(github.event.comment.body, '/component-test')
+ run: |
+ echo Component tests have been requested
+ - uses: actions/checkout@v3
+ with:
+ persist-credentials: false
+ fetch-depth: 0
+ - id: install-packages
+ uses: ./.github/actions/install-packages
+ - name: Set up JDK ${{ matrix.java }}
+ uses: actions/setup-java@v3
+ with:
+ distribution: 'temurin'
+ java-version: ${{ matrix.java }}
+ cache: 'maven'
+ - id: test
+ name: Component test execution
+ uses: ./.github/actions/component-test
+ with:
+ comment-body: ${{ github.event.comment.body }}