-
Notifications
You must be signed in to change notification settings - Fork 191
152 lines (137 loc) · 5.93 KB
/
test.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Test Workflow
# Test Workflow is executed when workflow changes are being made. For
# development repos, this is testing every workflow modification For other
# repos, this is effectively testing release PRs to development as workflow
# changes are not made directly to those repos.
on:
pull_request_target:
types: [opened, synchronize, reopened]
jobs:
check-contributor:
name: Check contributor
uses: ./.github/workflows/check-contributor.yml
with:
user: ${{ github.event.pull_request.user.login }}
determine-workflow-conditions:
name: Determine Workflow Conditions
needs: [check-contributor]
runs-on: ubuntu-22.04
if: |
github.event.pull_request.draft == false &&
needs.check-contributor.outputs.is-repo-owner == 'true'
outputs:
run-tests: ${{ steps.check_request.outputs.run-tests }}
is-charts-release-branch: ${{ steps.check_if_release_pr.outputs.charts_release_branch }}
test-tags: ${{ steps.determine-test-tags.outputs.test-tags }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.BOT_TOKEN }}
fetch-depth: 0
- name: Set up Python
uses: ./.github/actions/setup-python
- name: Set up Python 3.x Part 2
run: |
# set up python requirements and scripts
python3 -m venv ve1
cd scripts
../ve1/bin/pip3 install -r requirements.txt
../ve1/bin/pip3 install .
cd ..
- name: Check Request
id: check_request
env:
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
# check if workflow testing should run.
echo "[INFO] check if PR contains only workflow changes and user is authorized"
ve1/bin/check-pr-for-ci --verify-user=${{ github.event.pull_request.user.login }} --api-url=${{ github.event.pull_request._links.self.href }}
- name: Check Request Result
id: check_request_result
if: |
steps.check_request.outputs.workflow-only-but-not-authorized == 'true'
run: |
# workflow only change but user not authorized
exit 1
# BUG: This task attempts to run the `full` behave tag if the PR under
# test is a release from dev to prod, but the matcher condition that would
# emit this appears broken. Investigate the setting of the
# charts_release_branch output, or just run smoke tests and remove the
# condition associated with this output.
- name: (PR) check for release flow
id: check_if_release_pr
if: |
github.event_name == 'pull_request_target' && steps.check_request.outputs.run-tests == 'true'
env:
BOT_NAME: ${{ secrets.BOT_NAME }}
run: |
# check if PR was created as part of release processing
# mitigate unmatched quote error in bash
pr_body=$(cat <<EOF | xargs -0 printf '%q'
${{ github.event.pull_request.body }}
EOF
)
./ve1/bin/release-checker --api-url=${{ github.event.pull_request._links.self.href }} \
--sender='${{ github.event.sender.login }}' \
--pr_branch='${{ github.event.pull_request.head.ref }}' \
--pr_body="${pr_body}" \
--pr_base_repo='${{ github.event.pull_request.base.repo.full_name }}' \
--pr_head_repo='${{ github.event.pull_request.head.repo.full_name }}'
- name: Determine test tags
id: determine-test-tags
if: steps.check_request.outputs.run-tests == 'true'
run: |
echo "Full test in pr : ${{ steps.check_request.outputs.full_tests_in_pr }}"
echo "Is charts release branch : ${{ steps.check_request.outputs.full_tests_in_pr }}"
if ${{ steps.check_if_release_pr.outputs.charts_release_branch == 'true' || steps.check_request.outputs.full_tests_in_pr == 'true' }} ; then
echo "Release PR from dev to charts, or PR with new full test, so running full tests"
echo "test-tags=full" | tee -a $GITHUB_OUTPUT
exit 0
fi
echo "Not a release PR from dev to charts, so running only smoke tests"
echo "test-tags=smoke" | tee -a $GITHUB_OUTPUT
run-tests:
# No further pull request author checking done here because
# check-contributor gates the needed jobs.
name: Run Tests
needs:
- determine-workflow-conditions
if: |
needs.determine-workflow-conditions.outputs.run-tests == 'true'
uses: ./.github/workflows/behave.yml
with:
# Default tags to 'full' if test-tags is unset for any reason by the time
# we get here.
tags: ${{ needs.determine-workflow-conditions.outputs.test-tags || 'full' }}
behave-logging-level: WARNING
pr-body: "Test triggered by release PR ${{ github.event.pull_request.html_url }}."
# checkout parameters passed to ensure we're testing the release content
checkout-fetch-depth: 0
checkout-repository: ${{ github.event.pull_request.head.repo.full_name }}
checkout-ref: ${{ github.event.pull_request.head.sha }}
secrets:
bot-name: ${{ secrets.BOT_NAME }}
bot-token: ${{ secrets.BOT_TOKEN }}
approve-and-merge:
name: Approve and merge
needs:
- determine-workflow-conditions
- run-tests
runs-on: ubuntu-22.04
if: needs.determine-workflow-conditions.outputs.is-charts-release-branch == 'true'
steps:
- name: Approve PR
id: approve_pr
uses: hmarr/auto-approve-action@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Merge PR
id: merge_pr
uses: pascalgn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MERGE_METHOD: squash
MERGE_LABELS: ""