cycl 0.0.1__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. cycl-0.2.0/.github/dependabot.yml +11 -0
  2. cycl-0.2.0/.github/workflows/ci.yml +41 -0
  3. cycl-0.2.0/.github/workflows/release.yml +37 -0
  4. cycl-0.2.0/.gitignore +183 -0
  5. cycl-0.2.0/LICENSE +21 -0
  6. cycl-0.2.0/Makefile +41 -0
  7. cycl-0.2.0/PKG-INFO +57 -0
  8. cycl-0.2.0/README.md +33 -0
  9. cycl-0.2.0/TODO.md +21 -0
  10. cycl-0.2.0/pyproject.toml +86 -0
  11. cycl-0.2.0/requirements-build.txt +2 -0
  12. cycl-0.2.0/requirements-dev.txt +8 -0
  13. cycl-0.2.0/requirements.txt +2 -0
  14. cycl-0.2.0/src/cycl/__init__.py +6 -0
  15. cycl-0.2.0/src/cycl/__main__.py +4 -0
  16. cycl-0.2.0/src/cycl/cli.py +72 -0
  17. cycl-0.2.0/src/cycl/cycl.py +66 -0
  18. cycl-0.2.0/src/cycl/utils/__init__.py +0 -0
  19. cycl-0.2.0/src/cycl/utils/cdk.py +102 -0
  20. cycl-0.2.0/src/cycl/utils/cfn.py +57 -0
  21. cycl-0.2.0/src/cycl/utils/log_config.py +6 -0
  22. cycl-0.2.0/src/cycl/utils/testing.py +7 -0
  23. cycl-0.2.0/src/cycl.egg-info/PKG-INFO +57 -0
  24. cycl-0.2.0/src/cycl.egg-info/SOURCES.txt +36 -0
  25. cycl-0.2.0/src/cycl.egg-info/entry_points.txt +2 -0
  26. cycl-0.2.0/src/cycl.egg-info/requires.txt +2 -0
  27. cycl-0.2.0/src/cycl.egg-info/top_level.txt +1 -0
  28. cycl-0.2.0/tests/__init__.py +0 -0
  29. cycl-0.2.0/tests/cli_test.py +176 -0
  30. cycl-0.2.0/tests/cycl_test.py +445 -0
  31. cycl-0.2.0/tests/utils/__init__.py +0 -0
  32. cycl-0.2.0/tests/utils/cdk_test.py +208 -0
  33. cycl-0.2.0/tests/utils/cfn_test.py +171 -0
  34. cycl-0.2.0/tests/utils/log_config_test.py +17 -0
  35. cycl-0.2.0/tests/utils/testing_test.py +20 -0
  36. cycl-0.0.1/PKG-INFO +0 -15
  37. cycl-0.0.1/README.md +0 -9
  38. cycl-0.0.1/app/cycl.py +0 -2
  39. cycl-0.0.1/cycl.egg-info/PKG-INFO +0 -15
  40. cycl-0.0.1/cycl.egg-info/SOURCES.txt +0 -8
  41. cycl-0.0.1/cycl.egg-info/top_level.txt +0 -1
  42. cycl-0.0.1/pyproject.toml +0 -17
  43. {cycl-0.0.1 → cycl-0.2.0}/setup.cfg +0 -0
  44. /cycl-0.0.1/app/__init__.py → /cycl-0.2.0/src/cycl/py.typed +0 -0
  45. {cycl-0.0.1 → cycl-0.2.0/src}/cycl.egg-info/dependency_links.txt +0 -0
