|
11 | 11 | outputs: |
12 | 12 | skip: ${{ steps.test-parameters.outputs.skip }} |
13 | 13 | dialects: ${{ steps.test-parameters.outputs.dialects }} |
14 | | - integration_tests_ref: ${{ steps.test-parameters.outputs.integration_tests_ref }} |
| 14 | + integration_tests_sha: ${{ steps.test-parameters.outputs.integration_tests_sha }} |
15 | 15 |
|
16 | 16 | steps: |
17 | 17 | - name: Print debugging info |
@@ -54,15 +54,11 @@ jobs: |
54 | 54 | run: | |
55 | 55 | python .github/scripts/get_integration_test_params.py |
56 | 56 |
|
57 | | - # Read the submodule commit SHA to use as the ref for the remote workflow |
58 | | - INTEGRATION_REF=$(git ls-tree HEAD sqlglot-integration-tests | awk '{print $3}') |
59 | | - if [ -n "$INTEGRATION_REF" ]; then |
60 | | - echo "integration_tests_ref=$INTEGRATION_REF" >> $GITHUB_OUTPUT |
61 | | - echo "Integration tests ref: $INTEGRATION_REF" |
62 | | - else |
63 | | - echo "integration_tests_ref=main" >> $GITHUB_OUTPUT |
64 | | - echo "No submodule pointer found, using main" |
65 | | - fi |
| 57 | + # Read the submodule commit SHA so the run-integration-tests job can |
| 58 | + # resolve the correct ref in the remote repo |
| 59 | + SUBMODULE_SHA=$(git ls-tree HEAD sqlglot-integration-tests | awk '{print $3}') |
| 60 | + echo "integration_tests_sha=${SUBMODULE_SHA:-}" >> $GITHUB_OUTPUT |
| 61 | + echo "Integration tests submodule SHA: ${SUBMODULE_SHA:-not found}" |
66 | 62 |
|
67 | 63 | run-integration-tests: |
68 | 64 | name: Run Integration Tests |
|
91 | 87 |
|
92 | 88 | echo "Triggering remote workflow" |
93 | 89 |
|
94 | | - INTEGRATION_REF="${{ needs.should-run.outputs.integration_tests_ref }}" |
| 90 | + # Resolve the integration tests ref: use a matching branch if its tip |
| 91 | + # matches the submodule SHA, otherwise fall back to main |
| 92 | + INTEGRATION_REF="main" |
| 93 | + SUBMODULE_SHA="${{ needs.should-run.outputs.integration_tests_sha }}" |
| 94 | + BRANCH_NAME="${{ github.head_ref || github.ref_name }}" |
| 95 | +
|
| 96 | + if [ -n "$SUBMODULE_SHA" ] && [ -n "$BRANCH_NAME" ] && [ "$BRANCH_NAME" != "main" ]; then |
| 97 | + BRANCH_TIP=$(gh api "repos/$REMOTE_REPO/branches/$BRANCH_NAME" --jq '.commit.sha' 2>/dev/null || echo "") |
| 98 | + if [ "$BRANCH_TIP" = "$SUBMODULE_SHA" ]; then |
| 99 | + INTEGRATION_REF="$BRANCH_NAME" |
| 100 | + echo "Branch '$BRANCH_NAME' tip matches submodule SHA ($SUBMODULE_SHA)" |
| 101 | + elif [ -n "$BRANCH_TIP" ]; then |
| 102 | + echo "Branch '$BRANCH_NAME' exists but tip ($BRANCH_TIP) doesn't match submodule SHA ($SUBMODULE_SHA), using main" |
| 103 | + else |
| 104 | + echo "No branch '$BRANCH_NAME' in $REMOTE_REPO, using main" |
| 105 | + fi |
| 106 | + fi |
95 | 107 | echo "Using integration tests ref: $INTEGRATION_REF" |
96 | 108 |
|
97 | 109 | gh workflow run run-tests.yml \ |
|
0 commit comments