|
| 1 | +name: Connect Integration Tests |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + extensions: |
| 7 | + description: "JSON array of extension names to test" |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + outputs: |
| 11 | + successful_extensions: |
| 12 | + description: "JSON array of extension names that have passed all tests" |
| 13 | + value: ${{ jobs.collect-results.outputs.successful_extensions }} |
| 14 | + secrets: |
| 15 | + CONNECT_LICENSE: |
| 16 | + required: true |
| 17 | + |
| 18 | +jobs: |
| 19 | + # Determine the Connect versions to test against |
| 20 | + setup-integration-test: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + timeout-minutes: 5 |
| 23 | + outputs: |
| 24 | + versions: ${{ steps.versions.outputs.versions }} |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - id: versions |
| 29 | + working-directory: ./integration |
| 30 | + # The `jq` command is "output compact, raw input, slurp, split on new lines, and remove the last (empty) element" |
| 31 | + # This results in a JSON array of Connect versions (e.g., ["2025.01.0", "2024.12.0"]) |
| 32 | + run: | |
| 33 | + versions=$(make print-versions | jq -c -Rs 'split("\n") | .[:-1]') |
| 34 | + echo "Versions: $versions" |
| 35 | + echo "versions=$versions" >> "$GITHUB_OUTPUT" |
| 36 | +
|
| 37 | + # Run the Connect integration tests for each extension against each Connect version |
| 38 | + connect-integration-test: |
| 39 | + runs-on: ubuntu-latest |
| 40 | + timeout-minutes: 15 # Max time to run the integration tests |
| 41 | + needs: setup-integration-test |
| 42 | + strategy: |
| 43 | + # Do not fail fast so all extensions and Connect versions are processed |
| 44 | + fail-fast: false |
| 45 | + matrix: |
| 46 | + extension: ${{ fromJson(inputs.extensions) }} |
| 47 | + connect_version: ${{ fromJson(needs.setup-integration-test.outputs.versions) }} |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v4 |
| 50 | + |
| 51 | + - uses: ./.github/actions/connect-integration-test |
| 52 | + id: test |
| 53 | + with: |
| 54 | + extension-name: ${{ matrix.extension }} |
| 55 | + connect-version: ${{ matrix.connect_version }} |
| 56 | + connect-license: ${{ secrets.CONNECT_LICENSE }} |
| 57 | + |
| 58 | + - uses: actions/upload-artifact@v4 |
| 59 | + if: | |
| 60 | + always() && |
| 61 | + steps.test.outcome != 'cancelled' && |
| 62 | + steps.test.outcome != 'skipped' |
| 63 | + with: |
| 64 | + name: ${{ matrix.extension }}-${{ matrix.connect_version }}-test-report |
| 65 | + path: integration/reports/*.xml |
| 66 | + retention-days: 7 |
| 67 | + |
| 68 | + # Analyses the test result files and publishes the results on the GitHub Actions job summary page |
| 69 | + integration-test-report: |
| 70 | + needs: connect-integration-test |
| 71 | + runs-on: ubuntu-latest |
| 72 | + timeout-minutes: 5 |
| 73 | + # Create a matrix so each extension gets its own test report |
| 74 | + strategy: |
| 75 | + fail-fast: false |
| 76 | + matrix: |
| 77 | + extension: ${{ fromJson(inputs.extensions) }} |
| 78 | + permissions: |
| 79 | + checks: write |
| 80 | + pull-requests: write |
| 81 | + # Only run if tests weren't skipped or cancelled |
| 82 | + if: | |
| 83 | + always() && |
| 84 | + !contains(needs.connect-integration-test.result, 'skipped') && |
| 85 | + !contains(needs.connect-integration-test.result, 'cancelled') |
| 86 | + steps: |
| 87 | + - uses: actions/download-artifact@v4 |
| 88 | + id: download |
| 89 | + with: |
| 90 | + path: artifacts |
| 91 | + pattern: "${{ matrix.extension }}-*-test-report" |
| 92 | + |
| 93 | + - uses: EnricoMi/publish-unit-test-result-action@v2 |
| 94 | + if: ${{ steps.download.outputs.download-path != '' }} |
| 95 | + with: |
| 96 | + check_name: "Integration test results - ${{ matrix.extension }}" |
| 97 | + comment_mode: off |
| 98 | + files: "artifacts/**/*.xml" |
| 99 | + report_individual_runs: true |
| 100 | + |
| 101 | + # Using the XML test reports provide a matrix of extensions that passed all of the Connect integration tests |
| 102 | + collect-results: |
| 103 | + needs: [connect-integration-test, setup-integration-test] |
| 104 | + runs-on: ubuntu-latest |
| 105 | + timeout-minutes: 5 |
| 106 | + outputs: |
| 107 | + successful_extensions: ${{ steps.collect.outputs.successful_extensions }} |
| 108 | + if: always() |
| 109 | + steps: |
| 110 | + - uses: actions/download-artifact@v4 |
| 111 | + id: download |
| 112 | + with: |
| 113 | + path: artifacts |
| 114 | + pattern: "*-test-report" |
| 115 | + |
| 116 | + - id: collect |
| 117 | + run: | |
| 118 | + # Validate inputs first |
| 119 | + all_versions='${{ needs.setup-integration-test.outputs.versions }}' |
| 120 | + extensions='${{ inputs.extensions }}' |
| 121 | +
|
| 122 | + if [[ -z "$all_versions" || -z "$extensions" ]]; then |
| 123 | + echo "❌ Missing required inputs" |
| 124 | + exit 1 |
| 125 | + fi |
| 126 | + |
| 127 | + # Debug info |
| 128 | + echo "::group::Debug Inputs" |
| 129 | + echo "Extensions to check: $extensions" |
| 130 | + echo "Connect versions: $all_versions" |
| 131 | + echo "::endgroup::" |
| 132 | + |
| 133 | + # Track extensions that passed ALL version tests |
| 134 | + success_list=() |
| 135 | + |
| 136 | + for ext in $(echo "$extensions" | jq -r '.[]'); do |
| 137 | + all_passed=true |
| 138 | + echo "📦 Checking extension: $ext" |
| 139 | + |
| 140 | + for version in $(echo "$all_versions" | jq -r '.[]'); do |
| 141 | + echo "🔎 Checking $ext @ $version" |
| 142 | + report_dir="artifacts/${ext}-${version}-test-report" |
| 143 | + |
| 144 | + if [ ! -d "$report_dir" ]; then |
| 145 | + echo "❌ No test report for $ext @ $version" |
| 146 | + all_passed=false |
| 147 | + break |
| 148 | + fi |
| 149 | + |
| 150 | + # Use grep to check for failures/errors using XML test report attributes |
| 151 | + failures=$(grep -o 'failures="[0-9]*"' "$report_dir"/*.xml | sed 's/failures="//g' | sed 's/"//g' | awk '{sum+=$1} END {print sum}' || echo "0") |
| 152 | + errors=$(grep -o 'errors="[0-9]*"' "$report_dir"/*.xml | sed 's/errors="//g' | sed 's/"//g' | awk '{sum+=$1} END {print sum}' || echo "0") |
| 153 | + |
| 154 | + if [ "$failures" -gt 0 ] || [ "$errors" -gt 0 ]; then |
| 155 | + echo "❌ Found $failures failures, $errors errors in test suite attributes" |
| 156 | + # Extract and show some error details for debugging |
| 157 | + echo "::group::Error details" |
| 158 | + grep -r -A1 "<failure" "$report_dir" | head -10 |
| 159 | + grep -r -A1 "<error" "$report_dir" | head -10 |
| 160 | + echo "::endgroup::" |
| 161 | + all_passed=false |
| 162 | + break |
| 163 | + else |
| 164 | + echo "✅ Passed: $ext @ $version" |
| 165 | + fi |
| 166 | + done |
| 167 | + |
| 168 | + if [ "$all_passed" = "true" ]; then |
| 169 | + success_list+=("$ext") |
| 170 | + echo "🎉 SUCCESS: $ext passed ALL versions" |
| 171 | + else |
| 172 | + echo "⚠️ FAILED: $ext failed one or more versions" |
| 173 | + fi |
| 174 | + done |
| 175 | + |
| 176 | + # Format output and ensure we always have a valid JSON array |
| 177 | + if [ ${#success_list[@]} -eq 0 ]; then |
| 178 | + successful_extensions="[]" |
| 179 | + else |
| 180 | + successful_extensions=$(jq -n --arg arr "$(IFS=,; echo "${success_list[*]}")" \ |
| 181 | + '$arr | split(",") | map(select(length > 0))' -c) |
| 182 | + fi |
| 183 | +
|
| 184 | + echo "successful_extensions=$successful_extensions" >> $GITHUB_OUTPUT |
0 commit comments