Skip to content

Commit e169b9c

Browse files
authored
fix: deep_import on a repository loading (#62)
1 parent bb53aba commit e169b9c

File tree

13 files changed

+216
-79
lines changed

13 files changed

+216
-79
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @stacklet/platform
1+
* @stacklet/engineering

.github/workflows/ci.yaml

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,53 +12,70 @@ jobs:
1212
Lint:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v2
16-
- uses: actions/setup-python@v2.2.1
15+
- uses: actions/checkout@v4
16+
- uses: wistia/parse-tool-versions@v1.0
17+
- uses: actions/setup-python@v5
1718
with:
18-
python-version: 3.9
19+
python-version: ${{ env.PYTHON_TOOL_VERSION }}
1920
- name: Linting
2021
run: |
2122
pip install pre-commit
2223
pre-commit run --all-files
2324
2425
Tests:
26+
name: Run the tests against .tool-versions python
2527
needs: Lint
2628
runs-on: ubuntu-latest
2729
steps:
28-
- uses: actions/checkout@v2
29-
- name: Set up Python 3.9
30-
uses: actions/setup-python@v2.2.1
30+
- uses: actions/checkout@v4
31+
- uses: wistia/parse-tool-versions@v1.0
32+
- uses: extractions/setup-just@v1
33+
with:
34+
just-version: ${{ env.JUST_TOOL_VERSION }}
35+
- name: Install and configure Poetry
36+
uses: snok/install-poetry@v1
3137
with:
32-
python-version: "3.9"
38+
version: ${{ env.POETRY_TOOL_VERSION }}
39+
virtualenvs-in-project: true
3340

34-
- name: Install poetry
35-
shell: bash
36-
run: |
37-
curl -sSL https://install.python-poetry.org | python3 - --version 1.5.1
38-
echo "$HOME/.local/bin" >> $GITHUB_PATH
41+
- name: Set up Python ${{ env.PYTHON_TOOL_VERSION }}
42+
uses: actions/setup-python@v5
43+
with:
44+
python-version: ${{ env.PYTHON_TOOL_VERSION }}
45+
cache: poetry
3946

40-
- name: Configure poetry
47+
- name: Install dependencies
4148
shell: bash
42-
run: poetry config virtualenvs.in-project true
49+
run: poetry install
50+
51+
- name: Pytest run
52+
run: just test -v
4353

44-
- name: Set up cache
45-
uses: actions/cache@v2.1.4
46-
id: cache
54+
OldestPython:
55+
name: Run the tests against python 3.9 (oldest supported version)
56+
needs: Lint
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v4
60+
- uses: wistia/parse-tool-versions@v1.0
61+
- uses: extractions/setup-just@v1
4762
with:
48-
path: |
49-
.venv
50-
~/.cache
51-
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
63+
just-version: ${{ env.JUST_TOOL_VERSION }}
64+
- name: Install and configure Poetry
65+
uses: snok/install-poetry@v1
66+
with:
67+
version: ${{ env.POETRY_TOOL_VERSION }}
68+
virtualenvs-in-project: true
5269

53-
- name: Ensure cache is healthy
54-
if: steps.cache.outputs.cache-hit == 'true'
55-
shell: bash
56-
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
70+
- name: Set up Python 3.9
71+
uses: actions/setup-python@v5
72+
with:
73+
python-version: 3.9
74+
cache: poetry
5775

5876
- name: Install dependencies
5977
shell: bash
6078
run: poetry install
6179

6280
- name: Pytest run
63-
shell: bash
64-
run: poetry run pytest --cov=stacklet_cli -v tests
81+
run: just test -v

.github/workflows/release.yaml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,25 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- uses: actions/checkout@v4
11-
- name: Set up Python
12-
uses: actions/setup-python@v4
11+
- uses: wistia/parse-tool-versions@v1.0
12+
- uses: extractions/setup-just@v1
1313
with:
14-
python-version: "3.9"
14+
just-version: ${{ env.JUST_TOOL_VERSION }}
1515
- name: Install and configure Poetry
1616
uses: snok/install-poetry@v1
1717
with:
18-
version: 1.5.1
18+
version: ${{ env.POETRY_TOOL_VERSION }}
19+
virtualenvs-in-project: true
20+
21+
- name: Set up Python ${{ env.PYTHON_TOOL_VERSION }}
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ env.PYTHON_TOOL_VERSION }}
25+
cache: poetry
26+
1927
- name: Build a binary wheel and a source tarball
2028
run: poetry build
29+
2130
- name: Store the distribution packages
2231
uses: actions/upload-artifact@v3
2332
with:

.tool-versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
just 1.13.0
2-
poetry 1.5.1
3-
python 3.9.15
2+
poetry 1.8.3
3+
python 3.11.3

stacklet/client/platform/commands/policycollection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ class AddPolicyCollectionItem(StackletGraphqlSnippet):
183183
}
184184

185185
optional = {"policy_version": "Policy Version"}
186+
variable_transformers = {"policy_version": lambda x: x and int(x)}
186187

187188

188189
@StackletGraphqlExecutor.registry.register("remove-policy-collection-item")

stacklet/client/platform/commands/repository.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ class AddRepositorySnippet(StackletGraphqlSnippet):
6161
},
6262
"deep_import": "Deep Import Repository true | false",
6363
}
64+
variable_transformers = {
65+
"deep_import": lambda x: x and x.lower() in ("true", "t", "yes", "y")
66+
}
6467

6568

6669
@StackletGraphqlExecutor.registry.register("process-repository")

stacklet/client/platform/graphql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class StackletGraphqlSnippet:
66
"""
7-
A resusable Graphql Snippet
7+
A reusable Graphql Snippet
88
99
Define required variables with the required class attribute and optional
1010
variables with the optional class attribute. The value can either be a string

tests/__init__.py

Whitespace-only changes.

tests/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from tempfile import NamedTemporaryFile
77
import textwrap
88

9-
from utils import BaseCliTest
9+
from .utils import BaseCliTest
1010

1111

1212
class AdminCliTest(BaseCliTest):

tests/test_graphql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import yaml
66
from unittest.mock import patch
77

8-
from utils import BaseCliTest, get_executor_adapter
8+
from .utils import BaseCliTest, get_executor_adapter
99

1010

1111
class GraphqlTest(BaseCliTest):

0 commit comments

Comments
 (0)