Skip to content

Commit 12a8245

Browse files
authored
[Internal] Migrate workflows that need write access to use hosted runners (#397)
Fixes #396. Note: the YAML files were unformatted; please review with "hide whitespace".
1 parent 05e57f9 commit 12a8245

File tree

5 files changed

+105
-88
lines changed

5 files changed

+105
-88
lines changed

.github/workflows/external-message.yml

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ on:
1313

1414
jobs:
1515
comment-on-pr:
16-
runs-on: ubuntu-latest
16+
runs-on:
17+
group: databricks-deco-testing-runner-group
18+
labels: ubuntu-latest-deco
19+
1720
permissions:
1821
pull-requests: write
1922

@@ -22,19 +25,19 @@ jobs:
2225

2326
- name: Delete old comments
2427
env:
25-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2629
run: |
27-
# Delete previous comment if it exists
28-
previous_comment_ids=$(gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
29-
--jq '.[] | select(.body | startswith("<!-- INTEGRATION_TESTS_MANUAL -->")) | .id')
30-
echo "Previous comment IDs: $previous_comment_ids"
31-
# Iterate over each comment ID and delete the comment
32-
if [ ! -z "$previous_comment_ids" ]; then
33-
echo "$previous_comment_ids" | while read -r comment_id; do
34-
echo "Deleting comment with ID: $comment_id"
35-
gh api "repos/${{ github.repository }}/issues/comments/$comment_id" -X DELETE
36-
done
37-
fi
30+
# Delete previous comment if it exists
31+
previous_comment_ids=$(gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
32+
--jq '.[] | select(.body | startswith("<!-- INTEGRATION_TESTS_MANUAL -->")) | .id')
33+
echo "Previous comment IDs: $previous_comment_ids"
34+
# Iterate over each comment ID and delete the comment
35+
if [ ! -z "$previous_comment_ids" ]; then
36+
echo "$previous_comment_ids" | while read -r comment_id; do
37+
echo "Deleting comment with ID: $comment_id"
38+
gh api "repos/${{ github.repository }}/issues/comments/$comment_id" -X DELETE
39+
done
40+
fi
3841
3942
- name: Comment on PR
4043
env:
@@ -44,13 +47,13 @@ jobs:
4447
gh pr comment ${{ github.event.pull_request.number }} --body \
4548
"<!-- INTEGRATION_TESTS_MANUAL -->
4649
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:
47-
50+
4851
Trigger:
4952
[go/deco-tests-run/sdk-java](https://go/deco-tests-run/sdk-java)
5053
5154
Inputs:
5255
* PR number: ${{github.event.pull_request.number}}
5356
* Commit SHA: \`${{ env.COMMIT_SHA }}\`
54-
57+
5558
Checks will be approved automatically on success.
5659
"
Lines changed: 77 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,87 @@
11
name: Integration Tests
22

33
on:
4-
pull_request:
5-
types: [opened, synchronize]
4+
pull_request:
5+
types: [opened, synchronize]
66

7-
merge_group:
7+
merge_group:
88

99
jobs:
10-
check-token:
11-
name: Check secrets access
12-
runs-on: ubuntu-latest
13-
environment: "test-trigger-is"
14-
outputs:
15-
has_token: ${{ steps.set-token-status.outputs.has_token }}
16-
steps:
17-
- name: Check if DECO_WORKFLOW_TRIGGER_APP_ID is set
18-
id: set-token-status
19-
run: |
20-
if [ -z "${{ secrets.DECO_WORKFLOW_TRIGGER_APP_ID }}" ]; then
21-
echo "DECO_WORKFLOW_TRIGGER_APP_ID is empty. User has no access to secrets."
22-
echo "::set-output name=has_token::false"
23-
else
24-
echo "DECO_WORKFLOW_TRIGGER_APP_ID is set. User has access to secrets."
25-
echo "::set-output name=has_token::true"
26-
fi
10+
check-token:
11+
name: Check secrets access
2712

28-
trigger-tests:
29-
name: Trigger Tests
30-
runs-on: ubuntu-latest
31-
needs: check-token
32-
if: github.event_name == 'pull_request' && needs.check-token.outputs.has_token == 'true'
33-
environment: "test-trigger-is"
34-
steps:
35-
- uses: actions/checkout@v3
13+
runs-on:
14+
group: databricks-deco-testing-runner-group
15+
labels: ubuntu-latest-deco
3616

37-
- name: Generate GitHub App Token
38-
id: generate-token
39-
uses: actions/create-github-app-token@v1
40-
with:
41-
app-id: ${{ secrets.DECO_WORKFLOW_TRIGGER_APP_ID }}
42-
private-key: ${{ secrets.DECO_WORKFLOW_TRIGGER_PRIVATE_KEY }}
43-
owner: ${{ secrets.ORG_NAME }}
44-
repositories: ${{secrets.REPO_NAME}}
17+
environment: "test-trigger-is"
18+
outputs:
19+
has_token: ${{ steps.set-token-status.outputs.has_token }}
20+
steps:
21+
- name: Check if DECO_WORKFLOW_TRIGGER_APP_ID is set
22+
id: set-token-status
23+
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"
27+
else
28+
echo "DECO_WORKFLOW_TRIGGER_APP_ID is set. User has access to secrets."
29+
echo "::set-output name=has_token::true"
30+
fi
4531
46-
- name: Trigger Workflow in Another Repo
47-
env:
48-
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
49-
run: |
50-
gh workflow run sdk-java-isolated-pr.yml -R ${{ secrets.ORG_NAME }}/${{secrets.REPO_NAME}} \
51-
--ref main \
52-
-f pull_request_number=${{ github.event.pull_request.number }} \
53-
-f commit_sha=${{ github.event.pull_request.head.sha }}
32+
trigger-tests:
33+
name: Trigger Tests
5434

55-
# Statuses and checks apply to specific commits (by hash).
56-
# Enforcement of required checks is done both at the PR level and the merge queue level.
57-
# In case of multiple commits in a single PR, the hash of the squashed commit
58-
# will not match the one for the latest (approved) commit in the PR.
59-
# We auto approve the check for the merge queue for two reasons:
60-
# * Queue times out due to duration of tests.
61-
# * Avoid running integration tests twice, since it was already run at the tip of the branch before squashing.
62-
auto-approve:
63-
if: github.event_name == 'merge_group'
64-
runs-on: ubuntu-latest
65-
steps:
66-
- name: Mark Check
67-
env:
68-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69-
shell: bash
70-
run: |
71-
gh api -X POST -H "Accept: application/vnd.github+json" \
72-
-H "X-GitHub-Api-Version: 2022-11-28" \
73-
/repos/${{ github.repository }}/statuses/${{ github.sha }} \
74-
-f 'state=success' \
75-
-f 'context=Integration Tests Check'
35+
runs-on:
36+
group: databricks-deco-testing-runner-group
37+
labels: ubuntu-latest-deco
38+
39+
needs: check-token
40+
if: github.event_name == 'pull_request' && needs.check-token.outputs.has_token == 'true'
41+
environment: "test-trigger-is"
42+
steps:
43+
- uses: actions/checkout@v3
44+
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 sdk-java-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.
70+
auto-approve:
71+
if: github.event_name == 'merge_group'
72+
73+
runs-on:
74+
group: databricks-deco-testing-runner-group
75+
labels: ubuntu-latest-deco
76+
77+
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'

.github/workflows/message.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ jobs:
2424
TITLE: ${{ github.event.pull_request.title }}
2525
run: |
2626
TAG=$(echo "$TITLE" | sed -ne 's/\[\(.*\)\].*/\1/p')
27-
if grep -q "tag: \"\[$TAG\]\"" .codegen/changelog_config.yml; then
27+
if grep -q "tag: \"\[$TAG\]\"" .codegen/changelog_config.yml; then
2828
echo "Valid tag found: [$TAG]"
29-
else
30-
echo "Invalid or missing tag in commit message: [$TAG]"
29+
else
30+
echo "Invalid or missing tag in commit message: [$TAG]"
3131
exit 1
32-
fi
32+
fi

.github/workflows/push.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
fail-fast: false
3434
matrix:
3535
os: [macos-latest, ubuntu-latest]
36-
java-version: [8, 11, 17, 20] # 20 is the latest version as of 2023 and 17 is the latest LTS
36+
java-version: [8, 11, 17, 20] # 20 is the latest version as of 2023 and 17 is the latest LTS
3737

3838
runs-on: ${{ matrix.os }}
3939

@@ -55,4 +55,3 @@ jobs:
5555

5656
- name: Check Unit Tests
5757
run: mvn --errors test
58-

.github/workflows/release.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ name: Release
22
on:
33
push:
44
tags:
5-
- 'v*'
5+
- "v*"
66
jobs:
77
publish:
8-
runs-on: ubuntu-latest
8+
runs-on:
9+
group: databricks-deco-testing-runner-group
10+
labels: ubuntu-latest-deco
11+
912
steps:
1013
- name: Checkout
1114
uses: actions/checkout@v2

0 commit comments

Comments
 (0)