-
Notifications
You must be signed in to change notification settings - Fork 27
252 lines (227 loc) · 9.49 KB
/
reuse-wf-check-rc-release.yaml
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
---
name: (Reusable workflows) Check airflow provider RC releases and create testing branch
on: # yamllint disable-line rule:truthy
workflow_call:
inputs:
rc_testing_branch:
# If a branch is given, the workflow will use it for deployment and testing.
# If no branch is provided, the workflow will create a new rc testing branch
# for deployment and testing.
description: |
rc_testing_branch: existing testing branch
(Either rc_testing_branch or issue_url is required, and you cannot give both.)
required: false
type: string
default: ""
issue_url:
description: |
issue_url: the GitHub issue URL that tracks the status of Providers release
(Either rc_testing_branch or issue_url is required, and you cannot give both.)
required: false
type: string
default: ""
base_git_rev:
description: "The base git revision to test Providers RCs"
required: false
type: string
default: "main"
git_email:
description: "bot's email for setting up git"
required: true
type: string
git_username:
description: "bot's usernames for setting up git"
required: true
type: string
working_directory:
description: "the path to run scripts"
required: false
type: string
default: ""
secrets:
BOT_ACCESS_TOKEN:
description: "personal access token for the bot to push the commit and create pull request"
required: true
outputs:
rc_testing_branch:
description: "personal access token for the bot to push the commit and create pull request"
value: ${{ jobs.export-rc-testing-branch-name.outputs.rc_testing_branch }}
no_provider_changed:
description: "no provider has been changed in this rc release"
value: ${{ jobs.create-branch-for-testing-rc-release.outputs.no_provider_changed }}
rc_issue_url:
description: "the newly found GitHub issue URL that tracks the status of Providers release"
value: ${{ jobs.check-rc-testing-announcement.outputs.rc_issue_url }}
jobs:
check-rc-testing-announcement:
runs-on: "ubuntu-20.04"
if: github.event_name == 'schedule'
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Checkout apache-airflow
uses: actions/checkout@v3
with:
repository: "apache/airflow"
- name: Parse the latest 100 GitHub issues from apache-airflow to check providers testing announcement
id: parse-airflow-gh-issues
run: |
# The default limit is 30. Set it to 100 for retrieving more issues
rc_issue_url=`gh issue list \
--json createdAt,title,url \
--limit 100 \
--jq 'map(
select(
.title |
contains ("Status of testing Providers that were prepared on ")
)
) | .[0].url'`
echo "rc_issue_url=$rc_issue_url" >> $GITHUB_OUTPUT
- name: Checkout current repo
uses: actions/checkout@v3
if: steps.parse-airflow-gh-issues.outputs.rc_issue_url != ''
- name: Parse the latest GitHub pull requests for checking existing RC provider testing pull request
id: parse-current-repo
if: steps.parse-airflow-gh-issues.outputs.rc_issue_url != ''
run: |
# The default limit is 30. Set it to 100 for retrieving more pull requests
rc_issue_url="${{ steps.parse-airflow-gh-issues.outputs.rc_issue_url }}"
jq_query="map(
select(.title == \"[DO NOT MERGE] Test RC provider packages for $rc_issue_url\")
) | .[0].url"
testing_pr_url=`gh pr list \
--json createdAt,title,url \
--limit 100 \
--state all \
--jq "$jq_query"`
echo "testing_pr_url=$testing_pr_url" >> $GITHUB_OUTPUT
- name: Export rc_issue_url
id: export-rc-issue-url
run: |
rc_issue_url="${{ steps.parse-airflow-gh-issues.outputs.rc_issue_url }}"
testing_pr_url="${{ steps.parse-current-repo.outputs.testing_pr_url }}"
if [ "$rc_issue_url" == "" ] ; then
echo "No RC providers testing announcement found on apache-airflow"
elif [ "$testing_pr_url" != "" ] ; then
echo "Branch for testing RC providers has been created"
rc_issue_url=""
fi
echo "rc_issue_url=$rc_issue_url" >> $GITHUB_OUTPUT
outputs:
rc_issue_url: ${{ steps.export-rc-issue-url.outputs.rc_issue_url }}
validate-manual-input:
runs-on: "ubuntu-20.04"
if: github.event_name == 'workflow_dispatch'
steps:
- name: Validate user input
if: |
(inputs.rc_testing_branch == '' && inputs.issue_url == '') ||
(inputs.rc_testing_branch != '' && inputs.issue_url != '')
run: |
echo "Either rc_testing_branch or issue_url is required, and you cannot give both."
exit 1
create-branch-for-testing-rc-release:
needs: [validate-manual-input, check-rc-testing-announcement]
runs-on: "ubuntu-20.04"
if: |
always() &&
(
(github.event_name == 'workflow_dispatch' && inputs.issue_url != '') ||
(github.event_name == 'schedule' && needs.check-rc-testing-announcement.outputs.rc_issue_url != '')
)
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ inputs.base_git_rev }}
token: ${{ secrets.BOT_ACCESS_TOKEN }}
- name: Install dev dependency
working-directory: ${{ inputs.working_directory }}
run: |
python3 -m pip install -r dev/integration_test_scripts/requirements.txt
- name: Setup Github Actions git user
run: |
git config --global user.email "${{ inputs.git_email }}"
git config --global user.name "${{ inputs.git_username }}"
- name: Export GitHub RC provider testing url
id: export-rc-issue-url
run: |
if [ "${{ inputs.issue_url }}" != "" ] ; then
rc_issue_url="${{ inputs.issue_url }}"
else
rc_issue_url="${{ needs.check-rc-testing-announcement.outputs.rc_issue_url }}"
fi
echo "rc_issue_url=$rc_issue_url"
echo "rc_issue_url=$rc_issue_url" >> $GITHUB_OUTPUT
- name: Update project dependencies to use RC providers
working-directory: ${{ inputs.working_directory }}
run: |
rc_issue_url="${{ steps.export-rc-issue-url.outputs.rc_issue_url }}"
echo "Updating setup.cfg with RC provider packages on $rc_issue_url"
python3 dev/integration_test_scripts/replace_dependencies.py --issue-url $rc_issue_url
- name: Check repo providers updated
id: check-repo-provideres-updated
run: |
difference=`git diff`
if [ -z "$difference" ]
then
echo "No provider changed"
echo "no_provider_changed=true" >> $GITHUB_OUTPUT
else
echo "$difference"
echo "no_provider_changed=false" >> $GITHUB_OUTPUT
fi
- name: Create RC branch
id: create_rc_branch
run: |
if [ "${{ steps.check-repo-provideres-updated.outputs.no_provider_changed }}" != "true" ]
then
current_timestamp=`date +%Y-%m-%dT%H-%M-%S%Z`
echo "Current timestamp is" $current_timestamp
branch_name="rc-test-$current_timestamp"
git checkout -b $branch_name
else
branch_name=""
fi
echo "rc_testing_branch=$branch_name"
echo "rc_testing_branch=$branch_name" >> $GITHUB_OUTPUT
- name: Commit changes and create a pull request
if: steps.create_rc_branch.outputs.rc_testing_branch != ''
env:
GH_TOKEN: ${{ github.token }}
run: |
rc_issue_url="${{ steps.export-rc-issue-url.outputs.rc_issue_url }}"
git add .
git commit -m "Updating setup.cfg with RC provider packages on $rc_issue_url"
git push origin ${{ steps.create_rc_branch.outputs.rc_testing_branch }}
gh pr create --title "[DO NOT MERGE] Test RC provider packages for $rc_issue_url" \
--fill
echo "git_rev=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
outputs:
rc_testing_branch: ${{ steps.create_rc_branch.outputs.rc_testing_branch }}
no_provider_changed: ${{ steps.check-repo-provideres-updated.outputs.no_provider_changed }}
export-rc-testing-branch-name:
needs: [validate-manual-input, create-branch-for-testing-rc-release]
if: |
always() &&
(
needs.create-branch-for-testing-rc-release.result == 'success' &&
needs.create-branch-for-testing-rc-release.outputs.rc_testing_branch != ''
) ||
(
needs.validate-manual-input.result == 'success' &&
inputs.rc_testing_branch
)
runs-on: "ubuntu-20.04"
steps:
- name: export rc_testing_branch
id: export-rc-testing-branch-name-step
run: |
if [ "${{ inputs.rc_testing_branch }}" == "" ]; then
rc_testing_branch=${{ needs.create-branch-for-testing-rc-release.outputs.rc_testing_branch }}
else
rc_testing_branch=${{ inputs.rc_testing_branch }}
fi
echo "rc_testing_branch=$rc_testing_branch" >> $GITHUB_OUTPUT
outputs:
rc_testing_branch: ${{ steps.export-rc-testing-branch-name-step.outputs.rc_testing_branch }}