Skip to content

Commit

Permalink
The PRs which are not approved run subset of tests (#11828)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
potiuk committed Oct 29, 2020
1 parent 4cb0621 commit 37eaac3
Show file tree
Hide file tree
Showing 10 changed files with 276 additions and 29 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/build-images-workflow-run.yml
Expand Up @@ -53,15 +53,15 @@ jobs:
sourceHeadSha: ${{ steps.source-run-info.outputs.sourceHeadSha }}
mergeCommitSha: ${{ steps.source-run-info.outputs.mergeCommitSha }}
targetCommitSha: ${{ steps.source-run-info.outputs.targetCommitSha }}
pullRequestNumber: ${{ steps.workflow-run-info.outputs.pullRequestNumber }}
pullRequestLabels: ${{ steps.workflow-run-info.outputs.pullRequestLabels }}
pullRequestNumber: ${{ steps.source-run-info.outputs.pullRequestNumber }}
pullRequestLabels: ${{ steps.source-run-info.outputs.pullRequestLabels }}
sourceEvent: ${{ steps.source-run-info.outputs.sourceEvent }}
cacheDirective: ${{ steps.cache-directive.outputs.docker-cache }}
buildImages: ${{ steps.build-images.outputs.buildImages }}
upgradeToLatestConstraints: ${{ steps.upgrade-constraints.outputs.upgradeToLatestConstraints }}
steps:
- name: "Get information about the original trigger of the run"
uses: potiuk/get-workflow-origin@e3ba776faee1134e17551924b852bfb374e1703d # v1_1
uses: potiuk/get-workflow-origin@2ef0b065db6b688a2231f8a7f464df1aac254328 # v1_2
id: source-run-info
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -228,6 +228,7 @@ jobs:
env:
EVENT_NAME: ${{ needs.cancel-workflow-runs.outputs.sourceEvent }}
INCOMING_COMMIT_SHA: ${{ needs.cancel-workflow-runs.outputs.targetCommitSha }}
PR_LABELS: ${{ needs.cancel-workflow-runs.outputs.pullRequestLabels }}
run: |
if [[ ${EVENT_NAME} == "pull_request" ]]; then
# Run selective checks
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -71,6 +71,7 @@ jobs:
outputs:
waitForImage: ${{ steps.wait-for-image.outputs.wait-for-image }}
pythonVersions: ${{ steps.selective-checks.outputs.python-versions }}
pythonVersionsListAsString: ${{ steps.selective-checks.outputs.python-versions-list-as-string }}
defaultPythonVersion: ${{ steps.selective-checks.outputs.default-python-version }}
kubernetesVersions: ${{ steps.selective-checks.outputs.kubernetes-versions }}
defaultKubernetesVersion: ${{ steps.selective-checks.outputs.default-kubernetes-version }}
Expand Down Expand Up @@ -98,7 +99,7 @@ jobs:
pullRequestLabels: ${{ steps.source-run-info.outputs.pullRequestLabels }}
steps:
- name: "Get information about the PR"
uses: potiuk/get-workflow-origin@e3ba776faee1134e17551924b852bfb374e1703d # v1_1
uses: potiuk/get-workflow-origin@2ef0b065db6b688a2231f8a7f464df1aac254328 # v1_2
id: source-run-info
with:
token: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -131,6 +132,7 @@ jobs:
env:
EVENT_NAME: ${{ github.event_name }}
INCOMING_COMMIT_SHA: ${{ github.sha }}
PR_LABELS: "${{ steps.source-run-info.outputs.pullRequestLabels }}"
run: |
if [[ ${EVENT_NAME} == "pull_request" ]]; then
# Run selective checks
Expand Down Expand Up @@ -189,6 +191,9 @@ jobs:
- name: >
Wait for CI images
${{ needs.build-info.outputs.pythonVersions }}:${{ env.GITHUB_REGISTRY_PULL_IMAGE_TAG }}"
env:
CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING: >
${{needs.build-info.outputs.pythonVersionsListAsString}}
# We wait for the images to be available either from the build-ci-image step or from
# "build-images-workflow-run.yml' run as pull_request_target (it has the write
# permissions in case pull_request from fork is run.
Expand Down Expand Up @@ -469,7 +474,7 @@ jobs:


tests-postgres:
timeout-minutes: 60
timeout-minutes: 80
name: >
Postgres${{matrix.postgres-version}},Py${{matrix.python-version}}:
${{needs.build-info.outputs.testTypes}}
Expand Down Expand Up @@ -523,7 +528,7 @@ jobs:
path: "./files/coverage.xml"

tests-mysql:
timeout-minutes: 60
timeout-minutes: 80
name: >
MySQL${{matrix.mysql-version}}, Py${{matrix.python-version}}: ${{needs.build-info.outputs.testTypes}}
runs-on: ubuntu-latest
Expand Down Expand Up @@ -745,6 +750,9 @@ jobs:
- name: >
Wait for PROD images
${{ needs.build-info.outputs.pythonVersions }}:${{ env.GITHUB_REGISTRY_PULL_IMAGE_TAG }}"
env:
CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING: >
${{needs.build-info.outputs.pythonVersionsListAsString}}
run: ./scripts/ci/images/ci_wait_for_all_prod_images.sh
if: needs.build-info.outputs.waitForImage == 'true'
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/codeql-analysis.yml
@@ -1,3 +1,20 @@
# 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: "CodeQL"

Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/delete_old_artifacts.yml
@@ -1,3 +1,20 @@
# 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: 'Delete old artifacts'
on: # yamllint disable-line rule:truthy
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/label_when_reviewed.yml
@@ -0,0 +1,29 @@
# 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
on: pull_request_review # yamllint disable-line rule:truthy

jobs:

label-when-reviewed:
name: "Label PRs when reviewed"
runs-on: ubuntu-latest
steps:
- name: "Do nothing. Only trigger corresponding workflow_run event"
run: echo
127 changes: 127 additions & 0 deletions .github/workflows/label_when_reviewed_workflow_run.yml
@@ -0,0 +1,127 @@
# 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']
jobs:

label-when-reviewed:
name: "Label PRs when reviewed workflow run"
runs-on: ubuntu-latest
outputs:
labelSet: ${{ steps.label-when-reviewed.outputs.labelSet }}
steps:
- name: "Get information about the original trigger of the run"
uses: potiuk/get-workflow-origin@2ef0b065db6b688a2231f8a7f464df1aac254328 # v1_2
id: source-run-info
with:
token: ${{ secrets.GITHUB_TOKEN }}
sourceRunId: ${{ github.event.workflow_run.id }}
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v2
- 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
# checkout the master version again, to use the right script in master workflow
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v2
- name: Selective checks
id: selective-checks
env:
EVENT_NAME: ${{ steps.source-run-info.outputs.sourceEvent }}
INCOMING_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 "${INCOMING_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: TobKed/label-when-approved-action@7872312da76508d29f98d4fa68843ea91754cc59 # v1.2
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'
pullRequestNumber: ${{ steps.source-run-info.outputs.pullRequestNumber }}
comment: >
The PR needs to run all tests because it modifies core of Airflow! Please rebase it to latest
master or ask committer to re-run it!
- name: "Initiate GitHub Check forcing rerun of SH ${{ github.event.pull_request.head.sha }}"
uses: LouisBrunner/checks-action@9f02872da71b6f558c6a6f190f925dde5e4d8798 # v1.1.0
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 re-run to run full tests"
status: "in_progress"
sha: ${{ github.event.pull_request.head.sha }}
details_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
output: >
{"summary":
"The PR needs to run all tests! This was determined via
[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: TobKed/label-when-approved-action@7872312da76508d29f98d4fa68843ea91754cc59 # v1.2
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 should be OK to be merged with just subset of tests as it does not modify Core of
Airflow. The committers might merge it or can add a label 'full tests needed' and re-run it
to run all tests if they see it is needed!
- name: "Label when approved by committers for PRs that do not require tests at all"
uses: TobKed/label-when-approved-action@7872312da76508d29f98d4fa68843ea91754cc59 # v1.2
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 ready to be merged. No tests are needed!"
2 changes: 1 addition & 1 deletion airflow/providers/google/backport_provider_setup.py
Expand Up @@ -19,7 +19,7 @@
# NOTE! THIS FILE IS AUTOMATICALLY GENERATED AND WILL BE\
# OVERWRITTEN WHEN RUNNING
#
# ./breeze prepare-provider-readme
# ./breeze prepare-provider-readmes
#
# IF YOU WANT TO MODIFY IT, YOU SHOULD MODIFY THE TEMPLATE
# `SETUP_TEMPLATE.py.jinja2` IN the `provider_packages` DIRECTORY
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci/images/ci_wait_for_all_ci_images.sh
Expand Up @@ -32,7 +32,7 @@ if [[ ${USE_GITHUB_REGISTRY} != "true" || ${GITHUB_REGISTRY_WAIT_FOR_IMAGE} !=
fi

echo
echo "Waiting for all images to appear: ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS[*]}"
echo "Waiting for all images to appear: ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING}"
echo

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

initialization::initialize_common_environment

for PYTHON_MAJOR_MINOR_VERSION in "${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS[@]}"
for PYTHON_MAJOR_MINOR_VERSION in ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING}
do
export AIRFLOW_CI_IMAGE_NAME="${BRANCH_NAME}-python${PYTHON_MAJOR_MINOR_VERSION}-ci"
push_pull_remove_images::wait_for_github_registry_image "${AIRFLOW_CI_IMAGE_NAME}" "${GITHUB_REGISTRY_PULL_IMAGE_TAG}"
Expand Down
4 changes: 2 additions & 2 deletions scripts/ci/images/ci_wait_for_all_prod_images.sh
Expand Up @@ -32,7 +32,7 @@ if [[ ${USE_GITHUB_REGISTRY} != "true" || ${GITHUB_REGISTRY_WAIT_FOR_IMAGE} !=
fi

echo
echo "Waiting for all images to appear: ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS[*]}"
echo "Waiting for all images to appear: ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING}"
echo

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

initialization::initialize_common_environment

for PYTHON_MAJOR_MINOR_VERSION in "${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS[@]}"
for PYTHON_MAJOR_MINOR_VERSION in ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING}
do
export AIRFLOW_PROD_IMAGE_NAME="${BRANCH_NAME}-python${PYTHON_MAJOR_MINOR_VERSION}"
export AIRFLOW_PROD_BUILD_IMAGE_NAME="${BRANCH_NAME}-python${PYTHON_MAJOR_MINOR_VERSION}-build"
Expand Down

0 comments on commit 37eaac3

Please sign in to comment.