@@ -0,0 +1,11 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "github-actions"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "monthly"
7
+
8
+ - package-ecosystem: "pip"
9
+ directory: "/"
10
+ schedule:
11
+ interval: "monthly"
@@ -0,0 +1,41 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ types: [opened, edited, synchronize]
6
+ push:
7
+ branches: ['master', 'main']
8
+
9
+ env:
10
+ PYTHONPATH: './src:./test'
11
+
12
+ jobs:
13
+ build:
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ os: ['ubuntu-latest']
18
+ python-version: ['3.10', '3.11', '3.12', '3.13']
19
+ runs-on: ${{ matrix.os }}
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+
23
+ - uses: actions/setup-python@v5
24
+ with:
25
+ python-version: ${{ matrix.python-version }}
26
+ cache: 'pip'
27
+
28
+ - name: install deps
29
+ run: pip install --editable . -r requirements-dev.txt
30
+
31
+ - name: lint
32
+ run: ruff check
33
+
34
+ - name: format
35
+ run: ruff format --check
36
+
37
+ - name: static type checking
38
+ run: mypy ./src/
39
+
40
+ - name: test
41
+ run: pytest --cov=./src/ ./tests/
@@ -0,0 +1,37 @@
1
+ name: Release
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ release:
6
+ types: [ published ]
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: 'ubuntu-latest'
11
+ steps:
12
+ - name: dump context
13
+ run: echo "$GITHUB_CONTEXT"
14
+ env:
15
+ GITHUB_CONTEXT: ${{ toJSON(github) }}
16
+
17
+ - uses: actions/checkout@v4
18
+ with:
19
+ ref: ${{ github.event.release.target_commitish }}
20
+ persist-credentials: false
21
+
22
+ - uses: actions/setup-python@v5
23
+ with:
24
+ python-version: '3.13'
25
+ cache: 'pip'
26
+
27
+ - name: install deps
28
+ run: pip install -r requirements-build.txt
29
+
30
+ - name: build
31
+ run: python3 -m build
32
+
33
+ - name: Store the distribution packages
34
+ uses: actions/upload-artifact@v4
35
+ with:
36
+ name: pkg-dist
37
+ path: dist/
cycl-0.2.0/.gitignore ADDED
@@ -0,0 +1,183 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ #.idea/
169
+
170
+ # PyPI configuration file
171
+ .pypirc
172
+
173
+ # ruff
174
+ .ruff_cache
175
+
176
+ # docker
177
+ volume
178
+
179
+ # aws
180
+ aws
181
+
182
+ # make marker files
183
+ requirements.cache
cycl-0.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 tcm5343
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
cycl-0.2.0/Makefile ADDED
@@ -0,0 +1,41 @@
1
+ SHELL := /bin/bash
2
+ .SHELLFLAGS = -ec
3
+ .DEFAULT_GOAL = help
4
+ .PHONY = help clean format test install-deps
5
+
6
+ REQ_FILES := requirements.txt requirements-dev.txt
7
+ REQ_CACHE := requirements.cache
8
+
9
+ help:
10
+ @egrep -h '\s##\s' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-30s\033[0m %s\n", $$1, $$2}'
11
+
12
+ $(REQ_CACHE): $(REQ_FILES)
13
+ @echo "Installing dependencies..."
14
+ pip install --editable . -r requirements-dev.txt
15
+ touch requirements.cache
16
+
17
+ install-deps: $(REQ_CACHE) ## Install dependencies, if needed
18
+ @echo "Dependencies have been installed..."
19
+
20
+ format: ## Format the project
21
+ ruff format
22
+ ruff check --fix
23
+
24
+ validate: ## Validate the project is linted and formatted
25
+ ruff format --check
26
+ ruff check
27
+ mypy ./src/
28
+
29
+ test: ## Run unit tests and generate coverage report
30
+ pytest --cov=./src/ ./tests/
31
+
32
+ clean: ## Clean generated project files
33
+ rm -f $(REQ_CACHE)
34
+ rm -f .coverage
35
+ rm -rf ./.ruff_cache
36
+ rm -rf ./.pytest_cache
37
+ rm -rf ./.venv
38
+ rm -rf ./.tox
39
+ rm -rf ./dist
40
+ rm -rf ./.mypy_cache
41
+ find . -type d -name "__pycache__" -exec rm -r {} +
cycl-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,57 @@
1
+ Metadata-Version: 2.2
2
+ Name: cycl
3
+ Version: 0.2.0
4
+ Summary: CLI and Python SDK to help identify cross-stack import/export circular dependencies, for a given AWS account and region.
5
+ Project-URL: Repository, http://github.com/tcm5343/cycl
6
+ Keywords: aws,cdk,cycle,circular,dependency,infrastructure,boto3,cloud
7
+ Classifier: Intended Audience :: Developers
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Natural Language :: English
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Topic :: Software Development
19
+ Requires-Python: >=3.8
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: boto3~=1.0
23
+ Requires-Dist: networkx~=3.0
24
+
25
+ # cycl
26
+
27
+ [![PyPI](https://img.shields.io/pypi/v/cycl)](https://pypi.org/project/cycl/)
28
+ [![Downloads](https://static.pepy.tech/badge/cycl)](https://pepy.tech/projects/cycl)
29
+ [![Build Status](https://github.com/tcm5343/cycl/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/tcm5343/cycl/actions)
30
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
31
+
32
+ cycl is a CLI and Python SDK to help identify cross-stack import/export circular dependencies, for a given AWS account and region. The successor to [circular-dependency-detector](https://github.com/tcm5343/circular-dependency-detector), which was built at the University of Texas at Austin.
33
+
34
+ ## Getting started
35
+
36
+ Install `cycl` by running `pip install cycl`.
37
+
38
+ ### CLI
39
+
40
+ - `cycl check --exit-zero` - exit 0 regardless of result
41
+ - `cycl check --log-level` - set the logging level (default: WARNING)
42
+ - `cycl check --cdk-out /path/to/cdk.out` - path to cdk.out, where stacks are CDK synthesized to CFN templates
43
+
44
+ ## How to use cycl?
45
+
46
+ There are two main use cases for `cycl`.
47
+
48
+ 1. In a pipeline. `cycl` is best used to detect circular dependencies before a deployment. If you're using the AWS CDK v2 (v1 support coming soon), simply synthesize you templates to a directory and pass that directory to `cycl` using `--cdk-out-path some-path-here `. This allows `cycl` to find all existing cycles and then those to be introduced by the deployment. This prevents the circular dependency from ever being introduced. If your pipeline deploys more than once, you should execute `cycl` before each deployment.
49
+ 2. To perform analysis. While a CLI is best used in a pipeline, if you require analysis which is not currently supported, you can use the SDK. The SDK gives you all the information that `cycl` collects.
50
+
51
+ ## Why use cycl?
52
+
53
+ Over the lifetime of a project, circular references are bound to be introduced. They may not be noticed until you need to re-deploy some infrastructure. A good example is disaster recovery testing and potentially deploying all your infrastructure from scratch in a new region. This tool detects those changes.
54
+
55
+ ## Contributing
56
+
57
+ `cycl` is being actively developed, instructions will come as it becomes more stable.
cycl-0.2.0/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # cycl
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/cycl)](https://pypi.org/project/cycl/)
4
+ [![Downloads](https://static.pepy.tech/badge/cycl)](https://pepy.tech/projects/cycl)
5
+ [![Build Status](https://github.com/tcm5343/cycl/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/tcm5343/cycl/actions)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ cycl is a CLI and Python SDK to help identify cross-stack import/export circular dependencies, for a given AWS account and region. The successor to [circular-dependency-detector](https://github.com/tcm5343/circular-dependency-detector), which was built at the University of Texas at Austin.
9
+
10
+ ## Getting started
11
+
12
+ Install `cycl` by running `pip install cycl`.
13
+
14
+ ### CLI
15
+
16
+ - `cycl check --exit-zero` - exit 0 regardless of result
17
+ - `cycl check --log-level` - set the logging level (default: WARNING)
18
+ - `cycl check --cdk-out /path/to/cdk.out` - path to cdk.out, where stacks are CDK synthesized to CFN templates
19
+
20
+ ## How to use cycl?
21
+
22
+ There are two main use cases for `cycl`.
23
+
24
+ 1. In a pipeline. `cycl` is best used to detect circular dependencies before a deployment. If you're using the AWS CDK v2 (v1 support coming soon), simply synthesize you templates to a directory and pass that directory to `cycl` using `--cdk-out-path some-path-here `. This allows `cycl` to find all existing cycles and then those to be introduced by the deployment. This prevents the circular dependency from ever being introduced. If your pipeline deploys more than once, you should execute `cycl` before each deployment.
25
+ 2. To perform analysis. While a CLI is best used in a pipeline, if you require analysis which is not currently supported, you can use the SDK. The SDK gives you all the information that `cycl` collects.
26
+
27
+ ## Why use cycl?
28
+
29
+ Over the lifetime of a project, circular references are bound to be introduced. They may not be noticed until you need to re-deploy some infrastructure. A good example is disaster recovery testing and potentially deploying all your infrastructure from scratch in a new region. This tool detects those changes.
30
+
31
+ ## Contributing
32
+
33
+ `cycl` is being actively developed, instructions will come as it becomes more stable.
cycl-0.2.0/TODO.md ADDED
@@ -0,0 +1,21 @@
1
+ # TODO.md
2
+
3
+ - ignoring known cycles, [this](https://cs.stackexchange.com/questions/90481/how-to-remove-cycles-from-a-directed-graph) may help
4
+ - `cycl check --ignore`
5
+ - `cycl topo --ignore`
6
+ - reducing the stacks, for example, a tag on a stack representing the github repo name
7
+ - `cycl check --reduce-on`
8
+ - `cycl check --reduce-on-jq`
9
+ - `cycl check --reduce-on-jmespath`
10
+ - `cycl topo --reduce-on {rootstack}` # can we resolve the root stack through cdk.out
11
+
12
+ - [ ] [fully configure dependabot](https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions)
13
+ - [ ] configure make file
14
+ - [ ] dprint for other file formatting
15
+ - [ ] automatic release versioning for pypi, run unit tests against package? Is this possible?
16
+ - [ ] configuration file using cli, use toml, custom rc file, env vars?
17
+ - [ ] CDK v1 support
18
+ - [ ] Test with stages that the correct manifest is analyzed
19
+ - [ ] What if cdk out synth is for multiple accounts? We may need to determine what account we have credentials for and only analyze those templates
20
+ - [ ] automatic documentation generation
21
+ - [ ] configure tox
@@ -0,0 +1,86 @@
1
+ [build-system]
2
+ requires = ['setuptools>=64', 'setuptools-scm>=8']
3
+ build-backend = 'setuptools.build_meta'
4
+
5
+ [project]
6
+ name = 'cycl'
7
+ version='0.2.0'
8
+ requires-python = '>=3.8'
9
+ description = 'CLI and Python SDK to help identify cross-stack import/export circular dependencies, for a given AWS account and region.'
10
+ readme = 'README.md'
11
+ keywords = ['aws', 'cdk', 'cycle', 'circular', 'dependency', 'infrastructure', 'boto3', 'cloud']
12
+ classifiers = [
13
+ 'Intended Audience :: Developers',
14
+ 'License :: OSI Approved :: MIT License',
15
+ 'Natural Language :: English',
16
+ 'Programming Language :: Python :: 3.10',
17
+ 'Programming Language :: Python :: 3.11',
18
+ 'Programming Language :: Python :: 3.12',
19
+ 'Programming Language :: Python :: 3.13',
20
+ 'Programming Language :: Python :: 3.8',
21
+ 'Programming Language :: Python :: 3.9',
22
+ 'Programming Language :: Python :: 3',
23
+ 'Programming Language :: Python',
24
+ 'Topic :: Software Development',
25
+ ]
26
+ dependencies = [
27
+ 'boto3~=1.0',
28
+ 'networkx~=3.0',
29
+ ]
30
+
31
+ [project.urls]
32
+ Repository = 'http://github.com/tcm5343/cycl'
33
+
34
+ [project.scripts]
35
+ cycl = 'cycl.cli:app'
36
+
37
+ [tool.ruff]
38
+ line-length = 125
39
+
40
+ [tool.ruff.lint]
41
+ select = ['ALL']
42
+ ignore = [
43
+ 'COM', # flake8-commas
44
+ 'D', # pydocstyle
45
+ 'ERA001', # commented-out-code
46
+ 'FIX002', # line-contains-todo
47
+ 'Q000', # bad-quotes-inline-string
48
+ 'Q003', # avoidable-escaped-quote
49
+ 'T201', # print
50
+ 'TD', # flake8-todos
51
+ ]
52
+
53
+ [tool.ruff.lint.per-file-ignores]
54
+ 'tests/**' = [
55
+ 'ANN', # flake8-annotations
56
+ 'PLR2004', # magic-value-comparison
57
+ 'S101', # assert
58
+ ]
59
+ '__init__.py' = [
60
+ 'F401', # unused-import
61
+ ]
62
+
63
+ [tool.ruff.format]
64
+ quote-style = 'single'
65
+ indent-style = 'space'
66
+ docstring-code-format = true
67
+
68
+ [tool.coverage.run]
69
+ branch = true
70
+ source = ['./src']
71
+
72
+ [tool.coverage.report]
73
+ fail_under = 90
74
+ show_missing = true
75
+ skip_covered = true
76
+ skip_empty = true
77
+ exclude_lines = [
78
+ "if TYPE_CHECKING:",
79
+ ]
80
+ omit = [
81
+ '__*__.py',
82
+ ]
83
+
84
+ [tool.pytest.ini_options]
85
+ log_cli_level = 'INFO'
86
+ addopts = ['--import-mode=importlib']
@@ -0,0 +1,2 @@
1
+ build==1.2.2.post1
2
+ twine==6.1.0
@@ -0,0 +1,8 @@
1
+ boto3-stubs[essential]==1.36.21
2
+ mypy==1.15.0
3
+ pytest-cov==6.0.0
4
+ pytest-subtests==0.14.1
5
+ pytest-sugar==1.0.0
6
+ pytest==8.3.4
7
+ ruff==0.9.4
8
+ types-networkx==3.4.2.20241227
@@ -0,0 +1,2 @@
1
+ boto3==1.36.14
2
+ networkx==3.4.2
@@ -0,0 +1,6 @@
1
+ # import importlib.metadata
2
+
3
+ from .cycl import build_dependency_graph
4
+
5
+ # todo: how to resolve?
6
+ # __version__ = importlib.metadata.version(__package__ or __name__)
@@ -0,0 +1,4 @@
1
+ if __name__ == '__main__':
2
+ from cycl.cli import app
3
+
4
+ app()
@@ -0,0 +1,72 @@
1
+ import argparse
2
+ import json
3
+ import logging
4
+ import pathlib
5
+ import sys
6
+ from logging import getLogger
7
+
8
+ import networkx as nx
9
+
10
+ from cycl import build_dependency_graph
11
+ from cycl.utils.log_config import configure_log
12
+
13
+ log = getLogger(__name__)
14
+
15
+
16
+ def app() -> None:
17
+ parser = argparse.ArgumentParser(prog='cycl', description='Check for cross-stack import/export circular dependencies.')
18
+ sp = parser.add_subparsers(dest='cmd', required=True)
19
+
20
+ check_p = sp.add_parser('check', help='Check for cycles between stacks in AWS stack imports/exports')
21
+ check_p.add_argument('--exit-zero', action='store_true', help='Exit 0 regardless of result of cycle check')
22
+
23
+ topo_p = sp.add_parser('topo', help='Find topological generations if dependencies are acyclic')
24
+
25
+ # global options
26
+ for p in [check_p, topo_p]:
27
+ p.add_argument(
28
+ '--log-level',
29
+ choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],
30
+ default='WARNING',
31
+ help='Set the logging level (default: WARNING)',
32
+ )
33
+ p.add_argument(
34
+ '--cdk-out',
35
+ type=pathlib.Path,
36
+ help='Path to cdk.out, where stacks are CDK synthesized to CFN templates',
37
+ )
38
+ p.add_argument(
39
+ '-in',
40
+ '--ignore-nodes',
41
+ nargs='+',
42
+ default=[],
43
+ type=str,
44
+ help='List of nodes to ignore when building the graph (ex. --ignore-nodes s1 s2 ...)',
45
+ )
46
+
47
+ if len(sys.argv) == 1:
48
+ parser.print_help()
49
+ sys.exit(0)
50
+
51
+ args = parser.parse_args()
52
+ configure_log(getattr(logging, args.log_level))
53
+
54
+ dep_graph = build_dependency_graph(cdk_out_path=args.cdk_out, nodes_to_ignore=args.ignore_nodes)
55
+ cycles = list(nx.simple_cycles(dep_graph))
56
+ for cycle in cycles:
57
+ print(f'cycle found between nodes: {cycle}')
58
+
59
+ if args.cmd == 'check':
60
+ if cycles and not args.exit_zero:
61
+ sys.exit(1)
62
+ elif args.cmd == 'topo':
63
+ if cycles:
64
+ log.error('graph is cyclic, topological generations can only be computed on an acyclic graph')
65
+ sys.exit(1)
66
+ generations = [sorted(generation) for generation in nx.topological_generations(dep_graph)]
67
+ print(json.dumps(generations, indent=2))
68
+ sys.exit(0)
69
+
70
+
71
+ if __name__ == '__main__':
72
+ app()