-
Notifications
You must be signed in to change notification settings - Fork 400
82 lines (71 loc) · 2.97 KB
/
integration-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Integration Tests
on:
pull_request:
types: [opened, synchronize]
merge_group:
jobs:
check-integration-test-changes:
if: github.event_name == 'pull_request'
name: Check if changes require integration tests to be triggered
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v3
with:
# integration_tests_required should be true if integration tests should be run.
# - Any PRs that only modify documentation should not require integration tests to run.
filters: |
integration_tests_required:
- '!**/*.md'
trigger-tests:
needs: check-integration-test-changes
if: '{{ env.integration_tests_required == "true" }}'
name: Trigger Tests
runs-on: ubuntu-latest
environment: "test-trigger-is"
steps:
- uses: actions/checkout@v3
- name: Generate GitHub App Token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.DECO_WORKFLOW_TRIGGER_APP_ID }}
private-key: ${{ secrets.DECO_WORKFLOW_TRIGGER_PRIVATE_KEY }}
owner: ${{ secrets.ORG_NAME }}
repositories: ${{secrets.REPO_NAME}}
- name: Trigger Workflow in Another Repo
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
gh workflow run terraform-isolated-pr.yml -R ${{ secrets.ORG_NAME }}/${{secrets.REPO_NAME}} \
--ref main \
-f pull_request_number=${{ github.event.pull_request.number }} \
-f commit_sha=${{ github.event.pull_request.head.sha }}
# Statuses and checks apply to specific commits (by hash).
# Enforcement of required checks is done both at the PR level and the merge queue level.
# In case of multiple commits in a single PR, the hash of the squashed commit
# will not match the one for the latest (approved) commit in the PR.
# We auto approve the check for the merge queue for two reasons:
# * Queue times out due to duration of tests.
# * Avoid running integration tests twice, since it was already run at the tip of the branch before squashing.
# Additionally, integration tests are not run on docs-only changes.
auto-approve:
needs: check-integration-test-changes
if: '{{ github.event_name == "merge_group" || env.integration_tests_required == "false" }}'
runs-on: ubuntu-latest
steps:
- name: Mark Check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
if [ "${{ github.event_name }}" == "merge_group" ]; then
echo "Auto-approving check for merge queue"
else
echo "Auto-approving check for docs-only changes"
fi
gh api -X POST -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{ github.repository }}/statuses/${{ github.sha }} \
-f 'state=success' \
-f 'context=Integration Tests Check'