Skip to content

Commit b285974

Browse files
committed
Fixup in integration tests workflow
1 parent d44b283 commit b285974

1 file changed

Lines changed: 23 additions & 11 deletions

File tree

.github/workflows/run-integration-tests.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
outputs:
1212
skip: ${{ steps.test-parameters.outputs.skip }}
1313
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 }}
1515

1616
steps:
1717
- name: Print debugging info
@@ -54,15 +54,11 @@ jobs:
5454
run: |
5555
python .github/scripts/get_integration_test_params.py
5656
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}"
6662
6763
run-integration-tests:
6864
name: Run Integration Tests
@@ -91,7 +87,23 @@ jobs:
9187
9288
echo "Triggering remote workflow"
9389
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
95107
echo "Using integration tests ref: $INTEGRATION_REF"
96108
97109
gh workflow run run-tests.yml \

0 commit comments

Comments
 (0)