forked from apache/airflow
-
Notifications
You must be signed in to change notification settings - Fork 0
177 lines (176 loc) · 8.49 KB
/
label_when_reviewed_workflow_run.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
---
name: Label when reviewed workflow run
on: # yamllint disable-line rule:truthy
workflow_run:
workflows: ["Label when reviewed"]
types: ['requested']
permissions:
# All other permissions are set to none
checks: write
contents: read
pull-requests: write
jobs:
label-when-reviewed:
name: "Label PRs when reviewed workflow run"
runs-on: ubuntu-20.04
outputs:
labelSet: ${{ steps.label-when-reviewed.outputs.labelSet }}
steps:
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v2
with:
persist-credentials: false
submodules: recursive
- name: "Get information about the original trigger of the run"
uses: ./.github/actions/get-workflow-origin
id: source-run-info
with:
token: ${{ secrets.GITHUB_TOKEN }}
sourceRunId: ${{ github.event.workflow_run.id }}
- name: Initiate Selective Build check
uses: ./.github/actions/checks-action
id: selective-build-check
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: "Selective build check"
status: "in_progress"
sha: ${{ steps.source-run-info.outputs.sourceHeadSha }}
details_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
output: >
{"summary":
"Checking selective status of the build in
[the run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
"}
- name: >
Event: ${{ steps.source-run-info.outputs.sourceEvent }}
Repo: ${{ steps.source-run-info.outputs.sourceHeadRepo }}
Branch: ${{ steps.source-run-info.outputs.sourceHeadBranch }}
Run id: ${{ github.run_id }}
Source Run id: ${{ github.event.workflow_run.id }}
Sha: ${{ github.sha }}
Source Sha: ${{ steps.source-run-info.outputs.sourceHeadSha }}
Merge commit Sha: ${{ steps.source-run-info.outputs.mergeCommitSha }}
Target commit Sha: ${{ steps.source-run-info.outputs.targetCommitSha }}
run: printenv
- name: >
Fetch incoming commit ${{ steps.source-run-info.outputs.targetCommitSha }} with its parent
uses: actions/checkout@v2
with:
ref: ${{ steps.source-run-info.outputs.targetCommitSha }}
fetch-depth: 2
persist-credentials: false
# checkout the main branch again, to use the right script in main workflow
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v2
with:
persist-credentials: false
submodules: recursive
- name: Selective checks
id: selective-checks
env:
EVENT_NAME: ${{ steps.source-run-info.outputs.sourceEvent }}
TARGET_COMMIT_SHA: ${{ steps.source-run-info.outputs.targetCommitSha }}
PR_LABELS: ${{ steps.source-run-info.outputs.pullRequestLabels }}
run: |
if [[ ${EVENT_NAME} == "pull_request_review" ]]; then
# Run selective checks
./scripts/ci/selective_ci_checks.sh "${TARGET_COMMIT_SHA}"
else
# Run all checks
./scripts/ci/selective_ci_checks.sh
fi
- name: "Label when approved by committers for PRs that require full tests"
uses: ./.github/actions/label-when-approved-action
id: label-full-test-prs-when-approved-by-commiters
if: >
steps.selective-checks.outputs.run-tests == 'true' &&
contains(steps.selective-checks.outputs.test-types, 'Core')
with:
token: ${{ secrets.GITHUB_TOKEN }}
label: 'full tests needed'
require_committers_approval: 'true'
remove_label_when_approval_missing: 'false'
pullRequestNumber: ${{ steps.source-run-info.outputs.pullRequestNumber }}
comment: >
The PR most likely needs to run full matrix of tests because it modifies parts of the core
of Airflow. However, committers might decide to merge it quickly and take the risk.
If they don't merge it quickly - please rebase it to the latest main at your convenience,
or amend the last commit of the PR, and push it with --force-with-lease.
- name: "Initiate GitHub Check forcing rerun of SH ${{ github.event.pull_request.head.sha }}"
uses: ./.github/actions/checks-action
id: full-test-check
if: steps.label-full-test-prs-when-approved-by-commiters.outputs.labelSet == 'true'
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: "Please rebase or amend, and force push the PR to run full tests"
status: "in_progress"
sha: ${{ steps.source-run-info.outputs.sourceHeadSha }}
details_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
output: >
{"summary":
"The PR likely needs to run all tests! This was determined via selective check in
[the run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
"}
- name: "Label when approved by committers for PRs that do not require full tests"
uses: ./.github/actions/label-when-approved-action
id: label-simple-test-prs-when-approved-by-commiters
if: >
steps.selective-checks.outputs.run-tests == 'true' &&
! contains(steps.selective-checks.outputs.test-types, 'Core')
with:
token: ${{ secrets.GITHUB_TOKEN }}
label: 'okay to merge'
require_committers_approval: 'true'
pullRequestNumber: ${{ steps.source-run-info.outputs.pullRequestNumber }}
comment: >
The PR is likely OK to be merged with just subset of tests for default Python and Database
versions without running the full matrix of tests, because it does not modify the core of
Airflow. If the committers decide that the full tests matrix is needed, they will add the label
'full tests needed'. Then you should rebase to the latest main or amend the last commit
of the PR, and push it with --force-with-lease.
- name: "Label when approved by committers for PRs that do not require tests at all"
uses: ./.github/actions/label-when-approved-action
id: label-no-test-prs-when-approved-by-commiters
if: steps.selective-checks.outputs.run-tests != 'true'
with:
token: ${{ secrets.GITHUB_TOKEN }}
label: 'okay to merge'
pullRequestNumber: ${{ steps.source-run-info.outputs.pullRequestNumber }}
require_committers_approval: 'true'
comment: >
The PR is likely ready to be merged. No tests are needed as no important environment files,
nor python files were modified by it. However, committers might decide that full test matrix is
needed and add the 'full tests needed' label. Then you should rebase it to the latest main
or amend the last commit of the PR, and push it with --force-with-lease.
- name: Update Selective Build check
uses: ./.github/actions/checks-action
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
check_id: ${{ steps.selective-build-check.outputs.check_id }}
status: "completed"
sha: ${{ steps.source-run-info.outputs.sourceHeadSha }}
conclusion: ${{ job.status }}
details_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
output: >
{"summary":
"Checking selective status of the build completed in
[the run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
"}