Skip to content

Commit 25432dc

Browse files
Move OpenAPI tests to breeze container (apache#44326)
* move openapi tests to breeze container * remove space * move openapi tests inside special tests workflow * merge openapi tests into special tests workflow * use postgres backend for openapi tests * ignore tmp folder tests discovery in openapi tests * adding retries to python client tests connection * adding retries to python client tests connection * export auth backend configs * use connectivity check to verify webserver started or not * rename is-special-tests-require to special-tests-required * rename openapi-tests to python-api-client-tests * rename static-checks-mypy-docs.yml to ci-image-checks.yml * rename static-checks-mypy-docs.yml to ci-image-checks.yml * remove special-tests-required param
1 parent b1a44b4 commit 25432dc

30 files changed

+1066
-381
lines changed

.github/workflows/basic-tests.yml

-102
Original file line numberDiff line numberDiff line change
@@ -153,108 +153,6 @@ jobs:
153153
env:
154154
FORCE_COLOR: 2
155155

156-
test-openapi-client:
157-
timeout-minutes: 10
158-
name: "Test OpenAPI client"
159-
runs-on: ${{ fromJSON(inputs.runs-on-as-json-public) }}
160-
if: inputs.needs-api-codegen == 'true'
161-
steps:
162-
- name: "Cleanup repo"
163-
shell: bash
164-
run: docker run -v "${GITHUB_WORKSPACE}:/workspace" -u 0:0 bash -c "rm -rf /workspace/*"
165-
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
166-
uses: actions/checkout@v4
167-
with:
168-
fetch-depth: 2
169-
persist-credentials: false
170-
- name: "Cleanup docker"
171-
run: ./scripts/ci/cleanup_docker.sh
172-
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
173-
uses: actions/checkout@v4
174-
with:
175-
repository: "apache/airflow-client-python"
176-
fetch-depth: 1
177-
persist-credentials: false
178-
path: ./airflow-client-python
179-
- name: "Install Breeze"
180-
uses: ./.github/actions/breeze
181-
- name: "Generate client with breeze"
182-
run: >
183-
breeze release-management prepare-python-client --package-format both
184-
--version-suffix-for-pypi dev0 --python-client-repo ./airflow-client-python
185-
- name: "Show diff"
186-
run: git diff --color HEAD
187-
working-directory: ./airflow-client-python
188-
- name: Install hatch
189-
run: |
190-
python -m pip install --upgrade uv
191-
uv tool install hatch
192-
- name: Run tests
193-
run: hatch run run-coverage
194-
env:
195-
HATCH_ENV: "test"
196-
working-directory: ./clients/python
197-
- name: "Install source version of required packages"
198-
run: |
199-
breeze release-management prepare-provider-packages \
200-
fab \
201-
standard \
202-
common.sql \
203-
sqlite \
204-
--package-format wheel \
205-
--skip-tag-check \
206-
--version-suffix-for-pypi dev0
207-
pip install . \
208-
dist/apache_airflow_providers_fab-*.whl \
209-
dist/apache_airflow_providers_standard-*.whl \
210-
dist/apache_airflow_providers_common_sql-*.whl \
211-
dist/apache_airflow_providers_sqlite-*.whl
212-
breeze release-management prepare-task-sdk-package --package-format wheel
213-
pip install ./dist/apache_airflow_task_sdk-*.whl
214-
- name: "Install Python client"
215-
run: pip install ./dist/apache_airflow_client-*.whl
216-
- name: "Initialize Airflow DB and start webserver"
217-
run: |
218-
airflow db init
219-
# Let scheduler runs a few loops and get all DAG files from example DAGs serialized to DB
220-
airflow scheduler --num-runs 100
221-
airflow users create --username admin --password admin --firstname Admin --lastname Admin \
222-
--role Admin --email [email protected]
223-
killall python || true # just in case there is a webserver running in the background
224-
nohup airflow webserver --port 8080 &
225-
echo "Started webserver"
226-
env:
227-
AIRFLOW__API__AUTH_BACKENDS: >-
228-
airflow.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth
229-
AIRFLOW__WEBSERVER__EXPOSE_CONFIG: "True"
230-
AIRFLOW__CORE__LOAD_EXAMPLES: "True"
231-
AIRFLOW_HOME: "${{ github.workspace }}/airflow_home"
232-
- name: "Waiting for the webserver to be available"
233-
run: |
234-
timeout 30 bash -c 'until nc -z $0 $1; do echo "sleeping"; sleep 1; done' localhost 8080
235-
sleep 5
236-
- name: "Run test python client"
237-
run: python ./clients/python/test_python_client.py
238-
env:
239-
FORCE_COLOR: "standard"
240-
- name: "Stop running webserver"
241-
run: killall python || true # just in case there is a webserver running in the background
242-
if: always()
243-
- name: "Upload python client packages"
244-
uses: actions/upload-artifact@v4
245-
with:
246-
name: python-client-packages
247-
path: ./dist/apache_airflow_client-*
248-
retention-days: 7
249-
if-no-files-found: error
250-
- name: "Upload logs from failed tests"
251-
uses: actions/upload-artifact@v4
252-
if: failure()
253-
with:
254-
name: python-client-failed-logs
255-
path: "${{ github.workspace }}/airflow_home/logs"
256-
retention-days: 7
257-
258156
# Those checks are run if no image needs to be built for checks. This is for simple changes that
259157
# Do not touch any of the python code or any of the important files that might require building
260158
# The CI Docker image and they can be run entirely using the pre-commit virtual environments on host

.github/workflows/static-checks-mypy-docs.yml .github/workflows/ci-image-checks.yml

+61-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# under the License.
1717
#
1818
---
19-
name: Static checks, mypy, docs
19+
name: CI Image Checks
2020
on: # yamllint disable-line rule:truthy
2121
workflow_call:
2222
inputs:
@@ -96,6 +96,19 @@ on: # yamllint disable-line rule:truthy
9696
description: "Whether to build docs (true/false)"
9797
required: true
9898
type: string
99+
needs-api-codegen:
100+
description: "Whether to run API codegen (true/false)"
101+
required: true
102+
type: string
103+
default-postgres-version:
104+
description: "The default version of the postgres to use"
105+
required: true
106+
type: string
107+
run-coverage:
108+
description: "Whether to run coverage or not (true/false)"
109+
required: true
110+
type: string
111+
99112
jobs:
100113
static-checks:
101114
timeout-minutes: 45
@@ -304,3 +317,50 @@ jobs:
304317
- name: "Upload documentation to AWS S3"
305318
if: inputs.branch == 'main'
306319
run: aws s3 sync --delete ./docs/_build s3://apache-airflow-docs
320+
321+
test-python-api-client:
322+
timeout-minutes: 60
323+
name: "Test Python API client"
324+
runs-on: ${{ fromJSON(inputs.runs-on-as-json-default) }}
325+
if: inputs.needs-api-codegen == 'true'
326+
env:
327+
BACKEND: "postgres"
328+
BACKEND_VERSION: "${{ inputs.default-postgres-version }}"
329+
DEBUG_RESOURCES: "${{ inputs.debug-resources }}"
330+
ENABLE_COVERAGE: "${{ inputs.run-coverage }}"
331+
GITHUB_REPOSITORY: ${{ github.repository }}
332+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
333+
GITHUB_USERNAME: ${{ github.actor }}
334+
IMAGE_TAG: "${{ inputs.image-tag }}"
335+
JOB_ID: "python-api-client-tests"
336+
PYTHON_MAJOR_MINOR_VERSION: "${{ inputs.default-python-version }}"
337+
VERBOSE: "true"
338+
steps:
339+
- name: "Cleanup repo"
340+
shell: bash
341+
run: docker run -v "${GITHUB_WORKSPACE}:/workspace" -u 0:0 bash -c "rm -rf /workspace/*"
342+
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
343+
uses: actions/checkout@v4
344+
with:
345+
fetch-depth: 2
346+
persist-credentials: false
347+
- name: "Cleanup docker"
348+
run: ./scripts/ci/cleanup_docker.sh
349+
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
350+
uses: actions/checkout@v4
351+
with:
352+
repository: "apache/airflow-client-python"
353+
fetch-depth: 1
354+
persist-credentials: false
355+
path: ./airflow-client-python
356+
- name: "Prepare breeze & CI image: ${{inputs.default-python-version}}:${{inputs.image-tag}}"
357+
uses: ./.github/actions/prepare_breeze_and_image
358+
- name: "Generate airflow python client"
359+
run: >
360+
breeze release-management prepare-python-client --package-format both
361+
--version-suffix-for-pypi dev0 --python-client-repo ./airflow-client-python
362+
- name: "Show diff"
363+
run: git diff --color HEAD
364+
working-directory: ./airflow-client-python
365+
- name: "Python API client tests"
366+
run: breeze testing python-api-client-tests

.github/workflows/ci.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,10 @@ jobs:
297297
chicken-egg-providers: ${{ needs.build-info.outputs.chicken-egg-providers }}
298298
debug-resources: ${{ needs.build-info.outputs.debug-resources }}
299299

300-
static-checks-mypy-docs:
301-
name: "Static checks, mypy, docs"
300+
ci-image-checks:
301+
name: "CI image checks"
302302
needs: [build-info, wait-for-ci-images]
303-
uses: ./.github/workflows/static-checks-mypy-docs.yml
303+
uses: ./.github/workflows/ci-image-checks.yml
304304
secrets: inherit
305305
with:
306306
runs-on-as-json-default: ${{ needs.build-info.outputs.runs-on-as-json-default }}
@@ -322,6 +322,9 @@ jobs:
322322
include-success-outputs: ${{ needs.build-info.outputs.include-success-outputs }}
323323
debug-resources: ${{ needs.build-info.outputs.debug-resources }}
324324
docs-build: ${{ needs.build-info.outputs.docs-build }}
325+
needs-api-codegen: ${{ needs.build-info.outputs.needs-api-codegen }}
326+
default-postgres-version: ${{ needs.build-info.outputs.default-postgres-version }}
327+
run-coverage: ${{ needs.build-info.outputs.run-coverage }}
325328

326329
providers:
327330
name: "Provider packages tests"
@@ -702,7 +705,7 @@ jobs:
702705
- generate-constraints
703706
- wait-for-ci-images
704707
- wait-for-prod-images
705-
- static-checks-mypy-docs
708+
- ci-image-checks
706709
- tests-sqlite
707710
- tests-mysql
708711
- tests-postgres

.github/workflows/special-tests.yml

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ on: # yamllint disable-line rule:truthy
7676
description: "Whether to debug resources or not (true/false)"
7777
required: true
7878
type: string
79+
7980
jobs:
8081
tests-min-sqlalchemy:
8182
name: "Min SQLAlchemy test"

Dockerfile.ci

+51
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,8 @@ mkdir "${AIRFLOW_HOME}/sqlite" -p || true
822822

823823
ASSET_COMPILATION_WAIT_MULTIPLIER=${ASSET_COMPILATION_WAIT_MULTIPLIER:=1}
824824

825+
. "${IN_CONTAINER_DIR}/check_connectivity.sh"
826+
825827
function wait_for_asset_compilation() {
826828
if [[ -f "${AIRFLOW_SOURCES}/.build/www/.asset_compile.lock" ]]; then
827829
echo
@@ -1146,12 +1148,61 @@ function check_force_lowest_dependencies() {
11461148
set +x
11471149
}
11481150

1151+
function check_airflow_python_client_installation() {
1152+
if [[ ${INSTALL_AIRFLOW_PYTHON_CLIENT=} != "true" ]]; then
1153+
return
1154+
fi
1155+
python "${IN_CONTAINER_DIR}/install_airflow_python_client.py"
1156+
}
1157+
1158+
function start_webserver_with_examples(){
1159+
if [[ ${START_WEBSERVER_WITH_EXAMPLES=} != "true" ]]; then
1160+
return
1161+
fi
1162+
export AIRFLOW__CORE__LOAD_EXAMPLES=True
1163+
export AIRFLOW__API__AUTH_BACKENDS=airflow.api.auth.backend.session,airflow.providers.fab.auth_manager.api.auth.backend.basic_auth
1164+
export AIRFLOW__WEBSERVER__EXPOSE_CONFIG=True
1165+
echo
1166+
echo "${COLOR_BLUE}Initializing database${COLOR_RESET}"
1167+
echo
1168+
airflow db migrate
1169+
echo
1170+
echo "${COLOR_BLUE}Database initialized${COLOR_RESET}"
1171+
echo
1172+
echo "${COLOR_BLUE}Parsing example dags${COLOR_RESET}"
1173+
echo
1174+
airflow scheduler --num-runs 100
1175+
echo "Example dags parsing finished"
1176+
echo "Create admin user"
1177+
airflow users create -u admin -p admin -f Thor -l Administrator -r Admin -e [email protected]
1178+
echo "Admin user created"
1179+
echo
1180+
echo "${COLOR_BLUE}Starting airflow webserver${COLOR_RESET}"
1181+
echo
1182+
airflow webserver --port 8080 --daemon
1183+
echo
1184+
echo "${COLOR_BLUE}Waiting for webserver to start${COLOR_RESET}"
1185+
echo
1186+
check_service_connection "Airflow webserver" "run_nc localhost 8080" 100
1187+
EXIT_CODE=$?
1188+
if [[ ${EXIT_CODE} != 0 ]]; then
1189+
echo
1190+
echo "${COLOR_RED}Webserver did not start properly${COLOR_RESET}"
1191+
echo
1192+
exit ${EXIT_CODE}
1193+
fi
1194+
echo
1195+
echo "${COLOR_BLUE}Airflow webserver started${COLOR_RESET}"
1196+
}
1197+
11491198
determine_airflow_to_use
11501199
environment_initialization
11511200
check_boto_upgrade
11521201
check_downgrade_sqlalchemy
11531202
check_downgrade_pendulum
11541203
check_force_lowest_dependencies
1204+
check_airflow_python_client_installation
1205+
start_webserver_with_examples
11551206
check_run_tests "${@}"
11561207

11571208
exec /bin/bash "${@}"

0 commit comments

Comments
 (0)