Skip to content

docs: update compatibility matrix #3694

docs: update compatibility matrix

docs: update compatibility matrix #3694

Workflow file for this run

---
# yamllint disable rule:truthy rule:truthy rule:line-length
name: "CI"
on:
pull_request:
push:
branches:
- develop
- stable
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
INFRAHUB_DB_USERNAME: neo4j
INFRAHUB_DB_PASSWORD: admin
INFRAHUB_DB_ADDRESS: localhost
INFRAHUB_DB_PORT: 7687
INFRAHUB_DB_PROTOCOL: bolt
INFRAHUB_BROKER_ADDRESS: message-queue
INFRAHUB_LOG_LEVEL: CRITICAL
INFRAHUB_IMAGE_NAME: "opsmill/infrahub"
INFRAHUB_IMAGE_VER: "local"
INFRAHUB_TEST_IN_DOCKER: 1
VALE_VERSION: "3.7.1"
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
METRICS_ENDPOINT: ${{ secrets.METRICS_ENDPOINT }}
jobs:
prepare-environment:
uses: ./.github/workflows/define-versions.yml
# ------------------------------------------ Check Files Changes ------------------------------------------
files-changed:
name: Detect which file has changed
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
documentation: ${{ steps.changes.outputs.documentation_all }}
documentation_generated: ${{ steps.changes.outputs.documentation_generated_all }}
helm: ${{ steps.changes.outputs.helm_all }}
python: ${{ steps.changes.outputs.python_all }}
yaml: ${{ steps.changes.outputs.yaml_all }}
uv_files: ${{ steps.changes.outputs.uv_files }}
github_workflows: ${{ steps.changes.outputs.github_workflows }}
steps:
- name: "Check out repository code"
uses: "actions/checkout@v7"
- name: Check for file changes
uses: dorny/paths-filter@v4
id: changes
with:
token: ${{ github.token }}
filters: .github/file-filters.yml
# ------------------------------------------ All Linter ------------------------------------------
yaml-lint:
if: needs.files-changed.outputs.yaml == 'true'
needs: ["files-changed"]
runs-on: "ubuntu-latest"
timeout-minutes: 5
steps:
- name: "Check out repository code"
uses: "actions/checkout@v7"
- name: "Setup environment"
run: "pip install yamllint==1.35.1"
- name: "Linting: yamllint"
run: "yamllint -s ."
python-lint:
if: needs.files-changed.outputs.python == 'true'
needs: ["files-changed", "prepare-environment"]
runs-on: "ubuntu-latest"
timeout-minutes: 5
steps:
- name: "Check out repository code"
uses: "actions/checkout@v7"
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Install UV
uses: astral-sh/setup-uv@v7
with:
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"
- name: Install dependencies
run: uv sync --all-groups --all-extras
- name: "Linting: ruff check"
run: "uv run ruff check ."
- name: "Linting: ruff format"
run: "uv run ruff format --check --diff ."
- name: "Linting: ty check"
run: "uv run ty check ."
markdown-lint:
if: |
needs.files-changed.outputs.documentation == 'true' ||
needs.files-changed.outputs.github_workflows == 'true'
needs: ["files-changed", "prepare-environment"]
runs-on: "ubuntu-latest"
timeout-minutes: 5
steps:
- name: "Check out repository code"
uses: "actions/checkout@v7"
- name: "Install uv"
uses: astral-sh/setup-uv@v7
with:
version: ${{ needs.prepare-environment.outputs.UV_VERSION }}
- name: "Linting: rumdl"
run: "uvx rumdl@0.2.28 check ."
action-lint:
if: needs.files-changed.outputs.github_workflows == 'true'
needs: ["files-changed"]
runs-on: "ubuntu-latest"
timeout-minutes: 5
steps:
- name: "Check out repository code"
uses: "actions/checkout@v7"
- name: Check workflow files
run: |
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
./actionlint -color
shell: bash
env:
SHELLCHECK_OPTS: --exclude=SC2086 --exclude=SC2046 --exclude=SC2004 --exclude=SC2129
uv-lock-check:
if: |
needs.files-changed.outputs.uv_files == 'true' ||
needs.files-changed.outputs.github_workflows == 'true'
needs:
- files-changed
- prepare-environment
runs-on: "ubuntu-latest"
timeout-minutes: 5
steps:
- name: "Check out repository code"
uses: "actions/checkout@v7"
- name: "Set up Python"
uses: "actions/setup-python@v7"
with:
python-version: "3.12"
- name: "Install uv"
uses: astral-sh/setup-uv@v7
with:
version: ${{ needs.prepare-environment.outputs.UV_VERSION }}
- name: "Validate pyproject.toml and consistency with uv.lock"
run: uv lock --locked --offline
documentation:
defaults:
run:
working-directory: ./docs
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.files-changed.outputs.documentation == 'true'
needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint"]
runs-on: "ubuntu-22.04"
timeout-minutes: 5
steps:
- name: "Check out repository code"
uses: "actions/checkout@v7"
with:
submodules: true
- name: Install NodeJS
uses: actions/setup-node@v7
with:
node-version: 24
cache: "npm"
cache-dependency-path: docs/package-lock.json
- name: "Install dependencies"
run: npm install
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Install UV
uses: astral-sh/setup-uv@v7
with:
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"
- name: Install dependencies
run: uv sync --all-groups --all-extras
- name: "Build docs website"
run: "uv run invoke docs"
validate-generated-documentation:
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
(needs.files-changed.outputs.python == 'true' || needs.files-changed.outputs.documentation_generated == 'true')
needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint"]
runs-on: "ubuntu-22.04"
timeout-minutes: 5
steps:
- name: "Check out repository code"
uses: "actions/checkout@v7"
with:
submodules: true
- name: Install NodeJS
uses: actions/setup-node@v7
with:
node-version: 24
cache: "npm"
cache-dependency-path: docs/package-lock.json
- name: "Install npm dependencies"
run: npm install
working-directory: ./docs
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: Install UV
uses: astral-sh/setup-uv@v7
with:
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"
- name: Install dependencies
run: uv sync --all-groups --all-extras
- name: Docs unit tests
run: npx --no-install vitest run
working-directory: ./docs
- name: Validate generated documentation
run: uv run invoke docs-validate
validate-documentation-style:
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled')
needs: ["files-changed", "yaml-lint", "python-lint"]
runs-on: "ubuntu-22.04"
timeout-minutes: 5
steps:
- name: "Check out repository code"
uses: "actions/checkout@v7"
with:
submodules: true
# The official GitHub Action for Vale doesn't work, installing manually instead:
# https://github.com/errata-ai/vale-action/issues/103
# cf -> https://github.com/nf-core/website/pull/3509
- name: Download Vale
run: |
curl -sL "https://github.com/errata-ai/vale/releases/download/v${VALE_VERSION}/vale_${VALE_VERSION}_Linux_64-bit.tar.gz" -o vale.tar.gz
tar -xzf vale.tar.gz
env:
VALE_VERSION: ${{ env.VALE_VERSION }}
- name: "Validate documentation style"
run: ./vale $(find ./docs -type f \( -name "*.mdx" -o -name "*.md" \) )
unit-tests:
env:
# workaround for Rich table column width
COLUMNS: 140
strategy:
matrix:
python-version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
- "3.15"
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.files-changed.outputs.python == 'true'
needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint"]
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: "Check out repository code"
uses: "actions/checkout@v7"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install UV
uses: astral-sh/setup-uv@v7
with:
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: uv sync --all-groups --all-extras
- name: Mypy Tests
run: uv run mypy --show-error-codes infrahub_sdk/
- name: Unit Tests
run: uv run pytest --cov infrahub_sdk tests/unit/
- name: "Upload coverage to Codecov"
run: |
uv run codecov --flags python-${{ matrix.python-version }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# The pytest-cov plugin doesn't quite work with content that is
# auto-imported by our own infrahub pytest plugin, this workaround
# reports the missing lines
- name: "Report coverage for pytest-plugin"
if: matrix.python-version == '3.12'
run: |
uv run coverage run --source=infrahub_sdk -m pytest tests/unit/pytest_plugin
uv run coverage report -m
uv run coverage xml
uv run codecov --flags python-filler-${{ matrix.python-version }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# ------------------------------------------ Dependency Bounds ------------------------------------------
# `unit-tests` installs what uv.lock pins, so it never exercises the ranges in pyproject.toml.
# Upper bounds are tracked separately: an upstream release could turn such a job red on its own.
# Deterministic enough to gate on, since floors only move when pyproject.toml does. Development
# dependencies mask some floors; `dependency-lower-bounds-no-harness` below reaches those.
dependency-lower-bounds:
env:
# workaround for Rich table column width
COLUMNS: 140
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.files-changed.outputs.python == 'true'
needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint"]
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: "Check out repository code"
uses: "actions/checkout@v7"
# Oldest supported interpreter: pyarrow 14, pyyaml 6.0 and ujson 5.0 have no wheels past
# cp312, so a newer one would build them from source. Bump when requires-python changes.
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.10"
- name: Install UV
uses: astral-sh/setup-uv@v7
with:
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"
python-version: "3.10"
# Rewrites uv.lock in the checkout, which is discarded with the runner.
- name: "Re-resolve at the declared lower bounds"
run: uv lock --resolution lowest-direct
- name: Install dependencies
run: uv sync --frozen --all-groups --all-extras
- name: "Report the resolved versions"
run: uv pip list
- name: Unit Tests
run: uv run --frozen pytest --cov infrahub_sdk tests/unit/
# Proves a plain install works on every supported interpreter, which the uv.lock-based jobs cannot.
install-matrix:
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.files-changed.outputs.python == 'true'
needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint"]
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: "Check out repository code"
uses: "actions/checkout@v7"
with:
# hatch-vcs derives the version from git tags, and a shallow clone has none.
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
- name: Install UV
uses: astral-sh/setup-uv@v7
with:
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"
python-version: ${{ matrix.python-version }}
- name: "Build the wheel"
run: uv build --wheel --out-dir dist/
# Not `uv sync`: a fresh resolution of the built wheel is what a user actually gets.
- name: "Install the wheel with every extra"
run: |
uv venv --python ${{ matrix.python-version }} .venv-install
uv pip install --python .venv-install "$(echo dist/*.whl)[all]"
- name: "Report the resolved versions"
run: uv pip list --python .venv-install
# Run from elsewhere: `python -` puts the working directory on sys.path, so from the checkout
# this would import the source tree rather than the wheel.
- name: "Import every shipped module"
working-directory: ${{ runner.temp }}
run: |
${{ github.workspace }}/.venv-install/bin/python - <<'PY'
import importlib, pkgutil, sys
import infrahub_sdk
failures = []
for module in pkgutil.walk_packages(infrahub_sdk.__path__, "infrahub_sdk."):
try:
importlib.import_module(module.name)
except BaseException as exc: # noqa: BLE001
failures.append(f"{module.name}: {type(exc).__name__}: {exc}")
for failure in failures:
print(f"FAIL {failure}")
print(f"{len(failures)} module(s) failed to import")
sys.exit(1 if failures else 0)
PY
- name: "Run the CLI"
run: |
.venv-install/bin/infrahubctl --help
.venv-install/bin/infrahubctl schema --help
.venv-install/bin/infrahubctl branch --help
# With no dependency groups, nothing pulls pytest, pydantic, anyio or typing-extensions above
# their declared floors, so this is the only job that validates those four. httpx and
# graphql-core stay out of reach: ariadne-codegen requires httpx>=0.28 and graphql-core>=3.2.
# It cannot run the unit suite without the harness, so it checks the surface a user touches.
dependency-lower-bounds-no-harness:
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.files-changed.outputs.python == 'true'
needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint"]
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: "Check out repository code"
uses: "actions/checkout@v7"
with:
# hatch-vcs derives the version from git tags, and a shallow clone has none.
fetch-depth: 0
# The oldest supported interpreter, for the same wheel-availability reason as the job above.
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.10"
- name: Install UV
uses: astral-sh/setup-uv@v7
with:
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"
python-version: "3.10"
- name: "Build the wheel"
run: uv build --wheel --out-dir dist/
# From pyproject.toml, not the wheel: `--resolution lowest-direct` only lowers what is named
# on the command line, so asking for the wheel leaves its dependencies at their newest.
- name: "Resolve the extras at their declared lower bounds"
run: |
uv pip compile pyproject.toml --extra ctl --extra testing \
--resolution lowest-direct --python-version 3.10 -o floors.txt
- name: "Install the wheel against those floors, with no dependency groups"
run: |
uv venv --python 3.10 .venv-floors
uv pip install --python .venv-floors -r floors.txt
uv pip install --python .venv-floors --no-deps "$(echo dist/*.whl)"
- name: "Report the resolved versions"
run: uv pip list --python .venv-floors
# From outside the checkout, so this tests the wheel in site-packages and not the source tree.
- name: "Import every shipped module"
working-directory: ${{ runner.temp }}
run: |
${{ github.workspace }}/.venv-floors/bin/python - <<'PY'
import importlib, pkgutil, sys
import infrahub_sdk
# `testing.docker` needs the testcontainers extra, which is deliberately absent here.
skip = {"infrahub_sdk.testing.docker"}
failures = []
for module in pkgutil.walk_packages(infrahub_sdk.__path__, "infrahub_sdk."):
if module.name in skip:
continue
try:
importlib.import_module(module.name)
except BaseException as exc: # noqa: BLE001
failures.append(f"{module.name}: {type(exc).__name__}: {exc}")
for failure in failures:
print(f"FAIL {failure}")
print(f"{len(failures)} module(s) failed to import")
sys.exit(1 if failures else 0)
PY
- name: "Run the CLI"
run: |
.venv-floors/bin/infrahubctl --help
.venv-floors/bin/infrahubctl schema --help
.venv-floors/bin/infrahubctl branch --help
# Collection is where the plugin does its work; importing it would prove far less.
- name: "Collect a test through the bundled pytest plugin"
working-directory: ${{ runner.temp }}
run: |
rm -rf plugin-check && mkdir -p plugin-check/templates && cd plugin-check
cat > infrahub_config.yml <<'YAML'
---
jinja2_transforms:
- name: bgp_config
description: "Template for BGP config base"
query: "bgp_sessions"
template_path: "templates/bgp_config.j2"
YAML
cat > test_bgp.yml <<'YAML'
---
infrahub_tests:
- resource: "Jinja2Transform"
resource_name: "bgp_config"
tests:
- name: smoke
spec:
kind: "jinja2-transform-smoke"
YAML
printf 'router bgp {{ asn }}\n' > templates/bgp_config.j2
# The default shell is `bash -e` without pipefail, so a pytest failure would otherwise
# be reported as a grep failure.
set -o pipefail
${{ github.workspace }}/.venv-floors/bin/python -m pytest \
--infrahub-repo-config=infrahub_config.yml --strict-markers --collect-only -q \
| tee collected.txt
grep -q "infrahub_jinja2_transform__bgp_config__smoke" collected.txt
# ------------------------------------------ Integration Tests ------------------------------------------
integration-tests-latest-infrahub:
if: |
always() && !cancelled() &&
!contains(needs.*.result, 'failure') &&
!contains(needs.*.result, 'cancelled') &&
needs.files-changed.outputs.python == 'true'
needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint", "unit-tests"]
strategy:
fail-fast: false
matrix:
# The files in each shard are listed in INTEGRATION_TEST_SHARDS in tasks.py;
# keep this list in sync with it ("other" runs every file not listed there).
shard: [listed, other]
runs-on:
group: "huge-runners"
timeout-minutes: 30
steps:
- name: "Check out repository code"
uses: "actions/checkout@v7"
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.12"
- name: "Set environment variables"
run: |
RUNNER_NAME=$(echo "${{ runner.name }}" | grep -o 'ghrunner[0-9]\+' | sed 's/ghrunner\([0-9]\+\)/ghrunner_\1/')
echo "PYTEST_DEBUG_TEMPROOT=/var/lib/github/${RUNNER_NAME}/_temp" >> $GITHUB_ENV
- name: Install UV
uses: astral-sh/setup-uv@v7
with:
version: "${{ needs.prepare-environment.outputs.UV_VERSION }}"
- name: Install dependencies
run: uv sync --all-groups --all-extras
- name: "Integration Tests (${{ matrix.shard }})"
run: uv run invoke tests-integration --shard ${{ matrix.shard }}
# Both shards upload with the same flag; Codecov merges the uploads for a
# commit, so the integration-tests flag covers the whole suite.
- name: "Upload coverage to Codecov"
run: |
uv run codecov --flags integration-tests
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# NOTE: Disabling this test for now because it's expected that we can't start the latest version of infrahub
# with the current shipping version of infrahub-testcontainers
# integration-tests-local-infrahub:
# if: |
# always() && !cancelled() &&
# !contains(needs.*.result, 'failure') &&
# !contains(needs.*.result, 'cancelled') &&
# needs.files-changed.outputs.python == 'true' &&
# (github.base_ref == 'stable' || github.base_ref == 'develop')
# needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint", "unit-tests"]
# runs-on:
# group: "huge-runners"
# timeout-minutes: 30
# steps:
# - name: "Check out repository code"
# uses: "actions/checkout@v7"
# - name: "Extract target branch name"
# id: extract_branch
# run: echo "TARGET_BRANCH=${{ github.base_ref }}" >> $GITHUB_ENV
# - name: "Checkout infrahub repository"
# uses: "actions/checkout@v7"
# with:
# repository: "opsmill/infrahub"
# path: "infrahub-server"
# ref: ${{ github.base_ref }}
# submodules: true
# - name: Set up Python
# uses: actions/setup-python@v7
# with:
# python-version: "3.12"
# - name: "Setup git credentials prior dev.build"
# run: |
# cd infrahub-server
# git config --global user.name 'Infrahub'
# git config --global user.email 'infrahub@opsmill.com'
# git config --global --add safe.directory '*'
# git config --global credential.usehttppath true
# git config --global credential.helper /usr/local/bin/infrahub-git-credential
# - name: "Set environment variables prior dev.build"
# run: |
# echo "INFRAHUB_BUILD_NAME=infrahub-${{ runner.name }}" >> $GITHUB_ENV
# RUNNER_NAME=$(echo "${{ runner.name }}" | grep -o 'ghrunner[0-9]\+' | sed 's/ghrunner\([0-9]\+\)/ghrunner_\1/')
# echo "PYTEST_DEBUG_TEMPROOT=/var/lib/github/${RUNNER_NAME}/_temp" >> $GITHUB_ENV
# echo "INFRAHUB_IMAGE_VER=local-${{ runner.name }}-${{ github.sha }}" >> $GITHUB_ENV
# echo "INFRAHUB_TESTING_IMAGE_VER=local-${{ runner.name }}-${{ github.sha }}" >> $GITHUB_ENV
# echo "INFRAHUB_TESTING_DOCKER_IMAGE=opsmill/infrahub" >> $GITHUB_ENV
# - name: "Build container"
# run: |
# cd infrahub-server
# inv dev.build
# - name: "Setup environment"
# run: |
# pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
# poetry config virtualenvs.create true --local
# pip install invoke codecov
# - name: "Install Package"
# run: "poetry install --all-extras"
# - name: "Integration Tests"
# run: |
# echo "Running tests for version: $INFRAHUB_TESTING_IMAGE_VER"
# poetry run pytest --cov infrahub_sdk tests/integration/
# - name: "Upload coverage to Codecov"
# run: |
# codecov --flags integration-tests
# env:
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# ------------------------------------------ Gate ------------------------------------------
# Single rollup check, so branch protection can require CI without naming every
# job (several are conditional, and unit-tests fans out over a moving matrix).
ci-gate:
name: ci-gate
if: always()
needs:
- prepare-environment
- files-changed
- yaml-lint
- python-lint
- markdown-lint
- action-lint
- uv-lock-check
- documentation
- validate-generated-documentation
- validate-documentation-style
- unit-tests
- integration-tests-latest-infrahub
- dependency-lower-bounds
- dependency-lower-bounds-no-harness
- install-matrix
runs-on: "ubuntu-latest"
timeout-minutes: 5
steps:
- name: "Fail if any job did not succeed or skip"
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: |
echo "One or more CI jobs failed or were cancelled."
exit 1