Add a possibility to switch back to building images by secret (#10509)

You can now define secret in your own fork:

AIRFLOW_GITHUB_REGISTRY_WAIT_FOR_IMAGE

If you set it to "false", it skips building images in separate
workflow_run - images will be built in the jobs run in the
CI Build run and they won't be pushed to the registry.

Note - you can't have secrets starting with GITHUB_, that's why
the AIRFLOW_* prefix
This commit is contained in:
Jarek Potiuk 2020-08-25 01:38:28 +02:00 коммит произвёл GitHub
Родитель 6bed074b2d
Коммит be77f8e448
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 28 добавлений и 14 удалений

Просмотреть файл

@ -39,6 +39,7 @@ env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REGISTRY_PULL_IMAGE_TAG: "latest" GITHUB_REGISTRY_PULL_IMAGE_TAG: "latest"
GITHUB_REGISTRY_WAIT_FOR_IMAGE: "false" GITHUB_REGISTRY_WAIT_FOR_IMAGE: "false"
BUILD_IMAGES: ${{ secrets.AIRFLOW_GITHUB_REGISTRY_WAIT_FOR_IMAGE != 'false' }}
jobs: jobs:
@ -52,6 +53,7 @@ jobs:
sourceHeadSha: ${{ steps.cancel.outputs.sourceHeadSha }} sourceHeadSha: ${{ steps.cancel.outputs.sourceHeadSha }}
sourceEvent: ${{ steps.cancel.outputs.sourceEvent }} sourceEvent: ${{ steps.cancel.outputs.sourceEvent }}
cacheDirective: ${{ steps.cache-directive.outputs.docker-cache }} cacheDirective: ${{ steps.cache-directive.outputs.docker-cache }}
buildImages: ${{ steps.build-images.outputs.buildImages }}
if: github.repository == 'apache/airflow' || github.event.workflow_run.event != 'schedule' if: github.repository == 'apache/airflow' || github.event.workflow_run.event != 'schedule'
steps: steps:
- name: "Cancel duplicated 'CI Build' runs" - name: "Cancel duplicated 'CI Build' runs"
@ -61,6 +63,12 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
cancelMode: duplicates cancelMode: duplicates
sourceRunId: ${{ github.event.workflow_run.id }} sourceRunId: ${{ github.event.workflow_run.id }}
- name: "Output BUILD_IMAGES"
id: build-images
run: |
# Workaround - jobs cannot access env variable in "ifs"
# https://github.community/t/how-to-set-and-access-a-workflow-variable/17335/16
echo "::set-output name=buildImages::${BUILD_IMAGES}"
- name: "Cancel duplicated 'Build Image' runs" - name: "Cancel duplicated 'Build Image' runs"
# We find duplicates of our own "Build Image" runs - due to a missing feature # We find duplicates of our own "Build Image" runs - due to a missing feature
@ -75,6 +83,7 @@ jobs:
[".*Event: ${{ steps.cancel.outputs.sourceEvent }} [".*Event: ${{ steps.cancel.outputs.sourceEvent }}
Repo: ${{ steps.cancel.outputs.sourceHeadRepo }} Repo: ${{ steps.cancel.outputs.sourceHeadRepo }}
Branch: ${{ steps.cancel.outputs.sourceHeadBranch }}.*"] Branch: ${{ steps.cancel.outputs.sourceHeadBranch }}.*"]
if: env.BUILD_IMAGES == 'true'
- name: "Cancel all 'CI Build' runs where some jobs failed" - name: "Cancel all 'CI Build' runs where some jobs failed"
# We find any of the "CI Build" workflow runs, where any of the important jobs # We find any of the "CI Build" workflow runs, where any of the important jobs
@ -118,7 +127,7 @@ jobs:
# it to cancel any jobs that have matching names containing Source Run Id: # it to cancel any jobs that have matching names containing Source Run Id:
# followed by one of the run ids. Yes I know it's super complex ¯\_(ツ)_/¯. # followed by one of the run ids. Yes I know it's super complex ¯\_(ツ)_/¯.
if: steps.cancel-failed.outputs.cancelledRuns != '[]' if: env.BUILD_IMAGES == 'true' && steps.cancel-failed.outputs.cancelledRuns != '[]'
uses: potiuk/cancel-workflow-runs@v2 uses: potiuk/cancel-workflow-runs@v2
with: with:
cancelMode: namedJobs cancelMode: namedJobs
@ -149,9 +158,11 @@ jobs:
Source Sha: ${{ needs.cancel-workflow-runs.outputs.sourceHeadSha }} Source Sha: ${{ needs.cancel-workflow-runs.outputs.sourceHeadSha }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [cancel-workflow-runs] needs: [cancel-workflow-runs]
if: github.repository == 'apache/airflow' || github.event.workflow_run.event != 'schedule'
env: env:
GITHUB_CONTEXT: ${{ toJson(github) }} GITHUB_CONTEXT: ${{ toJson(github) }}
if: >
needs.cancel-workflow-runs.outputs.buildImages == 'true' &&
(github.repository == 'apache/airflow' || github.event.workflow_run.event != 'schedule')
steps: steps:
- name: > - name: >
Event: ${{ needs.cancel-workflow-runs.outputs.sourceEvent }} Event: ${{ needs.cancel-workflow-runs.outputs.sourceEvent }}
@ -174,7 +185,9 @@ jobs:
python-version: [3.6, 3.7, 3.8] python-version: [3.6, 3.7, 3.8]
image-type: [CI, PROD] image-type: [CI, PROD]
fail-fast: true fail-fast: true
if: github.repository == 'apache/airflow' || github.event.workflow_run.event != 'schedule' if: >
needs.cancel-workflow-runs.outputs.buildImages == 'true' &&
(github.repository == 'apache/airflow' || github.event.workflow_run.event != 'schedule')
env: env:
BACKEND: postgres BACKEND: postgres
PYTHON_MAJOR_MINOR_VERSION: ${{ matrix.python-version }} PYTHON_MAJOR_MINOR_VERSION: ${{ matrix.python-version }}

21
.github/workflows/ci.yml поставляемый
Просмотреть файл

@ -56,9 +56,10 @@ env:
# #
# GITHUB_REGISTRY_WAIT_FOR_IMAGE: "false" # GITHUB_REGISTRY_WAIT_FOR_IMAGE: "false"
# #
# You can also switch back to building images locally and disabling the "Build Images" workflow
# by defining AIRFLOW_GITHUB_REGISTRY_WAIT_FOR_IMAGE secret with value set to "false"
GITHUB_REGISTRY_WAIT_FOR_IMAGE: "true" GITHUB_REGISTRY_WAIT_FOR_IMAGE: ${{ secrets.AIRFLOW_GITHUB_REGISTRY_WAIT_FOR_IMAGE != 'false' }}
jobs: jobs:
@ -305,7 +306,7 @@ jobs:
POSTGRES_VERSION: ${{ matrix.postgres-version }} POSTGRES_VERSION: ${{ matrix.postgres-version }}
RUN_TESTS: true RUN_TESTS: true
TEST_TYPE: ${{ matrix.test-type }} TEST_TYPE: ${{ matrix.test-type }}
if: | if: >
(needs.trigger-tests.outputs.run-tests == 'true' || github.event_name != 'pull_request') && (needs.trigger-tests.outputs.run-tests == 'true' || github.event_name != 'pull_request') &&
(github.repository == 'apache/airflow' || github.event_name != 'schedule') (github.repository == 'apache/airflow' || github.event_name != 'schedule')
steps: steps:
@ -351,7 +352,7 @@ jobs:
MYSQL_VERSION: ${{ matrix.mysql-version }} MYSQL_VERSION: ${{ matrix.mysql-version }}
RUN_TESTS: true RUN_TESTS: true
TEST_TYPE: ${{ matrix.test-type }} TEST_TYPE: ${{ matrix.test-type }}
if: | if: >
(needs.trigger-tests.outputs.run-tests == 'true' || github.event_name != 'pull_request') && (needs.trigger-tests.outputs.run-tests == 'true' || github.event_name != 'pull_request') &&
(github.repository == 'apache/airflow' || github.event_name != 'schedule') (github.repository == 'apache/airflow' || github.event_name != 'schedule')
steps: steps:
@ -440,7 +441,7 @@ jobs:
TEST_TYPE: Quarantined TEST_TYPE: Quarantined
NUM_RUNS: 20 NUM_RUNS: 20
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: | if: >
(needs.trigger-tests.outputs.run-tests == 'true' || github.event_name != 'pull_request') && (needs.trigger-tests.outputs.run-tests == 'true' || github.event_name != 'pull_request') &&
(github.repository == 'apache/airflow' || github.event_name != 'schedule') (github.repository == 'apache/airflow' || github.event_name != 'schedule')
steps: steps:
@ -561,7 +562,7 @@ jobs:
KUBERNETES_VERSION: "${{ matrix.kubernetes-version }}" KUBERNETES_VERSION: "${{ matrix.kubernetes-version }}"
KIND_VERSION: "${{ matrix.kind-version }}" KIND_VERSION: "${{ matrix.kind-version }}"
HELM_VERSION: "${{ matrix.helm-version }}" HELM_VERSION: "${{ matrix.helm-version }}"
if: | if: >
(needs.trigger-tests.outputs.run-tests == 'true' || github.event_name != 'pull_request') && (needs.trigger-tests.outputs.run-tests == 'true' || github.event_name != 'pull_request') &&
(github.repository == 'apache/airflow' || github.event_name != 'schedule') (github.repository == 'apache/airflow' || github.event_name != 'schedule')
steps: steps:
@ -622,7 +623,7 @@ jobs:
- prod-images - prod-images
- docs - docs
- docs-spell-check - docs-spell-check
if: | if: >
(github.ref == 'refs/heads/master' || github.ref == 'refs/heads/v1-10-test') && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/v1-10-test') &&
github.event_name != 'schedule' github.event_name != 'schedule'
strategy: strategy:
@ -660,7 +661,7 @@ jobs:
- ci-images - ci-images
- docs - docs
- docs-spell-check - docs-spell-check
if: | if: >
(github.ref == 'refs/heads/master' || github.ref == 'refs/heads/v1-10-test' ) && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/v1-10-test' ) &&
github.event_name != 'schedule' github.event_name != 'schedule'
strategy: strategy:
@ -700,7 +701,7 @@ jobs:
- tests-kubernetes - tests-kubernetes
env: env:
PYTHON_MAJOR_MINOR_VERSION: ${{ matrix.python-version }} PYTHON_MAJOR_MINOR_VERSION: ${{ matrix.python-version }}
if: | if: >
(github.ref == 'refs/heads/master' || github.ref == 'refs/heads/v1-10-test' ) && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/v1-10-test' ) &&
github.event_name != 'pull' && github.event_name != 'pull' &&
(github.repository == 'apache/airflow' || github.event_name != 'schedule') (github.repository == 'apache/airflow' || github.event_name != 'schedule')
@ -728,7 +729,7 @@ jobs:
name: "Constraints push" name: "Constraints push"
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [constraints] needs: [constraints]
if: | if: >
(github.ref == 'refs/heads/master' || github.ref == 'refs/heads/v1-10-test' ) && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/v1-10-test' ) &&
github.event_name != 'pull' && github.event_name != 'pull' &&
(github.repository == 'apache/airflow' || github.event_name != 'schedule') (github.repository == 'apache/airflow' || github.event_name != 'schedule')

2
.github/workflows/scheduled_quarantined.yml поставляемый
Просмотреть файл

@ -77,7 +77,7 @@ jobs:
TEST_TYPE: Quarantined TEST_TYPE: Quarantined
NUM_RUNS: 20 NUM_RUNS: 20
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: | if: >
github.repository == 'apache/airflow' && github.repository == 'apache/airflow' &&
(needs.trigger-tests.outputs.run-tests == 'true' || github.event_name != 'pull_request') (needs.trigger-tests.outputs.run-tests == 'true' || github.event_name != 'pull_request')
steps: steps: