-
Notifications
You must be signed in to change notification settings - Fork 13
163 lines (149 loc) · 6.53 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
152
153
154
155
156
157
158
159
160
161
name: Test Workflow
on:
pull_request_target:
types: [opened, synchronize, reopened]
workflow_dispatch:
inputs:
dry-run:
description: "Run tests but do not create issues {true,false}"
required: true
default: "true"
vendor-type:
description: "Vendor type {all,partner,redhat,community}"
required: true
default: "all"
software-name:
description: "Software Name"
required: true
software-version:
description: "Software Version"
required: true
notify-id:
description: "(Optional) Issue notification {github id}"
required: false
default: ""
jobs:
check-contributor:
name: Check contributor
uses: ./.github/workflows/check-contributor.yml
with:
user: ${{ github.event.pull_request.user.login }}
workflow-test:
name: Workflow Test
needs: [check-contributor]
runs-on: ubuntu-22.04
if: |
github.event.pull_request.draft == false &&
needs.check-contributor.outputs.is-repo-owner == 'true'
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 3.x Part 1
uses: actions/setup-python@v5
with:
python-version: "3.10"
- 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 "Request type: '$GITHUB_EVENT_NAME'"
if [ "$GITHUB_EVENT_NAME" == "pull_request_target" ]; then
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 }}
else
echo "[INFO] manual invocation - check if user is authorized"
ve1/bin/check-pr-for-ci --verify-user=${{ github.actor }}
fi
- 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
- 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: (PR) Test CI Workflow
if: |
github.event_name == 'pull_request_target' && steps.check_request.outputs.run-tests == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BOT_NAME: ${{ secrets.BOT_NAME }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_BODY: "Test triggered by ${{ github.event.pull_request.html_url }}."
run: |
echo "Full test in pr : ${{ 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, oer PR with new full test, so running full tests"
ve1/bin/behave tests/functional/behave_features/ --tags=full --logging-level=WARNING --no-capture --no-color
else
echo "Not a release PR from dev to charts, so running only smoke tests"
ve1/bin/behave tests/functional/behave_features/ --tags=smoke --logging-level=WARNING --no-capture --no-color
fi
- name: (Manual) Test CI Workflow
if: |
github.event_name == 'workflow_dispatch' && steps.check_request.outputs.run-tests == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DRY_RUN: ${{ github.event.inputs.dry-run }}
VENDOR_TYPE: ${{ github.event.inputs.vendor-type }}
NOTIFY_ID: ${{ github.event.inputs.notify-id }}
SOFTWARE_NAME: ${{ github.event.inputs.software-name }}
SOFTWARE_VERSION: ${{ github.event.inputs.software-version }}
BOT_NAME: ${{ secrets.BOT_NAME }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
PR_BODY: "Triggerd by ${{ github.event.sender.html_url }} from ${{ github.event.repository.html_url }} on `${{ github.event.ref }}`."
run: |
echo "[INFO] Dry run '${{ env.DRY_RUN }}'"
echo "[INFO] Vendor type '${{ env.VENDOR_TYPE }}'"
echo "[INFO] Notify ID '${{ env.NOTIFY_ID }}'"
echo "[INFO] Software Name '${{ env.SOFTWARE_NAME }}'"
echo "[INFO] Software Version '${{ env.SOFTWARE_VERSION }}'"
ve1/bin/behave tests/functional/behave_features/ --tags=version-change --logging-level=WARNING --no-capture --no-color
- name: Approve PR
id: approve_pr
if: ${{ steps.check_if_release_pr.outputs.charts_release_branch == 'true' }}
uses: hmarr/auto-approve-action@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Merge PR
id: merge_pr
if: ${{ steps.check_if_release_pr.outputs.charts_release_branch == 'true' }}
uses: pascalgn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MERGE_METHOD: squash
MERGE_LABELS: ""