Skip to content

Commit

Permalink
Skips provider package builds and provider tests for non-master (#14996)
Browse files Browse the repository at this point in the history
This PR skips building Provider packages for branches different
than master. Provider packages are always released from master
but never from any other branch so there is no point in running
the package building and tests there
  • Loading branch information
potiuk committed Mar 25, 2021
1 parent 645e772 commit db9febd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Expand Up @@ -154,6 +154,7 @@ jobs:
needs-helm-tests: ${{ steps.selective-checks.outputs.needs-helm-tests }}
needs-api-tests: ${{ steps.selective-checks.outputs.needs-api-tests }}
needs-api-codegen: ${{ steps.selective-checks.outputs.needs-api-codegen }}
default-branch: ${{ steps.selective-checks.outputs.default-branch }}
pullRequestNumber: ${{ steps.source-run-info.outputs.pullRequestNumber }}
pullRequestLabels: ${{ steps.source-run-info.outputs.pullRequestLabels }}
runsOn: ${{ steps.set-runs-on.outputs.runsOn }}
Expand Down Expand Up @@ -504,12 +505,13 @@ ${{ hashFiles('.pre-commit-config.yaml') }}"
strategy:
matrix:
package-format: ['wheel', 'sdist']
if: needs.build-info.outputs.image-build == 'true'
if: needs.build-info.outputs.image-build == 'true' && needs.build-info.outputs.default-branch == 'master'
steps:
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v2
with:
persist-credentials: false
if: needs.build-info.outputs.default-branch == 'master'
- name: "Setup python"
uses: actions/setup-python@v2
with:
Expand Down Expand Up @@ -551,7 +553,7 @@ ${{ hashFiles('.pre-commit-config.yaml') }}"
strategy:
matrix:
package-format: ['wheel', 'sdist']
if: needs.build-info.outputs.image-build == 'true'
if: needs.build-info.outputs.image-build == 'true' && needs.build-info.outputs.default-branch == 'master'
steps:
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v2
Expand Down Expand Up @@ -1033,8 +1035,6 @@ ${{ hashFiles('.pre-commit-config.yaml') }}"
- tests-postgres
- tests-mysql
- tests-kubernetes
- prepare-provider-packages
- test-provider-packages-released-airflow
- prod-images
- docs
if: >
Expand Down
9 changes: 6 additions & 3 deletions PULL_REQUEST_WORKFLOW.rst
Expand Up @@ -125,15 +125,18 @@ The logic implemented for the changes works as follows:

1) In case of direct push (so when PR gets merged) or scheduled run, we always run all tests and checks.
This is in order to make sure that the merge did not miss anything important. The remainder of the logic
is executed only in case of Pull Requests.
is executed only in case of Pull Requests. We do not add providers tests in case DEFAULT_BRANCH is
different than master, because providers are only important in master branch and PRs to master branch.

2) We retrieve which files have changed in the incoming Merge Commit (github.sha is a merge commit
automatically prepared by GitHub in case of Pull Request, so we can retrieve the list of changed
files from that commit directly).

3) If any of the important, environment files changed (Dockerfile, ci scripts, setup.py, GitHub workflow
files), then we again run all tests and checks. Those are cases where the logic of the checks changed
or the environment for the checks changed so we want to make sure to check everything.
or the environment for the checks changed so we want to make sure to check everything. We do not add
providers tests in case DEFAULT_BRANCH is different than master, because providers are only
important in master branch and PRs to master branch.

4) If any of py files changed: we need to have CI image and run full static checks so we enable image building

Expand All @@ -157,7 +160,7 @@ The logic implemented for the changes works as follows:
b) if any of the Airflow API files changed we enable ``API`` test type
c) if any of the Airflow CLI files changed we enable ``CLI`` test type and Kubernetes tests (the
K8S tests depend on CLI changes as helm chart uses CLI to run Airflow).
d) if any of the Provider files changed we enable ``Providers`` test type
d) if this is a master branch and if any of the Provider files changed we enable ``Providers`` test type
e) if any of the WWW files changed we enable ``WWW`` test type
f) if any of the Kubernetes files changed we enable ``Kubernetes`` test type
g) Then we subtract count of all the ``specific`` above per-type changed files from the count of
Expand Down
26 changes: 21 additions & 5 deletions scripts/ci/selective_ci_checks.sh
Expand Up @@ -122,7 +122,12 @@ function output_all_basic_variables() {
initialization::ga_output sqlite-exclude '[]'
fi


initialization::ga_output default-helm-version "${HELM_VERSION}"
initialization::ga_output kubernetes-exclude '[]'

initialization::ga_output default-branch "${DEFAULT_BRANCH}"

}

function get_changed_files() {
Expand Down Expand Up @@ -198,8 +203,12 @@ function set_upgrade_to_newer_dependencies() {
initialization::ga_output upgrade-to-newer-dependencies "${@}"
}


ALL_TESTS="Always API Core Other CLI Providers WWW Integration"
if [[ ${DEFAULT_BRANCH} == "master" ]]; then
ALL_TESTS="Always API Core Other CLI Providers WWW Integration"
else
# Skips Provider tests in case current default branch is not master
ALL_TESTS="Always API Core Other CLI WWW Integration"
fi
readonly ALL_TESTS

function set_outputs_run_everything_and_exit() {
Expand Down Expand Up @@ -588,11 +597,18 @@ function calculate_test_types_to_run() {
SELECTED_TESTS="${SELECTED_TESTS} CLI"
kubernetes_tests_needed="true"
fi
if [[ ${COUNT_PROVIDERS_CHANGED_FILES} != "0" ]]; then

if [[ ${DEFAULT_BRANCH} == "master" ]]; then
if [[ ${COUNT_PROVIDERS_CHANGED_FILES} != "0" ]]; then
echo
echo "Adding Providers to selected files as ${COUNT_PROVIDERS_CHANGED_FILES} Provider files changed"
echo
SELECTED_TESTS="${SELECTED_TESTS} Providers"
fi
else
echo
echo "Adding Providers to selected files as ${COUNT_PROVIDERS_CHANGED_FILES} Provider files changed"
echo "Providers tests are not added because they are only run in case of master branch."
echo
SELECTED_TESTS="${SELECTED_TESTS} Providers"
fi
if [[ ${COUNT_WWW_CHANGED_FILES} != "0" ]]; then
echo
Expand Down

0 comments on commit db9febd

Please sign in to comment.