Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
290 changes: 290 additions & 0 deletions .github/workflows/trigger-integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
# Copyright (c) 2025 ADBC Drivers Contributors
#
# Licensed 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: Trigger Integration Tests
on:
pull_request:
types: [labeled, synchronize] # Trigger on label add or new commits
merge_group: # Trigger when added to merge queue
jobs:
# =============================================================================
# For PRs: Only run if "integration-test" label exists
# =============================================================================
check-should-run-pr:
if: github.event_name == 'pull_request'
runs-on: [self-hosted, Linux, X64, peco-driver]
outputs:
run: ${{ steps.check.outputs.run }}
steps:
- name: Check for integration-test label
id: check
run: |
if [[ "${{ contains(github.event.pull_request.labels.*.name, 'integration-test') }}" == "true" ]]; then
echo "✅ integration-test label found - will trigger tests"
echo "run=true" >> $GITHUB_OUTPUT
else
echo "⏭️ integration-test label not found - skipping tests"
echo "run=false" >> $GITHUB_OUTPUT
fi
trigger-tests-pr:
needs: check-should-run-pr
if: needs.check-should-run-pr.outputs.run == 'true'
runs-on: [self-hosted, Linux, X64, peco-driver]
permissions:
issues: write
pull-requests: write
steps:
- name: Generate GitHub App Token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.INTEGRATION_TEST_APP_ID }}
private-key: ${{ secrets.INTEGRATION_TEST_PRIVATE_KEY }}
owner: databricks
repositories: databricks-driver-test
- name: Dispatch tests to internal repo
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ steps.app-token.outputs.token }}
repository: databricks/databricks-driver-test
event-type: adbc-pr-test
client-payload: |
{
"pr_number": "${{ github.event.pull_request.number }}",
"commit_sha": "${{ github.event.pull_request.head.sha }}",
"pr_repo": "${{ github.repository }}",
"pr_url": "${{ github.event.pull_request.html_url }}",
"pr_title": "${{ github.event.pull_request.title }}",
"pr_author": "${{ github.event.pull_request.user.login }}"
}
- name: Comment on PR
uses: actions/github-script@v7
with:
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: '🚀 Integration tests triggered! [View workflow run](https://github.com/databricks/databricks-driver-test/actions)'
});
# =============================================================================
# For Merge Queue: Check if relevant files changed
# =============================================================================
check-merge-queue-paths:
if: github.event_name == 'merge_group'
runs-on: [self-hosted, Linux, X64, peco-driver]
outputs:
should-test: ${{ steps.check-paths.outputs.should_test }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if relevant files changed
id: check-paths
run: |
# Get the base and head commits for the merge queue
BASE_SHA="${{ github.event.merge_group.base_sha }}"
HEAD_SHA="${{ github.event.merge_group.head_sha }}"
echo "Checking files changed between $BASE_SHA and $HEAD_SHA"
# Define paths to check
PATHS=(
".github/workflows/trigger-integration-tests.yml"
"ci/scripts/"
"csharp/src/"
"csharp/test/"
)
# Check if any relevant files changed
CHANGED=false
for path in "${PATHS[@]}"; do
if git diff --name-only "$BASE_SHA" "$HEAD_SHA" | grep -q "^${path}"; then
echo "✅ Found changes in: $path"
CHANGED=true
break
fi
done
if [ "$CHANGED" = true ]; then
echo "should_test=true" >> $GITHUB_OUTPUT
echo "✅ Relevant files changed - will run tests"
else
echo "should_test=false" >> $GITHUB_OUTPUT
echo "⏭️ No relevant files changed - skipping tests"
fi
# =============================================================================
# For Merge Queue: Check if tests already passed on PR
# =============================================================================
check-previous-run:
needs: check-merge-queue-paths
if: github.event_name == 'merge_group' && needs.check-merge-queue-paths.outputs.should-test == 'true'
runs-on: [self-hosted, Linux, X64, peco-driver]
outputs:
already-passed: ${{ steps.check-pr.outputs.passed }}
pr-number: ${{ steps.extract-pr.outputs.pr_number }}
steps:
- name: Extract PR number from merge queue ref
id: extract-pr
run: |
# Merge queue ref format: refs/heads/gh-readonly-queue/{base_branch}/pr-{pr_number}-{sha}
REF="${{ github.event.merge_group.head_ref }}"
echo "Full ref: $REF"
# Extract PR number
if [[ $REF =~ pr-([0-9]+) ]]; then
PR_NUMBER="${BASH_REMATCH[1]}"
echo "Extracted PR number: $PR_NUMBER"
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
else
echo "❌ Could not extract PR number from ref"
echo "pr_number=" >> $GITHUB_OUTPUT
fi
- name: Generate GitHub App Token
if: steps.extract-pr.outputs.pr_number != ''
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.INTEGRATION_TEST_APP_ID }}
private-key: ${{ secrets.INTEGRATION_TEST_PRIVATE_KEY }}
owner: adbc-drivers
repositories: databricks
- name: Check if tests passed on current PR head
if: steps.extract-pr.outputs.pr_number != ''
id: check-pr
uses: actions/github-script@v7
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const prNumber = '${{ steps.extract-pr.outputs.pr_number }}';
if (!prNumber) {
console.log('No PR number found');
return false;
}
// Get PR details
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber
});
console.log(`PR #${prNumber} head SHA: ${pr.head.sha}`);
// Get checks for current PR head SHA
const { data: checks } = await github.rest.checks.listForRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: pr.head.sha,
check_name: 'Integration Tests'
});
console.log(`Found ${checks.total_count} check runs for "Integration Tests"`);
// Find the most recent passing check
const passingChecks = checks.check_runs
.filter(run => run.conclusion === 'success')
.sort((a, b) => new Date(b.completed_at) - new Date(a.completed_at));
if (passingChecks.length === 0) {
console.log('❌ No passing checks found');
return false;
}
const latestPassing = passingChecks[0];
// CRITICAL: Check if the passing test ran on the CURRENT head SHA
if (latestPassing.head_sha !== pr.head.sha) {
console.log(`⚠️ Tests passed on ${latestPassing.head_sha}, but PR head is now ${pr.head.sha}`);
return false;
}
console.log(`✅ Tests passed on current head ${pr.head.sha}`);
return true;
trigger-tests-merge:
needs: check-previous-run
if: needs.check-previous-run.outputs.already-passed != 'true'
runs-on: [self-hosted, Linux, X64, peco-driver]
steps:
- name: Generate GitHub App Token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.INTEGRATION_TEST_APP_ID }}
private-key: ${{ secrets.INTEGRATION_TEST_PRIVATE_KEY }}
owner: databricks
repositories: databricks-driver-test
- name: Dispatch tests to internal repo
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ steps.app-token.outputs.token }}
repository: databricks/databricks-driver-test
event-type: adbc-pr-test
client-payload: |
{
"pr_number": "${{ needs.check-previous-run.outputs.pr-number }}",
"commit_sha": "${{ github.event.merge_group.head_sha }}",
"pr_repo": "${{ github.repository }}",
"pr_url": "https://github.com/${{ github.repository }}/pull/${{ needs.check-previous-run.outputs.pr-number }}",
"pr_title": "Merge queue validation",
"pr_author": "merge-queue"
}
auto-approve-no-relevant-changes:
needs: check-merge-queue-paths
if: github.event_name == 'merge_group' && needs.check-merge-queue-paths.outputs.should-test == 'false'
runs-on: [self-hosted, Linux, X64, peco-driver]
steps:
- name: Generate GitHub App Token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.INTEGRATION_TEST_APP_ID }}
private-key: ${{ secrets.INTEGRATION_TEST_PRIVATE_KEY }}
owner: adbc-drivers
repositories: databricks
- name: Create passing check (no relevant changes)
uses: actions/github-script@v7
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Integration Tests',
head_sha: '${{ github.event.merge_group.head_sha }}',
status: 'completed',
conclusion: 'success',
completed_at: new Date().toISOString(),
output: {
title: 'Auto-approved - no relevant changes',
summary: '✅ No integration test files changed. Skipping tests.'
}
});
auto-approve-already-passed:
needs: check-previous-run
if: needs.check-previous-run.outputs.already-passed == 'true'
runs-on: [self-hosted, Linux, X64, peco-driver]
steps:
- name: Generate GitHub App Token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.INTEGRATION_TEST_APP_ID }}
private-key: ${{ secrets.INTEGRATION_TEST_PRIVATE_KEY }}
owner: adbc-drivers
repositories: databricks
- name: Create passing check (auto-approve)
uses: actions/github-script@v7
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Integration Tests',
head_sha: '${{ github.event.merge_group.head_sha }}',
status: 'completed',
conclusion: 'success',
completed_at: new Date().toISOString(),
output: {
title: 'Auto-approved for merge queue',
summary: '✅ Tests already passed on PR head commit. Skipping duplicate test run.'
}
});
Loading