Skip to content

Commit a65e072

Browse files
committed
Conditionally trigger integration tests based on testmask output (#4017)
Consolidate integration workflow files into a single job in push.yml that depends on the testmask job introduced in #4017. Integration tests are now only triggered for pull requests when the "test" target is included in the testmask output. When skipped, a success status is posted to satisfy the required check without running tests. This reduces CI resource usage for changes that don't affect code covered by integration tests (e.g., documentation-only changes).
1 parent edcc112 commit a65e072

File tree

4 files changed

+74
-110
lines changed

4 files changed

+74
-110
lines changed

.github/workflows/integration-approve.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/integration-main.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/integration-pr.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/push.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,77 @@ jobs:
334334
335335
exit 1
336336
fi
337+
338+
# Trigger integration tests in a separate repository.
339+
# Requires secrets from "test-trigger-is" environment (not available for fork PRs).
340+
# Auto-approves for merge groups to avoid running twice and queue timeouts.
341+
integration-trigger:
342+
needs:
343+
- testmask
344+
345+
if: >-
346+
(github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork) ||
347+
(github.event_name == 'merge_group') ||
348+
(github.event_name == 'push')
349+
350+
runs-on:
351+
group: databricks-deco-testing-runner-group
352+
labels: ubuntu-latest-deco
353+
354+
environment: "test-trigger-is"
355+
356+
steps:
357+
- name: Generate GitHub App Token
358+
if: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
359+
id: generate-token
360+
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
361+
with:
362+
app-id: ${{ secrets.DECO_WORKFLOW_TRIGGER_APP_ID }}
363+
private-key: ${{ secrets.DECO_WORKFLOW_TRIGGER_PRIVATE_KEY }}
364+
owner: ${{ secrets.ORG_NAME }}
365+
repositories: ${{ secrets.REPO_NAME }}
366+
367+
# Trigger integration tests if the primary "test" target is triggered by this change.
368+
- name: Trigger integration tests (pull request)
369+
if: ${{ github.event_name == 'pull_request' && contains(fromJSON(needs.testmask.outputs.targets), 'test') }}
370+
env:
371+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
372+
run: |-
373+
gh workflow run cli-isolated-pr.yml -R ${{ secrets.ORG_NAME }}/${{ secrets.REPO_NAME }} \
374+
--ref main \
375+
-f pull_request_number=${{ github.event.pull_request.number }} \
376+
-f commit_sha=${{ github.event.pull_request.head.sha }}
377+
378+
# Skip integration tests if the primary "test" target is not triggered by this change.
379+
- name: Skip integration tests (pull request)
380+
if: ${{ github.event_name == 'pull_request' && !contains(fromJSON(needs.testmask.outputs.targets), 'test') }}
381+
env:
382+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
383+
run: |-
384+
gh api -X POST -H "Accept: application/vnd.github+json" \
385+
-H "X-GitHub-Api-Version: 2022-11-28" \
386+
/repos/${{ github.repository }}/statuses/${{ github.event.pull_request.head.sha }} \
387+
-f 'state=success' \
388+
-f 'context=Integration Tests Check' \
389+
-f 'description=⏭️ Skipped'
390+
391+
- name: Auto-approve for merge group
392+
if: ${{ github.event_name == 'merge_group' }}
393+
env:
394+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
395+
run: |-
396+
gh api -X POST -H "Accept: application/vnd.github+json" \
397+
-H "X-GitHub-Api-Version: 2022-11-28" \
398+
/repos/${{ github.repository }}/statuses/${{ github.sha }} \
399+
-f 'state=success' \
400+
-f 'context=Integration Tests Check' \
401+
-f 'description=⏭️ Skipped'
402+
403+
- name: Trigger integration tests (push to main)
404+
if: ${{ github.event_name == 'push' }}
405+
env:
406+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
407+
run: |-
408+
gh workflow run cli-isolated-nightly.yml -R ${{ secrets.ORG_NAME }}/${{ secrets.REPO_NAME }} \
409+
--ref main \
410+
-f commit_sha=${{ github.event.after }}

0 commit comments

Comments
 (0)