Skip to content

Commit d7a640f

Browse files
authored
Merge pull request #280 from opsmill/develop
Sync Infrahub-develop with develop
2 parents 984285f + 825363c commit d7a640f

34 files changed

+267
-143
lines changed

.github/workflows/ci.yml

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ jobs:
126126
- "3.10"
127127
- "3.11"
128128
- "3.12"
129-
- "3.13"
130129
if: |
131130
always() && !cancelled() &&
132131
!contains(needs.*.result, 'failure') &&
@@ -144,7 +143,7 @@ jobs:
144143
python-version: ${{ matrix.python-version }}
145144
- name: "Setup environment"
146145
run: |
147-
pipx install poetry==1.8.5
146+
pipx install poetry==1.8.5 --python python${{ matrix.python-version }}
148147
poetry config virtualenvs.create true --local
149148
pip install invoke toml codecov
150149
- name: "Install Package"
@@ -174,7 +173,7 @@ jobs:
174173
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
175174

176175
# ------------------------------------------ Integration Tests ------------------------------------------
177-
integration-tests:
176+
integration-tests-latest-infrahub:
178177
if: |
179178
always() && !cancelled() &&
180179
!contains(needs.*.result, 'failure') &&
@@ -202,10 +201,91 @@ jobs:
202201
pip install invoke toml codecov
203202
- name: "Install Package"
204203
run: "poetry install --all-extras"
204+
- name: "Set environment variables for python_testcontainers"
205+
run: |
206+
echo INFRAHUB_TESTING_IMAGE_VER=latest >> $GITHUB_ENV
205207
- name: "Integration Tests"
206-
run: "poetry run pytest --cov infrahub_sdk tests/integration/"
208+
run: |
209+
poetry run pytest --cov infrahub_sdk tests/integration/
207210
- name: "Upload coverage to Codecov"
208211
run: |
209212
codecov --flags integration-tests
210213
env:
211214
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
215+
216+
# NOTE: Disabling this test for now because it's expected that we can't start the latest version of infrahub
217+
# with the current shipping version of infrahub-testcontainers
218+
# integration-tests-local-infrahub:
219+
# if: |
220+
# always() && !cancelled() &&
221+
# !contains(needs.*.result, 'failure') &&
222+
# !contains(needs.*.result, 'cancelled') &&
223+
# needs.files-changed.outputs.python == 'true' &&
224+
# (github.base_ref == 'stable' || github.base_ref == 'develop')
225+
# needs: ["files-changed", "yaml-lint", "python-lint"]
226+
# runs-on:
227+
# group: "huge-runners"
228+
# timeout-minutes: 30
229+
# steps:
230+
# - name: "Check out repository code"
231+
# uses: "actions/checkout@v4"
232+
233+
# - name: "Extract target branch name"
234+
# id: extract_branch
235+
# run: echo "TARGET_BRANCH=${{ github.base_ref }}" >> $GITHUB_ENV
236+
237+
# - name: "Checkout infrahub repository"
238+
# uses: "actions/checkout@v4"
239+
# with:
240+
# repository: "opsmill/infrahub"
241+
# path: "infrahub-server"
242+
# ref: ${{ github.base_ref }}
243+
# submodules: true
244+
245+
# - name: Set up Python
246+
# uses: actions/setup-python@v5
247+
# with:
248+
# python-version: "3.12"
249+
250+
# - name: "Setup git credentials prior dev.build"
251+
# run: |
252+
# cd infrahub-server
253+
# git config --global user.name 'Infrahub'
254+
# git config --global user.email '[email protected]'
255+
# git config --global --add safe.directory '*'
256+
# git config --global credential.usehttppath true
257+
# git config --global credential.helper /usr/local/bin/infrahub-git-credential
258+
259+
# - name: "Set environment variables prior dev.build"
260+
# run: |
261+
# echo "INFRAHUB_BUILD_NAME=infrahub-${{ runner.name }}" >> $GITHUB_ENV
262+
# RUNNER_NAME=$(echo "${{ runner.name }}" | grep -o 'ghrunner[0-9]\+' | sed 's/ghrunner\([0-9]\+\)/ghrunner_\1/')
263+
# echo "PYTEST_DEBUG_TEMPROOT=/var/lib/github/${RUNNER_NAME}/_temp" >> $GITHUB_ENV
264+
# echo "INFRAHUB_IMAGE_VER=local-${{ runner.name }}-${{ github.sha }}" >> $GITHUB_ENV
265+
# echo "INFRAHUB_TESTING_IMAGE_VER=local-${{ runner.name }}-${{ github.sha }}" >> $GITHUB_ENV
266+
# echo "INFRAHUB_TESTING_DOCKER_IMAGE=opsmill/infrahub" >> $GITHUB_ENV
267+
268+
# - name: "Build container"
269+
# run: |
270+
# cd infrahub-server
271+
# inv dev.build
272+
273+
# - name: "Setup environment"
274+
# run: |
275+
# pipx install poetry==1.8.5
276+
# poetry config virtualenvs.create true --local
277+
# pip install invoke toml codecov
278+
279+
# - name: "Install Package"
280+
# run: "poetry install --all-extras"
281+
282+
# - name: "Integration Tests"
283+
# run: |
284+
# echo "Running tests for version: $INFRAHUB_TESTING_IMAGE_VER"
285+
# poetry run pytest --cov infrahub_sdk tests/integration/
286+
287+
# - name: "Upload coverage to Codecov"
288+
# run: |
289+
# codecov --flags integration-tests
290+
# env:
291+
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added logger to `InfrahubGenerator` class to allow users use built-in logging (`self.logger`) to show logging within Infrahub CI pipeline.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Changes InfrahubNode `artifact_fetch` and `artifact_generate` methods to use the name of the artifact instead of the name of the artifact definition
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Move the function `read_file` from the ctl module to the SDK.

