Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/actions/python-airflow-apis/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Run Airflow API tests
description: Start an OpenMetadata test stack, run the Airflow APIs suite, and report its results.
inputs:
python-version:
description: Python interpreter for the API tests.
required: true
use-backend-image:
description: Use the shared backend image instead of building on this runner.
default: 'false'
collect-coverage:
description: Collect coverage for the nightly Sonar analysis.
default: 'false'
runs:
using: composite
steps:
- name: Restore Maven dependencies
if: inputs.use-backend-image != 'true'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Start test environment
uses: ./.github/actions/setup-openmetadata-test-environment
with:
use-backend-image: ${{ inputs.use-backend-image }}
args: -m no-ui -i false -s ${{ inputs.use-backend-image }}
maven-args: -Dmaven.test.skip=true
- uses: ./.github/actions/setup-python
with:
python-version: ${{ inputs.python-version }}
- name: Prepare generated models
run: |
sudo make install_antlr_cli
make generate ARGS=--python-only
shell: bash
- name: Run Airflow API tests
id: tests
env:
COLLECT_COVERAGE: ${{ inputs.collect-coverage }}
run: |
set -o pipefail
args=()
if [[ "$COLLECT_COVERAGE" == 'true' ]]; then
args+=(--coverage)
fi
make -C openmetadata-airflow-apis test ARGS="${args[*]}" 2>&1 | tee openmetadata-airflow-apis/airflow-apis-test-run.log
shell: bash
- name: Report test results
if: ${{ always() }}
uses: ./.github/actions/report-test-results
with:
step-outcome: ${{ steps.tests.outcome }}
exit-code-file: openmetadata-airflow-apis/airflow-apis-test-exit-code.txt
test-profile: airflow-apis
artifact-name: airflow-apis-test-results
working-directory: openmetadata-airflow-apis
61 changes: 61 additions & 0 deletions .github/actions/python-unit/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Run Python unit tests
description: Prepare the classification test profile, run the ingestion unit suite, and report its results.
inputs:
python-version:
description: Python interpreter for the unit suite.
required: true
collect-coverage:
description: Collect and upload unit coverage for nightly Sonar.
default: 'false'
prepare-models:
description: Prepare classification models on this runner instead of consuming the shared artifact.
default: 'false'
run-tooling-tests:
description: Run CI tooling and offline E2E framework tests before the unit suite.
default: 'false'
runs:
using: composite
steps:
- name: Prepare Python environment
uses: ./.github/actions/prepare-python-environment
env:
PYTHON_VERSIONS: ${{ inputs.python-version }}
with:
python-version: ${{ inputs.python-version }}
profile: test-classification
prepare-models: ${{ inputs.prepare-models }}
- name: Test CI and Python tooling
if: inputs.run-tooling-tests == 'true'
env:
PYTEST_DISABLE_PLUGIN_AUTOLOAD: '1'
run: |
env/bin/python -m pytest -q --noconftest \
.github/scripts/tests/test_python_ci.py \
.github/scripts/test_classify_test_outcome.py \
ingestion/tests/tooling
shell: bash
- name: Run offline E2E framework tests
if: inputs.run-tooling-tests == 'true'
run: |
source env/bin/activate
cd ingestion
env -u OM_JWT_TOKEN OM_SERVER_URL=http://127.0.0.1:1/api \
python -m pytest tests/cli_e2e_v2/meta -q
shell: bash
- name: Run unit tests
id: tests
uses: ./.github/actions/python-suite
env:
PYTHON_VERSIONS: ${{ inputs.python-version }}
with:
suite: unit
collect-coverage: ${{ inputs.collect-coverage }}
coverage-name: coverage-unit-${{ inputs.python-version }}
- name: Report test results
if: ${{ always() }}
uses: ./.github/actions/report-test-results
with:
step-outcome: ${{ steps.tests.outcome }}
exit-code-file: ingestion/unit-test-exit-code.txt
test-profile: python-unit
artifact-name: py-unit-test-results-${{ inputs.python-version }}
4 changes: 2 additions & 2 deletions .github/python-ci/paths.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ python:
- .github/actions/prepare-python-build/**
- openmetadata-spec/**
- .github/workflows/ci-pr.yml
- .github/workflows/reusable-py-unit.yml
- .github/actions/python-unit/**
- .github/python-ci/**
- .github/actions/python-static-checks/**
- .github/actions/python-suite/**
Expand Down Expand Up @@ -63,7 +63,7 @@ backend:
- .github/scripts/python_ci_diagnostics.sh
airflow-apis:
- openmetadata-airflow-apis/**/!(*.md)
- .github/workflows/reusable-py-airflow-apis.yml
- .github/actions/python-airflow-apis/**
static:
- scripts/update_version.py
- .github/scripts/tests/test_python_ci.py
29 changes: 26 additions & 3 deletions .github/scripts/tests/test_python_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import itertools
import json
import os
import re
import shutil
import subprocess
import sys
Expand Down Expand Up @@ -110,9 +111,17 @@ def test_connectors_reject_invalid_configuration(defaults, selected):
assert not result.stdout


@pytest.fixture(params=["ci-pr.yml", "ci-merge-queue.yml"])
@pytest.fixture(
params=[
("ci-pr.yml", "python", "gate"),
("ci-pr.yml", "py-tests-status", None),
("ci-merge-queue.yml", "py-tests-status", None),
]
)
def gate(request):
script = workflow(request.param)["jobs"]["py-tests-status"]["steps"][0]["run"]
name, job, step_id = request.param
steps = workflow(name)["jobs"][job]["steps"]
script = next(step for step in steps if step_id is None or step.get("id") == step_id)["run"]

def invoke(needs, expected):
return run(
Expand Down Expand Up @@ -173,7 +182,9 @@ def invoke(needs):


def test_nightly_artifact_names_are_unique_across_invocations():
unit_steps = workflow("reusable-py-unit.yml")["jobs"]["py-unit-tests"]["steps"]
unit_steps = yaml.load(
(ROOT / ".github/actions/python-unit/action.yml").read_text(), Loader=yaml.BaseLoader
)["runs"]["steps"]
unit = {
key: value
for step in unit_steps
Expand Down Expand Up @@ -207,6 +218,18 @@ def test_nightly_artifact_names_are_unique_across_invocations():
assert len(names) == len(set(names))


def test_pr_gate_covers_every_selected_step():
job = workflow("ci-pr.yml")["jobs"]["python"]
gate = next(step for step in job["steps"] if step.get("id") == "gate")

def keys(template):
return set(re.findall(r'^\s*"([\w-]+)":', template, re.MULTILINE))

suites = {step["id"] for step in job["steps"] if step.get("uses", "").startswith("./.github/actions/")}
assert keys(gate["env"]["NEEDS_JSON"]) == keys(gate["env"]["EXPECTED_RESULTS"])
assert len(keys(gate["env"]["NEEDS_JSON"])) == len(suites) + 1


@pytest.mark.parametrize(
"directory, step_outcome, exit_code, classification",
[
Expand Down
35 changes: 25 additions & 10 deletions .github/workflows/ci-merge-queue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,18 @@ jobs:
- plan
- prepare-classification-models
if: ${{ needs.plan.outputs.python == 'true' }}
uses: ./.github/workflows/reusable-py-unit.yml
with:
python-version: ${{ needs.plan.outputs.python-highest }}
ref: ${{ needs.plan.outputs.ref }}
collect-coverage: false
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
ref: ${{ needs.plan.outputs.ref }}
persist-credentials: false
fetch-depth: 1
- name: Run Python unit tests
uses: ./.github/actions/python-unit
with:
python-version: ${{ needs.plan.outputs.python-highest }}

python-integration:
needs:
Expand All @@ -124,11 +131,19 @@ jobs:
airflow-apis:
needs: [plan, backend]
if: ${{ needs.plan.outputs.airflow-apis == 'true' }}
uses: ./.github/workflows/reusable-py-airflow-apis.yml
with:
ref: ${{ needs.plan.outputs.ref }}
use-backend-image: true
python-version: ${{ needs.plan.outputs.python-lowest }}
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
ref: ${{ needs.plan.outputs.ref }}
persist-credentials: false
fetch-depth: 1
- name: Run Airflow API tests
uses: ./.github/actions/python-airflow-apis
with:
python-version: ${{ needs.plan.outputs.python-lowest }}
use-backend-image: 'true'

py-tests-status:
name: py-tests-status
Expand Down
41 changes: 29 additions & 12 deletions .github/workflows/ci-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,21 @@ jobs:
fail-fast: false
matrix:
python: ${{ fromJSON(needs.plan.outputs.python-versions) }}
uses: ./.github/workflows/reusable-py-unit.yml
with:
python-version: ${{ matrix.python }}
ref: ${{ needs.plan.outputs.ref }}
collect-coverage: ${{ github.ref == 'refs/heads/main' && matrix.python == needs.plan.outputs.python-lowest }}
run-tooling-tests: ${{ matrix.python == needs.plan.outputs.python-highest }}
name: Unit Tests (${{ matrix.python }})
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
ref: ${{ needs.plan.outputs.ref }}
persist-credentials: false
fetch-depth: 1
- name: Run Python unit tests
uses: ./.github/actions/python-unit
with:
python-version: ${{ matrix.python }}
collect-coverage: ${{ github.ref == 'refs/heads/main' && matrix.python == needs.plan.outputs.python-lowest }}
run-tooling-tests: ${{ matrix.python == needs.plan.outputs.python-highest }}

python-integration:
needs:
Expand Down Expand Up @@ -161,12 +170,20 @@ jobs:

airflow-apis:
needs: [plan, backend]
uses: ./.github/workflows/reusable-py-airflow-apis.yml
with:
ref: ${{ needs.plan.outputs.ref }}
python-version: ${{ needs.plan.outputs.python-lowest }}
use-backend-image: true
collect-coverage: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
with:
ref: ${{ needs.plan.outputs.ref }}
persist-credentials: false
fetch-depth: 1
- name: Run Airflow API tests
uses: ./.github/actions/python-airflow-apis
with:
python-version: ${{ needs.plan.outputs.python-lowest }}
use-backend-image: 'true'
collect-coverage: ${{ github.ref == 'refs/heads/main' }}

py-tests-status:
name: py-tests-status
Expand Down
Loading
Loading