@@ -18,15 +18,15 @@ jobs:
1818 outputs :
1919 has_token : ${{ steps.set-token-status.outputs.has_token }}
2020 steps :
21- - name : Check if DECO_WORKFLOW_TRIGGER_APP_ID is set
21+ - name : Check if required secrets are set
2222 id : set-token-status
2323 run : |
24- if [ -z "${{ secrets.DECO_WORKFLOW_TRIGGER_APP_ID }}" ]; then
25- echo "DECO_WORKFLOW_TRIGGER_APP_ID is empty . User has no access to secrets."
26- echo "::set-output name= has_token:: false"
24+ if [ -z "${{ secrets.DECO_WORKFLOW_TRIGGER_APP_ID }}" ] || [ -z "${{ secrets.DECO_TEST_APPROVAL_APP_ID }}" ] ; then
25+ echo "Required secrets are missing . User has no access to secrets."
26+ echo "has_token= false" >> $GITHUB_OUTPUT
2727 else
28- echo "DECO_WORKFLOW_TRIGGER_APP_ID is set. User has access to secrets."
29- echo "::set-output name= has_token:: true"
28+ echo "All required secrets are set. User has access to secrets."
29+ echo "has_token= true" >> $GITHUB_OUTPUT
3030 fi
3131
3232 trigger-tests :
@@ -39,49 +39,80 @@ jobs:
3939 needs : check-token
4040 if : github.event_name == 'pull_request' && needs.check-token.outputs.has_token == 'true'
4141 environment : " test-trigger-is"
42+
4243 steps :
43- - uses : actions/checkout@v4
44+ - uses : actions/checkout@v4
4445
45- - name : Generate GitHub App Token
46- id : generate-token
47- uses : actions/create-github-app-token@v1
48- with :
49- app-id : ${{ secrets.DECO_WORKFLOW_TRIGGER_APP_ID }}
50- private-key : ${{ secrets.DECO_WORKFLOW_TRIGGER_PRIVATE_KEY }}
51- owner : ${{ secrets.ORG_NAME }}
52- repositories : ${{secrets.REPO_NAME}}
53-
54- - name : Trigger Workflow in Another Repo
55- env :
56- GH_TOKEN : ${{ steps.generate-token.outputs.token }}
57- run : |
58- gh workflow run vscode-isolated-pr.yml -R ${{ secrets.ORG_NAME }}/${{secrets.REPO_NAME}} \
59- --ref main \
60- -f pull_request_number=${{ github.event.pull_request.number }} \
61- -f commit_sha=${{ github.event.pull_request.head.sha }}
62-
63- # Statuses and checks apply to specific commits (by hash).
64- # Enforcement of required checks is done both at the PR level and the merge queue level.
65- # In case of multiple commits in a single PR, the hash of the squashed commit
66- # will not match the one for the latest (approved) commit in the PR.
67- # We auto approve the check for the merge queue for two reasons:
68- # * Queue times out due to duration of tests.
69- # * Avoid running integration tests twice, since it was already run at the tip of the branch before squashing.
46+ - name : Generate GitHub App Token for Check Updates
47+ id : generate-check-token
48+ uses : actions/create-github-app-token@v1
49+ with :
50+ app-id : ${{ secrets.DECO_TEST_APPROVAL_APP_ID }}
51+ private-key : ${{ secrets.DECO_TEST_APPROVAL_PRIVATE_KEY }}
52+ owner : databricks
53+
54+ - name : Create Check Run
55+ id : create-check
56+ env :
57+ GH_TOKEN : ${{ steps.generate-check-token.outputs.token }}
58+ run : |
59+ response=$(gh api -X POST \
60+ /repos/${{ github.repository }}/check-runs \
61+ -f name="Integration Tests" \
62+ -f head_sha="${{ github.event.pull_request.head.sha }}" \
63+ -f status="queued" \
64+ -f output[title]="Integration Tests" \
65+ -f output[summary]="Tests queued and will be triggered shortly...")
66+
67+ check_run_id=$(echo "$response" | jq -r .id)
68+ echo "check_run_id=$check_run_id" >> $GITHUB_OUTPUT
69+
70+ - name : Generate GitHub App Token for Workflow Trigger
71+ id : generate-token
72+ uses : actions/create-github-app-token@v1
73+ with :
74+ app-id : ${{ secrets.DECO_WORKFLOW_TRIGGER_APP_ID }}
75+ private-key : ${{ secrets.DECO_WORKFLOW_TRIGGER_PRIVATE_KEY }}
76+ owner : ${{ secrets.ORG_NAME }}
77+ repositories : ${{secrets.REPO_NAME}}
78+
79+ - name : Trigger Workflow in Another Repo
80+ env :
81+ GH_TOKEN : ${{ steps.generate-token.outputs.token }}
82+ run : |
83+ gh workflow run vscode-isolated-pr.yml -R ${{ secrets.ORG_NAME }}/${{secrets.REPO_NAME}} \
84+ --ref deco-26060-vscode-checks-api \
85+ -f pull_request_number=${{ github.event.pull_request.number }} \
86+ -f commit_sha=${{ github.event.pull_request.head.sha }} \
87+ -f check_run_id=${{ steps.create-check.outputs.check_run_id }}
88+
89+ # The hash for the merge queue may not be the same as the hash for the PR.
90+ # Auto approve the check for the merge queue to avoid running integration tests twice.
7091 auto-approve :
7192 if : github.event_name == 'merge_group'
7293
7394 runs-on :
7495 group : databricks-deco-testing-runner-group
7596 labels : ubuntu-latest-deco
7697
98+ permissions :
99+ checks : write
100+ contents : read
101+
77102 steps :
78- - name : Mark Check
79- env :
80- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
81- shell : bash
82- run : |
83- gh api -X POST -H "Accept: application/vnd.github+json" \
84- -H "X-GitHub-Api-Version: 2022-11-28" \
85- /repos/${{ github.repository }}/statuses/${{ github.sha }} \
86- -f 'state=success' \
87- -f 'context=Integration Tests Check'
103+ - name : Auto-approve Check for Merge Queue
104+ uses : actions/github-script@v7
105+ with :
106+ script : |
107+ await github.rest.checks.create({
108+ owner: context.repo.owner,
109+ repo: context.repo.repo,
110+ name: 'Integration Tests',
111+ head_sha: context.sha,
112+ status: 'completed',
113+ conclusion: 'success',
114+ output: {
115+ title: 'Integration Tests',
116+ summary: 'Auto-approved for merge queue (tests already passed on PR)'
117+ }
118+ });
0 commit comments