changelog/104.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- `protocols` CTL command properly gets default branch setting from environment variable

changelog/251.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix typing for Python 3.9 and remove support for Python 3.13

changelog/264.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove default value "main" for branch parameter from all Infrahub CTL commands.

infrahub_sdk/ctl/_file.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

infrahub_sdk/ctl/check.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from asyncio import run as aiorun
66
from dataclasses import dataclass
77
from pathlib import Path
8-
from typing import TYPE_CHECKING
8+
from typing import TYPE_CHECKING, Optional
99

1010
import typer
1111
from rich.console import Console
@@ -50,8 +50,8 @@ def run(
5050
format_json: bool,
5151
list_available: bool,
5252
variables: dict[str, str],
53-
name: str | None = None,
54-
branch: str | None = None,
53+
name: Optional[str] = None,
54+
branch: Optional[str] = None,
5555
) -> None:
5656
"""Locate and execute all checks under the defined path."""
5757

infrahub_sdk/ctl/cli_commands.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import platform
88
import sys
99
from pathlib import Path
10-
from typing import TYPE_CHECKING, Any, Callable
10+
from typing import TYPE_CHECKING, Any, Callable, Optional
1111

1212
import jinja2
1313
import typer
@@ -74,13 +74,13 @@
7474
@catch_exception(console=console)
7575
def check(
7676
check_name: str = typer.Argument(default="", help="Name of the Python check"),
77-
branch: str | None = None,
77+
branch: Optional[str] = None,
7878
path: str = typer.Option(".", help="Root directory"),
7979
debug: bool = False,
8080
format_json: bool = False,
8181
_: str = CONFIG_PARAM,
8282
list_available: bool = typer.Option(False, "--list", help="Show available Python checks"),
83-
variables: list[str] | None = typer.Argument(
83+
variables: Optional[list[str]] = typer.Argument(
8484
None, help="Variables to pass along with the query. Format key=value key=value."
8585
),
8686
) -> None:
@@ -102,12 +102,12 @@ def check(
102102
@catch_exception(console=console)
103103
async def generator(
104104
generator_name: str = typer.Argument(default="", help="Name of the Generator"),
105-
branch: str | None = None,
105+
branch: Optional[str] = None,
106106
path: str = typer.Option(".", help="Root directory"),
107107
debug: bool = False,
108108
_: str = CONFIG_PARAM,
109109
list_available: bool = typer.Option(False, "--list", help="Show available Generators"),
110-
variables: list[str] | None = typer.Argument(
110+
variables: Optional[list[str]] = typer.Argument(
111111
None, help="Variables to pass along with the query. Format key=value key=value."
112112
),
113113
) -> None:
@@ -129,14 +129,14 @@ async def run(
129129
method: str = "run",
130130
debug: bool = False,
131131
_: str = CONFIG_PARAM,
132-
branch: str = typer.Option("main", help="Branch on which to run the script."),
133-
concurrent: int | None = typer.Option(
132+
branch: str = typer.Option(None, help="Branch on which to run the script."),
133+
concurrent: Optional[int] = typer.Option(
134134
None,
135135
help="Maximum number of requests to execute at the same time.",
136136
envvar="INFRAHUB_MAX_CONCURRENT_EXECUTION",
137137
),
138138
timeout: int = typer.Option(60, help="Timeout in sec", envvar="INFRAHUB_TIMEOUT"),
139-
variables: list[str] | None = typer.Argument(
139+
variables: Optional[list[str]] = typer.Argument(
140140
None, help="Variables to pass along with the query. Format key=value key=value."
141141
),
142142
) -> None:
@@ -259,7 +259,7 @@ def _run_transform(
259259
@catch_exception(console=console)
260260
def render(
261261
transform_name: str = typer.Argument(default="", help="Name of the Python transformation", show_default=False),
262-
variables: list[str] | None = typer.Argument(
262+
variables: Optional[list[str]] = typer.Argument(
263263
None, help="Variables to pass along with the query. Format key=value key=value."
264264
),
265265
branch: str = typer.Option(None, help="Branch on which to render the transform."),
@@ -309,7 +309,7 @@ def render(
309309
@catch_exception(console=console)
310310
def transform(
311311
transform_name: str = typer.Argument(default="", help="Name of the Python transformation", show_default=False),
312-
variables: list[str] | None = typer.Argument(
312+
variables: Optional[list[str]] = typer.Argument(
313313
None, help="Variables to pass along with the query. Format key=value key=value."
314314
),
315315
branch: str = typer.Option(None, help="Branch on which to run the transformation"),
@@ -383,6 +383,7 @@ def protocols(
383383

384384
else:
385385
client = initialize_client_sync()
386+
branch = branch or client.default_branch
386387
schema.update(client.schema.fetch(branch=branch))
387388

388389
code_generator = CodeGenerator(schema=schema)

0 commit comments

Comments
 (0)