Skip to content

Commit 12735bc

Browse files
Merge branch 'stable' into may-202501-repo-ref-commit-fix-1
2 parents 1b2397e + aa65bb0 commit 12735bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+390
-254
lines changed

.github/workflows/ci.yml

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ jobs:
116116

117117

118118
unit-tests:
119+
env:
120+
# workaround for Rich table column width
121+
COLUMNS: 140
119122
strategy:
120123
matrix:
121124
python-version:
@@ -148,8 +151,6 @@ jobs:
148151
run: "poetry install --all-extras"
149152
- name: "Mypy Tests"
150153
run: "poetry run mypy --show-error-codes infrahub_sdk/"
151-
# - name: "Pylint Tests"
152-
# run: "poetry run pylint infrahub_sdk/"
153154
- name: "Unit Tests"
154155
run: "poetry run pytest --cov infrahub_sdk tests/unit/"
155156
- name: "Upload coverage to Codecov"
@@ -173,7 +174,7 @@ jobs:
173174
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
174175

175176
# ------------------------------------------ Integration Tests ------------------------------------------
176-
integration-tests:
177+
integration-tests-latest-infrahub:
177178
if: |
178179
always() && !cancelled() &&
179180
!contains(needs.*.result, 'failure') &&
@@ -201,8 +202,87 @@ jobs:
201202
pip install invoke toml codecov
202203
- name: "Install Package"
203204
run: "poetry install --all-extras"
205+
- name: "Set environment variables for python_testcontainers"
206+
run: |
207+
echo INFRAHUB_TESTING_IMAGE_VER=latest >> $GITHUB_ENV
204208
- name: "Integration Tests"
205-
run: "poetry run pytest --cov infrahub_sdk tests/integration/"
209+
run: |
210+
poetry run pytest --cov infrahub_sdk tests/integration/
211+
- name: "Upload coverage to Codecov"
212+
run: |
213+
codecov --flags integration-tests
214+
env:
215+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
216+
217+
integration-tests-local-infrahub:
218+
if: |
219+
always() && !cancelled() &&
220+
!contains(needs.*.result, 'failure') &&
221+
!contains(needs.*.result, 'cancelled') &&
222+
needs.files-changed.outputs.python == 'true' &&
223+
(github.base_ref == 'stable' || github.base_ref == 'develop')
224+
needs: ["files-changed", "yaml-lint", "python-lint"]
225+
runs-on:
226+
group: "huge-runners"
227+
timeout-minutes: 30
228+
steps:
229+
- name: "Check out repository code"
230+
uses: "actions/checkout@v4"
231+
232+
- name: "Extract target branch name"
233+
id: extract_branch
234+
run: echo "TARGET_BRANCH=${{ github.base_ref }}" >> $GITHUB_ENV
235+
236+
- name: "Checkout infrahub repository"
237+
uses: "actions/checkout@v4"
238+
with:
239+
repository: "opsmill/infrahub"
240+
path: "infrahub-server"
241+
ref: ${{ github.base_ref }}
242+
submodules: true
243+
244+
- name: Set up Python
245+
uses: actions/setup-python@v5
246+
with:
247+
python-version: "3.12"
248+
249+
- name: "Setup git credentials prior dev.build"
250+
run: |
251+
cd infrahub-server
252+
git config --global user.name 'Infrahub'
253+
git config --global user.email '[email protected]'
254+
git config --global --add safe.directory '*'
255+
git config --global credential.usehttppath true
256+
git config --global credential.helper /usr/local/bin/infrahub-git-credential
257+
258+
- name: "Set environment variables prior dev.build"
259+
run: |
260+
echo "INFRAHUB_BUILD_NAME=infrahub-${{ runner.name }}" >> $GITHUB_ENV
261+
RUNNER_NAME=$(echo "${{ runner.name }}" | grep -o 'ghrunner[0-9]\+' | sed 's/ghrunner\([0-9]\+\)/ghrunner_\1/')
262+
echo "PYTEST_DEBUG_TEMPROOT=/var/lib/github/${RUNNER_NAME}/_temp" >> $GITHUB_ENV
263+
echo "INFRAHUB_IMAGE_VER=local-${{ runner.name }}-${{ github.sha }}" >> $GITHUB_ENV
264+
echo "INFRAHUB_TESTING_IMAGE_VER=local-${{ runner.name }}-${{ github.sha }}" >> $GITHUB_ENV
265+
echo "INFRAHUB_TESTING_DOCKER_IMAGE=opsmill/infrahub" >> $GITHUB_ENV
266+
267+
- name: "Build container"
268+
run: |
269+
cd infrahub-server
270+
inv dev.build
271+
272+
- name: "Setup environment"
273+
run: |
274+
pipx install poetry==1.8.5
275+
poetry config virtualenvs.create true --local
276+
pip install invoke toml codecov
277+
278+
- name: "Install Package"
279+
run: "poetry install --all-extras"
280+
281+
- name: "Integration Tests"
282+
run: |
283+
echo "Running tests for version: $INFRAHUB_TESTING_IMAGE_VER"
284+
poetry run pytest --cov infrahub_sdk tests/integration/
285+
206286
- name: "Upload coverage to Codecov"
207287
run: |
208288
codecov --flags integration-tests

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ This project uses [*towncrier*](https://towncrier.readthedocs.io/) and the chang
1111

1212
<!-- towncrier release notes start -->
1313

14+
## [1.7.1](https://github.com/opsmill/infrahub-sdk-python/tree/v1.7.1) - 2025-01-30
15+
16+
### Removed
17+
18+
- All mention of pylint have been removed from the project. ([#206](https://github.com/opsmill/infrahub-sdk-python/issues/206))
19+
20+
## [1.7.0](https://github.com/opsmill/infrahub-sdk-python/tree/v1.7.0) - 2025-01-23
21+
22+
### Added
23+
24+
- adds `infrahubctl repository list` command
25+
1426
## [1.6.1](https://github.com/opsmill/infrahub-sdk-python/tree/v1.6.1) - 2025-01-16
1527

1628
Fixes release of v1.6.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Aligned the environment variables used by the `infrahubctl` with the environment variables used by the SDK
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

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/towncrier.md.template

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{% if render_title %}
2+
{% if versiondata.name %}
3+
# {{ versiondata.name }} {{ versiondata.version }} ({{ versiondata.date }})
4+
{% else %}
5+
# {{ versiondata.version }} ({{ versiondata.date }})
6+
{% endif %}
7+
{% endif %}
8+
{% for section, _ in sections.items() %}
9+
{% if section %}
10+
11+
## {{section}}
12+
{% endif %}
13+
{% if sections[section] %}
14+
{% for category, val in definitions.items() if category in sections[section] %}
15+
### {{ definitions[category]['name'] }}
16+
17+
{% for text, values in sections[section][category].items() %}
18+
- {{ text }}
19+
{%- if values %}
20+
{% if "\n - " in text or '\n * ' in text %}
21+
22+
23+
(
24+
{%- else %}
25+
{% if text %} ({% endif %}
26+
{%- endif -%}
27+
{%- for issue in values %}
28+
{{ issue.split(": ", 1)[0] }}{% if not loop.last %}, {% endif %}
29+
{%- endfor %}
30+
{% if text %}){% endif %}
31+
32+
{% else %}
33+
34+
{% endif %}
35+
{% endfor %}
36+
37+
{% if issues_by_category[section][category] and "]: " in issues_by_category[section][category][0] %}
38+
{% for issue in issues_by_category[section][category] %}
39+
{{ issue }}
40+
{% endfor %}
41+
42+
{% endif %}
43+
{% if sections[section][category]|length == 0 %}
44+
No significant changes.
45+
46+
{% else %}
47+
{% endif %}
48+
{% endfor %}
49+
{% else %}
50+
No significant changes.
51+
52+
{% endif %}
53+
{% endfor +%}

infrahub_sdk/batch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def execute(self, return_exceptions: bool = False) -> tuple[InfrahubNodeSync | N
3030
result = None
3131
try:
3232
result = self.task(*self.args, **self.kwargs)
33-
except Exception as exc: # pylint: disable=broad-exception-caught
33+
except Exception as exc:
3434
if return_exceptions:
3535
return self.node, exc
3636
raise exc
@@ -44,7 +44,7 @@ async def execute_batch_task_in_pool(
4444
async with semaphore:
4545
try:
4646
result = await task.task(*task.args, **task.kwargs)
47-
except Exception as exc: # pylint: disable=broad-exception-caught
47+
except Exception as exc:
4848
if return_exceptions:
4949
return (task.node, exc)
5050
raise exc

infrahub_sdk/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def validate_address(cls, value: str) -> str:
113113

114114
@model_validator(mode="after")
115115
def validate_proxy_config(self) -> Self:
116-
if self.proxy and self.proxy_mounts.is_set: # pylint: disable=no-member
116+
if self.proxy and self.proxy_mounts.is_set:
117117
raise ValueError("'proxy' and 'proxy_mounts' are mutually exclusive")
118118
return self
119119

infrahub_sdk/ctl/check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ async def run_check(
121121
except QueryNotFoundError as exc:
122122
log.warning(f"{module_name}::{check}: unable to find query ({exc!s})")
123123
passed = False
124-
except Exception as exc: # pylint: disable=broad-exception-caught
124+
except Exception as exc:
125125
log.warning(f"{module_name}::{check}: An error occurred during execution ({exc})")
126126
passed = False
127127

infrahub_sdk/ctl/cli_commands.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ 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 = typer.Option(
134-
4,
132+
branch: str = typer.Option("main", help="Branch on which to run the script."), # TODO: Replace main by None
133+
concurrent: int | None = typer.Option(
134+
None,
135135
help="Maximum number of requests to execute at the same time.",
136-
envvar="INFRAHUBCTL_CONCURRENT_EXECUTION",
136+
envvar="INFRAHUB_MAX_CONCURRENT_EXECUTION",
137137
),
138-
timeout: int = typer.Option(60, help="Timeout in sec", envvar="INFRAHUBCTL_TIMEOUT"),
138+
timeout: int = typer.Option(60, help="Timeout in sec", envvar="INFRAHUB_TIMEOUT"),
139139
variables: list[str] | None = typer.Argument(
140140
None, help="Variables to pass along with the query. Format key=value key=value."
141141
),
@@ -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)