Skip to content

Commit 37eaac3

Browse files
authored
The PRs which are not approved run subset of tests (#11828)
This PR is an implementation of optimisation - to only run default values for build matrix in case PR does not have "okay to test" label. This "okay to test" label is set when the PR gets approved but it was not approved before, also then a comment is generated urging the committer to rebase the PR to run full set of tests. Additionally a check is added (in-progress) that makes the PR not yet ready to be merged. Only after re-running it it will become truly readty to be merged.
1 parent 4cb0621 commit 37eaac3

File tree

10 files changed

+276
-29
lines changed

10 files changed

+276
-29
lines changed

.github/workflows/build-images-workflow-run.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ jobs:
5353
sourceHeadSha: ${{ steps.source-run-info.outputs.sourceHeadSha }}
5454
mergeCommitSha: ${{ steps.source-run-info.outputs.mergeCommitSha }}
5555
targetCommitSha: ${{ steps.source-run-info.outputs.targetCommitSha }}
56-
pullRequestNumber: ${{ steps.workflow-run-info.outputs.pullRequestNumber }}
57-
pullRequestLabels: ${{ steps.workflow-run-info.outputs.pullRequestLabels }}
56+
pullRequestNumber: ${{ steps.source-run-info.outputs.pullRequestNumber }}
57+
pullRequestLabels: ${{ steps.source-run-info.outputs.pullRequestLabels }}
5858
sourceEvent: ${{ steps.source-run-info.outputs.sourceEvent }}
5959
cacheDirective: ${{ steps.cache-directive.outputs.docker-cache }}
6060
buildImages: ${{ steps.build-images.outputs.buildImages }}
6161
upgradeToLatestConstraints: ${{ steps.upgrade-constraints.outputs.upgradeToLatestConstraints }}
6262
steps:
6363
- name: "Get information about the original trigger of the run"
64-
uses: potiuk/get-workflow-origin@e3ba776faee1134e17551924b852bfb374e1703d # v1_1
64+
uses: potiuk/get-workflow-origin@2ef0b065db6b688a2231f8a7f464df1aac254328 # v1_2
6565
id: source-run-info
6666
with:
6767
token: ${{ secrets.GITHUB_TOKEN }}
@@ -228,6 +228,7 @@ jobs:
228228
env:
229229
EVENT_NAME: ${{ needs.cancel-workflow-runs.outputs.sourceEvent }}
230230
INCOMING_COMMIT_SHA: ${{ needs.cancel-workflow-runs.outputs.targetCommitSha }}
231+
PR_LABELS: ${{ needs.cancel-workflow-runs.outputs.pullRequestLabels }}
231232
run: |
232233
if [[ ${EVENT_NAME} == "pull_request" ]]; then
233234
# Run selective checks

.github/workflows/ci.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ jobs:
7171
outputs:
7272
waitForImage: ${{ steps.wait-for-image.outputs.wait-for-image }}
7373
pythonVersions: ${{ steps.selective-checks.outputs.python-versions }}
74+
pythonVersionsListAsString: ${{ steps.selective-checks.outputs.python-versions-list-as-string }}
7475
defaultPythonVersion: ${{ steps.selective-checks.outputs.default-python-version }}
7576
kubernetesVersions: ${{ steps.selective-checks.outputs.kubernetes-versions }}
7677
defaultKubernetesVersion: ${{ steps.selective-checks.outputs.default-kubernetes-version }}
@@ -98,7 +99,7 @@ jobs:
9899
pullRequestLabels: ${{ steps.source-run-info.outputs.pullRequestLabels }}
99100
steps:
100101
- name: "Get information about the PR"
101-
uses: potiuk/get-workflow-origin@e3ba776faee1134e17551924b852bfb374e1703d # v1_1
102+
uses: potiuk/get-workflow-origin@2ef0b065db6b688a2231f8a7f464df1aac254328 # v1_2
102103
id: source-run-info
103104
with:
104105
token: ${{ secrets.GITHUB_TOKEN }}
@@ -131,6 +132,7 @@ jobs:
131132
env:
132133
EVENT_NAME: ${{ github.event_name }}
133134
INCOMING_COMMIT_SHA: ${{ github.sha }}
135+
PR_LABELS: "${{ steps.source-run-info.outputs.pullRequestLabels }}"
134136
run: |
135137
if [[ ${EVENT_NAME} == "pull_request" ]]; then
136138
# Run selective checks
@@ -189,6 +191,9 @@ jobs:
189191
- name: >
190192
Wait for CI images
191193
${{ needs.build-info.outputs.pythonVersions }}:${{ env.GITHUB_REGISTRY_PULL_IMAGE_TAG }}"
194+
env:
195+
CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING: >
196+
${{needs.build-info.outputs.pythonVersionsListAsString}}
192197
# We wait for the images to be available either from the build-ci-image step or from
193198
# "build-images-workflow-run.yml' run as pull_request_target (it has the write
194199
# permissions in case pull_request from fork is run.
@@ -469,7 +474,7 @@ jobs:
469474

470475

471476
tests-postgres:
472-
timeout-minutes: 60
477+
timeout-minutes: 80
473478
name: >
474479
Postgres${{matrix.postgres-version}},Py${{matrix.python-version}}:
475480
${{needs.build-info.outputs.testTypes}}
@@ -523,7 +528,7 @@ jobs:
523528
path: "./files/coverage.xml"
524529

525530
tests-mysql:
526-
timeout-minutes: 60
531+
timeout-minutes: 80
527532
name: >
528533
MySQL${{matrix.mysql-version}}, Py${{matrix.python-version}}: ${{needs.build-info.outputs.testTypes}}
529534
runs-on: ubuntu-latest
@@ -745,6 +750,9 @@ jobs:
745750
- name: >
746751
Wait for PROD images
747752
${{ needs.build-info.outputs.pythonVersions }}:${{ env.GITHUB_REGISTRY_PULL_IMAGE_TAG }}"
753+
env:
754+
CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING: >
755+
${{needs.build-info.outputs.pythonVersionsListAsString}}
748756
run: ./scripts/ci/images/ci_wait_for_all_prod_images.sh
749757
if: needs.build-info.outputs.waitForImage == 'true'
750758

.github/workflows/codeql-analysis.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
118
---
219
name: "CodeQL"
320

.github/workflows/delete_old_artifacts.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
118
---
219
name: 'Delete old artifacts'
320
on: # yamllint disable-line rule:truthy
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
---
19+
name: Label when reviewed
20+
on: pull_request_review # yamllint disable-line rule:truthy
21+
22+
jobs:
23+
24+
label-when-reviewed:
25+
name: "Label PRs when reviewed"
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: "Do nothing. Only trigger corresponding workflow_run event"
29+
run: echo
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
---
19+
name: Label when reviewed workflow run
20+
on: # yamllint disable-line rule:truthy
21+
workflow_run:
22+
workflows: ["Label when reviewed"]
23+
types: ['requested']
24+
jobs:
25+
26+
label-when-reviewed:
27+
name: "Label PRs when reviewed workflow run"
28+
runs-on: ubuntu-latest
29+
outputs:
30+
labelSet: ${{ steps.label-when-reviewed.outputs.labelSet }}
31+
steps:
32+
- name: "Get information about the original trigger of the run"
33+
uses: potiuk/get-workflow-origin@2ef0b065db6b688a2231f8a7f464df1aac254328 # v1_2
34+
id: source-run-info
35+
with:
36+
token: ${{ secrets.GITHUB_TOKEN }}
37+
sourceRunId: ${{ github.event.workflow_run.id }}
38+
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
39+
uses: actions/checkout@v2
40+
- name: >
41+
Event: ${{ steps.source-run-info.outputs.sourceEvent }}
42+
Repo: ${{ steps.source-run-info.outputs.sourceHeadRepo }}
43+
Branch: ${{ steps.source-run-info.outputs.sourceHeadBranch }}
44+
Run id: ${{ github.run_id }}
45+
Source Run id: ${{ github.event.workflow_run.id }}
46+
Sha: ${{ github.sha }}
47+
Source Sha: ${{ steps.source-run-info.outputs.sourceHeadSha }}
48+
Merge commit Sha: ${{ steps.source-run-info.outputs.mergeCommitSha }}
49+
Target commit Sha: ${{ steps.source-run-info.outputs.targetCommitSha }}
50+
run: printenv
51+
- name: >
52+
Fetch incoming commit ${{ steps.source-run-info.outputs.targetCommitSha }} with its parent
53+
uses: actions/checkout@v2
54+
with:
55+
ref: ${{ steps.source-run-info.outputs.targetCommitSha }}
56+
fetch-depth: 2
57+
# checkout the master version again, to use the right script in master workflow
58+
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
59+
uses: actions/checkout@v2
60+
- name: Selective checks
61+
id: selective-checks
62+
env:
63+
EVENT_NAME: ${{ steps.source-run-info.outputs.sourceEvent }}
64+
INCOMING_COMMIT_SHA: ${{ steps.source-run-info.outputs.targetCommitSha }}
65+
PR_LABELS: ${{ steps.source-run-info.outputs.pullRequestLabels }}
66+
run: |
67+
if [[ ${EVENT_NAME} == "pull_request_review" ]]; then
68+
# Run selective checks
69+
./scripts/ci/selective_ci_checks.sh "${INCOMING_COMMIT_SHA}"
70+
else
71+
# Run all checks
72+
./scripts/ci/selective_ci_checks.sh
73+
fi
74+
- name: "Label when approved by committers for PRs that require full tests"
75+
uses: TobKed/label-when-approved-action@7872312da76508d29f98d4fa68843ea91754cc59 # v1.2
76+
id: label-full-test-prs-when-approved-by-commiters
77+
if: >
78+
steps.selective-checks.outputs.run-tests == 'true' &&
79+
contains(steps.selective-checks.outputs.test-types, 'Core')
80+
with:
81+
token: ${{ secrets.GITHUB_TOKEN }}
82+
label: 'full tests needed'
83+
require_committers_approval: 'true'
84+
pullRequestNumber: ${{ steps.source-run-info.outputs.pullRequestNumber }}
85+
comment: >
86+
The PR needs to run all tests because it modifies core of Airflow! Please rebase it to latest
87+
master or ask committer to re-run it!
88+
- name: "Initiate GitHub Check forcing rerun of SH ${{ github.event.pull_request.head.sha }}"
89+
uses: LouisBrunner/checks-action@9f02872da71b6f558c6a6f190f925dde5e4d8798 # v1.1.0
90+
id: full-test-check
91+
if: steps.label-full-test-prs-when-approved-by-commiters.outputs.labelSet == 'true'
92+
with:
93+
token: ${{ secrets.GITHUB_TOKEN }}
94+
name: "Please rebase or re-run to run full tests"
95+
status: "in_progress"
96+
sha: ${{ github.event.pull_request.head.sha }}
97+
details_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
98+
output: >
99+
{"summary":
100+
"The PR needs to run all tests! This was determined via
101+
[the run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
102+
"}
103+
- name: "Label when approved by committers for PRs that do not require full tests"
104+
uses: TobKed/label-when-approved-action@7872312da76508d29f98d4fa68843ea91754cc59 # v1.2
105+
id: label-simple-test-prs-when-approved-by-commiters
106+
if: >
107+
steps.selective-checks.outputs.run-tests == 'true' &&
108+
! contains(steps.selective-checks.outputs.test-types, 'Core')
109+
with:
110+
token: ${{ secrets.GITHUB_TOKEN }}
111+
label: 'okay to merge'
112+
require_committers_approval: 'true'
113+
pullRequestNumber: ${{ steps.source-run-info.outputs.pullRequestNumber }}
114+
comment: >
115+
The PR should be OK to be merged with just subset of tests as it does not modify Core of
116+
Airflow. The committers might merge it or can add a label 'full tests needed' and re-run it
117+
to run all tests if they see it is needed!
118+
- name: "Label when approved by committers for PRs that do not require tests at all"
119+
uses: TobKed/label-when-approved-action@7872312da76508d29f98d4fa68843ea91754cc59 # v1.2
120+
id: label-no-test-prs-when-approved-by-commiters
121+
if: steps.selective-checks.outputs.run-tests != 'true'
122+
with:
123+
token: ${{ secrets.GITHUB_TOKEN }}
124+
label: 'okay to merge'
125+
pullRequestNumber: ${{ steps.source-run-info.outputs.pullRequestNumber }}
126+
require_committers_approval: 'true'
127+
comment: "The PR is ready to be merged. No tests are needed!"

airflow/providers/google/backport_provider_setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# NOTE! THIS FILE IS AUTOMATICALLY GENERATED AND WILL BE\
2020
# OVERWRITTEN WHEN RUNNING
2121
#
22-
# ./breeze prepare-provider-readme
22+
# ./breeze prepare-provider-readmes
2323
#
2424
# IF YOU WANT TO MODIFY IT, YOU SHOULD MODIFY THE TEMPLATE
2525
# `SETUP_TEMPLATE.py.jinja2` IN the `provider_packages` DIRECTORY

scripts/ci/images/ci_wait_for_all_ci_images.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if [[ ${USE_GITHUB_REGISTRY} != "true" || ${GITHUB_REGISTRY_WAIT_FOR_IMAGE} !=
3232
fi
3333

3434
echo
35-
echo "Waiting for all images to appear: ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS[*]}"
35+
echo "Waiting for all images to appear: ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING}"
3636
echo
3737

3838
echo
@@ -49,7 +49,7 @@ source "${AIRFLOW_SOURCES}/scripts/ci/libraries/_all_libs.sh"
4949

5050
initialization::initialize_common_environment
5151

52-
for PYTHON_MAJOR_MINOR_VERSION in "${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS[@]}"
52+
for PYTHON_MAJOR_MINOR_VERSION in ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING}
5353
do
5454
export AIRFLOW_CI_IMAGE_NAME="${BRANCH_NAME}-python${PYTHON_MAJOR_MINOR_VERSION}-ci"
5555
push_pull_remove_images::wait_for_github_registry_image "${AIRFLOW_CI_IMAGE_NAME}" "${GITHUB_REGISTRY_PULL_IMAGE_TAG}"

scripts/ci/images/ci_wait_for_all_prod_images.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if [[ ${USE_GITHUB_REGISTRY} != "true" || ${GITHUB_REGISTRY_WAIT_FOR_IMAGE} !=
3232
fi
3333

3434
echo
35-
echo "Waiting for all images to appear: ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS[*]}"
35+
echo "Waiting for all images to appear: ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING}"
3636
echo
3737

3838
echo
@@ -49,7 +49,7 @@ source "${AIRFLOW_SOURCES}/scripts/ci/libraries/_all_libs.sh"
4949

5050
initialization::initialize_common_environment
5151

52-
for PYTHON_MAJOR_MINOR_VERSION in "${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS[@]}"
52+
for PYTHON_MAJOR_MINOR_VERSION in ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING}
5353
do
5454
export AIRFLOW_PROD_IMAGE_NAME="${BRANCH_NAME}-python${PYTHON_MAJOR_MINOR_VERSION}"
5555
export AIRFLOW_PROD_BUILD_IMAGE_NAME="${BRANCH_NAME}-python${PYTHON_MAJOR_MINOR_VERSION}-build"

0 commit comments

Comments
 (0)