This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch camel-quarkus-main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus-examples.git


The following commit(s) were added to refs/heads/camel-quarkus-main by this 
push:
     new 7fb72d4  Dynamically generate native test matrix
7fb72d4 is described below

commit 7fb72d472934797123ea521d123ae7d6739c3ff3
Author: James Netherton <jamesnether...@gmail.com>
AuthorDate: Wed Feb 16 10:43:07 2022 +0000

    Dynamically generate native test matrix
---
 .github/generate-test-groups.groovy | 43 +++++++++++++++++++++++++++++++++++
 .github/test-categories.yaml        | 43 -----------------------------------
 .github/workflows/ci-build.yaml     | 45 +++++++++++++++++++------------------
 3 files changed, 66 insertions(+), 65 deletions(-)

diff --git a/.github/generate-test-groups.groovy 
b/.github/generate-test-groups.groovy
new file mode 100644
index 0000000..6987c2d
--- /dev/null
+++ b/.github/generate-test-groups.groovy
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+import groovy.json.JsonOutput;
+
+final int MAX_GROUPS = 10
+final List<Map<String, String>> GROUPS = new ArrayList<>()
+int groupId = 0
+
+// Distribute example projects across a bounded set of test groups and output 
as JSON
+new File(".").eachFileRecurse { file ->
+    if (file.getName() == "pom.xml" && file.text.contains("<id>native</id>")) {
+        if (GROUPS[groupId] == null) {
+            GROUPS[groupId] = [:]
+            GROUPS[groupId].name = "group-${String.format("%02d", groupId + 
1)}"
+            GROUPS[groupId].tests = ""
+        }
+
+        String separator = GROUPS[groupId].tests == "" ? "" : ","
+
+        GROUPS[groupId].tests = 
"${GROUPS[groupId].tests}${separator}${file.parentFile.name}"
+
+        groupId += 1;
+        if (groupId == MAX_GROUPS) {
+            groupId = 0
+        }
+    }
+}
+
+print JsonOutput.toJson(["include": GROUPS])
diff --git a/.github/test-categories.yaml b/.github/test-categories.yaml
deleted file mode 100644
index bdaec59..0000000
--- a/.github/test-categories.yaml
+++ /dev/null
@@ -1,43 +0,0 @@
-
-#
-# 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.
-#
-
-# Association of categories and camel-quarkus-examples maven modules. Used by 
GitHub workflows.
-group-01:
-  - file-bindy-ftp
-  - file-split-log-xml
-group-02:
-  - health
-  - observability
-group-03:
-  - http-log
-  - rest-json
-group-04:
-  - aws-lambda
-  - timer-log
-  - timer-log-cdi
-group-05:
-  - timer-log-kotlin
-  - timer-log-main
-group-06:
-  - timer-log-spring
-  - timer-log-xml
-group-07:
-  - kafka
-  - kamelet-chucknorris
-group-08:
-  - jdbc-datasource
diff --git a/.github/workflows/ci-build.yaml b/.github/workflows/ci-build.yaml
index b040299..2727618 100644
--- a/.github/workflows/ci-build.yaml
+++ b/.github/workflows/ci-build.yaml
@@ -78,19 +78,6 @@ jobs:
             license:check \
             net.revelc.code.formatter:formatter-maven-plugin:validate \
             net.revelc.code:impsort-maven-plugin:check
-      - name: Validate test categories YAML
-        run: |
-          VALID=true
-          for EXAMPLE in $(dirname $(grep -l "camel-quarkus-examples-" $(find 
. -name pom.xml)) | cut -f2 -d'/'); do
-            if ! grep ${EXAMPLE} .github/test-categories.yaml > /dev/null; then
-              echo "Project ${EXAMPLE} is not listed in 
.github/test-categories.yaml"
-              VALID=false
-            fi
-          done
-
-          if [[ ${VALID} != "true" ]]; then
-            exit 1
-          fi
       - name: Build Camel Quarkus Examples
         run: |
           ./mvnw-for-each.sh ${MAVEN_ARGS} clean install -DskipTests 
-Dquarkus.build.skip
@@ -111,11 +98,12 @@ jobs:
       - name: Setup Integration Test Matrix
         id: set-itest-matrix
         run: |
-          CATEGORIES=$(yq -M -N -I 0 -o=json e 'keys' 
.github/test-categories.yaml | tr '"' "'")
-          echo "::set-output name=matrix::{'category': ${CATEGORIES}}"
+          sudo apt install groovy -y --no-install-recommends
+          TEST_GROUPS=$(groovy .github/generate-test-groups.groovy)
+          echo "::set-output name=matrix::${TEST_GROUPS}"
 
   integration-tests:
-    name: Integration Tests - ${{matrix.category}}
+    name: Integration Tests - ${{matrix.name}}
     needs: initial-mvn-install
     runs-on: ubuntu-latest
     strategy:
@@ -139,18 +127,31 @@ jobs:
         run: |
           tar -xzf ../maven-repo.tgz -C ~
       - name: Integration Tests
+        env:
+          TEST_MODULES: ${{matrix.tests}}
+        shell: '/usr/bin/bash {0}'
         run: |
-          EXAMPLE_PROJECTS=""
-          for EXAMPLE in $(yq -M -N e ".${{ matrix.category }}" 
.github/test-categories.yaml | cut -f2 -d' '); do
-            if [ "${EXAMPLE}" == "null" ]; then
-              continue
-            fi
+          BUILD_FAILURES=()
 
+          for MODULE in ${TEST_MODULES//,/ }; do
             ./mvnw ${MAVEN_ARGS} clean verify \
               -Dformatter.skip -Dimpsort.skip \
               -Pnative,docker \
-              -f "${EXAMPLE}/pom.xml"
+              -f "${MODULE}/pom.xml"
+
+            if [[ $? -ne 0 ]]; then
+              BUILD_FAILURES[${#BUILD_FAILURES[@]}]=${MODULE}
+            fi
           done
+
+          if [[ ${#BUILD_FAILURES[@]} -gt 0 ]]; then
+            echo -e "\nBuild errors were encountred in the following 
projects:\n"
+            for FAILURE in ${BUILD_FAILURES[@]}; do
+                echo "* ${FAILURE}"
+            done
+            echo -e "\nCheck build logs for further information."
+            exit 1
+          fi
       - name: Fail if there are uncommitted changes
         shell: bash
         run: |

Reply via email to