uv-workspace-codegen 0.6.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.
- uv_workspace_codegen-0.6.0/.github/workflow-templates/publish.template.yml +65 -0
- uv_workspace_codegen-0.6.0/.github/workflow-templates/test.template.yml +68 -0
- uv_workspace_codegen-0.6.0/.github/workflows/publish-uv-workspace-codegen.yml +69 -0
- uv_workspace_codegen-0.6.0/.github/workflows/test-uv-workspace-codegen.yml +55 -0
- uv_workspace_codegen-0.6.0/.gitignore +5 -0
- uv_workspace_codegen-0.6.0/.vscode/settings.json +14 -0
- uv_workspace_codegen-0.6.0/CHANGELOG.md +200 -0
- uv_workspace_codegen-0.6.0/PKG-INFO +9 -0
- uv_workspace_codegen-0.6.0/README.md +125 -0
- uv_workspace_codegen-0.6.0/pyproject.toml +40 -0
- uv_workspace_codegen-0.6.0/src/uv_workspace_codegen/__init__.py +8 -0
- uv_workspace_codegen-0.6.0/src/uv_workspace_codegen/__main__.py +11 -0
- uv_workspace_codegen-0.6.0/src/uv_workspace_codegen/main.py +454 -0
- uv_workspace_codegen-0.6.0/src/uv_workspace_codegen/py.typed +0 -0
- uv_workspace_codegen-0.6.0/src/uv_workspace_codegen/templates/package.template.yml +24 -0
- uv_workspace_codegen-0.6.0/tests/__init__.py +1 -0
- uv_workspace_codegen-0.6.0/tests/test_cleanup_manual.py +45 -0
- uv_workspace_codegen-0.6.0/tests/test_diff_mode.py +230 -0
- uv_workspace_codegen-0.6.0/tests/test_main.py +395 -0
- uv_workspace_codegen-0.6.0/tests/test_target_dir.py +110 -0
- uv_workspace_codegen-0.6.0/uv.lock +339 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
name: Publish {{ package.name }}
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v6
|
|
13
|
+
|
|
14
|
+
- name: Install uv
|
|
15
|
+
uses: astral-sh/setup-uv@v7
|
|
16
|
+
|
|
17
|
+
- name: Build wheel
|
|
18
|
+
run: uv build
|
|
19
|
+
working-directory: {{ package.path }}
|
|
20
|
+
|
|
21
|
+
- name: Store the distribution packages
|
|
22
|
+
uses: actions/upload-artifact@v6
|
|
23
|
+
with:
|
|
24
|
+
name: python-package-distributions
|
|
25
|
+
path: {{ package.path }}/dist/
|
|
26
|
+
|
|
27
|
+
publish-to-test-pypi:
|
|
28
|
+
environment:
|
|
29
|
+
name: testpypi
|
|
30
|
+
url: https://test.pypi.org/project/{{ package.name }}/
|
|
31
|
+
permissions:
|
|
32
|
+
id-token: write
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
needs: build
|
|
35
|
+
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/download-artifact@v7
|
|
38
|
+
with:
|
|
39
|
+
name: python-package-distributions
|
|
40
|
+
path: dist/
|
|
41
|
+
|
|
42
|
+
- name: Publish distribution to TestPyPI
|
|
43
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
44
|
+
with:
|
|
45
|
+
repository-url: https://test.pypi.org/legacy/
|
|
46
|
+
|
|
47
|
+
publish-to-pypi:
|
|
48
|
+
environment:
|
|
49
|
+
name: pypi
|
|
50
|
+
url: https://pypi.org/project/{{ package.name }}/
|
|
51
|
+
permissions:
|
|
52
|
+
id-token: write
|
|
53
|
+
runs-on: ubuntu-latest
|
|
54
|
+
needs:
|
|
55
|
+
- build
|
|
56
|
+
- publish-to-test-pypi
|
|
57
|
+
|
|
58
|
+
steps:
|
|
59
|
+
- uses: actions/download-artifact@v7
|
|
60
|
+
with:
|
|
61
|
+
name: python-package-distributions
|
|
62
|
+
path: dist/
|
|
63
|
+
|
|
64
|
+
- name: Publish distribution to PyPI
|
|
65
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
name: Test tool {{ package.name }}
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
paths:
|
|
6
|
+
- "{% if package.path != "." %}{{ package.path }}/{% endif %}**"
|
|
7
|
+
- "pyproject.toml"
|
|
8
|
+
- "uv.lock"
|
|
9
|
+
push:
|
|
10
|
+
branches: [master]
|
|
11
|
+
paths:
|
|
12
|
+
- "{% if package.path != "." %}{{ package.path }}/{% endif %}**"
|
|
13
|
+
- "pyproject.toml"
|
|
14
|
+
- "uv.lock"
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
test:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
with:
|
|
22
|
+
lfs: true
|
|
23
|
+
|
|
24
|
+
- name: Set up Python 3.14
|
|
25
|
+
uses: actions/setup-python@v5
|
|
26
|
+
with:
|
|
27
|
+
python-version: "3.14"
|
|
28
|
+
|
|
29
|
+
- name: Install the latest version of uv
|
|
30
|
+
uses: astral-sh/setup-uv@v6
|
|
31
|
+
|
|
32
|
+
- name: Install
|
|
33
|
+
shell: bash
|
|
34
|
+
run: |
|
|
35
|
+
cd {{ package.path }}
|
|
36
|
+
uv sync
|
|
37
|
+
{%- if package.custom_steps %}
|
|
38
|
+
{%- for step in package.custom_steps %}
|
|
39
|
+
|
|
40
|
+
- {{ step | to_nice_yaml | indent(8) }}
|
|
41
|
+
{%- endfor %}
|
|
42
|
+
{%- endif %}
|
|
43
|
+
{%- if package.generate_standard_pytest_step %}
|
|
44
|
+
|
|
45
|
+
- name: Run tests
|
|
46
|
+
shell: bash
|
|
47
|
+
run: |
|
|
48
|
+
uv run pytest {{ package.path }}/tests/
|
|
49
|
+
{%- endif %}
|
|
50
|
+
|
|
51
|
+
- name: Check formatting
|
|
52
|
+
shell: bash
|
|
53
|
+
run: |
|
|
54
|
+
uv run ruff check {{ package.path }}
|
|
55
|
+
{%- if package.generate_typechecking_step and package.typechecker == "mypy" %}
|
|
56
|
+
|
|
57
|
+
- name: Check typing
|
|
58
|
+
shell: bash
|
|
59
|
+
run: |
|
|
60
|
+
uv run mypy -p {{ package.package_name }}
|
|
61
|
+
{%- endif %}
|
|
62
|
+
{%- if package.generate_typechecking_step and package.typechecker == "ty" %}
|
|
63
|
+
|
|
64
|
+
- name: Check typing
|
|
65
|
+
shell: bash
|
|
66
|
+
run: |
|
|
67
|
+
uv run ty check {{ package.path }}
|
|
68
|
+
{%- endif %}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# This file was automatically generated by uv-workspace-codegen
|
|
2
|
+
# For more information, see: https://github.com/epoch8/uv-workspace-codegen/blob/master/README.md
|
|
3
|
+
# Do not edit this file manually - changes will be overwritten
|
|
4
|
+
|
|
5
|
+
name: Publish uv-workspace-codegen
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
tags:
|
|
10
|
+
- 'v*'
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v6
|
|
17
|
+
|
|
18
|
+
- name: Install uv
|
|
19
|
+
uses: astral-sh/setup-uv@v7
|
|
20
|
+
|
|
21
|
+
- name: Build wheel
|
|
22
|
+
run: uv build
|
|
23
|
+
working-directory: .
|
|
24
|
+
|
|
25
|
+
- name: Store the distribution packages
|
|
26
|
+
uses: actions/upload-artifact@v6
|
|
27
|
+
with:
|
|
28
|
+
name: python-package-distributions
|
|
29
|
+
path: ./dist/
|
|
30
|
+
|
|
31
|
+
publish-to-test-pypi:
|
|
32
|
+
environment:
|
|
33
|
+
name: testpypi
|
|
34
|
+
url: https://test.pypi.org/project/uv-workspace-codegen/
|
|
35
|
+
permissions:
|
|
36
|
+
id-token: write
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
needs: build
|
|
39
|
+
|
|
40
|
+
steps:
|
|
41
|
+
- uses: actions/download-artifact@v7
|
|
42
|
+
with:
|
|
43
|
+
name: python-package-distributions
|
|
44
|
+
path: dist/
|
|
45
|
+
|
|
46
|
+
- name: Publish distribution to TestPyPI
|
|
47
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
48
|
+
with:
|
|
49
|
+
repository-url: https://test.pypi.org/legacy/
|
|
50
|
+
|
|
51
|
+
publish-to-pypi:
|
|
52
|
+
environment:
|
|
53
|
+
name: pypi
|
|
54
|
+
url: https://pypi.org/project/uv-workspace-codegen/
|
|
55
|
+
permissions:
|
|
56
|
+
id-token: write
|
|
57
|
+
runs-on: ubuntu-latest
|
|
58
|
+
needs:
|
|
59
|
+
- build
|
|
60
|
+
- publish-to-test-pypi
|
|
61
|
+
|
|
62
|
+
steps:
|
|
63
|
+
- uses: actions/download-artifact@v7
|
|
64
|
+
with:
|
|
65
|
+
name: python-package-distributions
|
|
66
|
+
path: dist/
|
|
67
|
+
|
|
68
|
+
- name: Publish distribution to PyPI
|
|
69
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# This file was automatically generated by uv-workspace-codegen
|
|
2
|
+
# For more information, see: https://github.com/epoch8/uv-workspace-codegen/blob/master/README.md
|
|
3
|
+
# Do not edit this file manually - changes will be overwritten
|
|
4
|
+
|
|
5
|
+
name: Test tool uv-workspace-codegen
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
pull_request:
|
|
9
|
+
paths:
|
|
10
|
+
- "**"
|
|
11
|
+
- "pyproject.toml"
|
|
12
|
+
- "uv.lock"
|
|
13
|
+
push:
|
|
14
|
+
branches: [master]
|
|
15
|
+
paths:
|
|
16
|
+
- "**"
|
|
17
|
+
- "pyproject.toml"
|
|
18
|
+
- "uv.lock"
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
test:
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v4
|
|
25
|
+
with:
|
|
26
|
+
lfs: true
|
|
27
|
+
|
|
28
|
+
- name: Set up Python 3.14
|
|
29
|
+
uses: actions/setup-python@v5
|
|
30
|
+
with:
|
|
31
|
+
python-version: "3.14"
|
|
32
|
+
|
|
33
|
+
- name: Install the latest version of uv
|
|
34
|
+
uses: astral-sh/setup-uv@v6
|
|
35
|
+
|
|
36
|
+
- name: Install
|
|
37
|
+
shell: bash
|
|
38
|
+
run: |
|
|
39
|
+
cd .
|
|
40
|
+
uv sync
|
|
41
|
+
|
|
42
|
+
- name: Run tests
|
|
43
|
+
shell: bash
|
|
44
|
+
run: |
|
|
45
|
+
uv run pytest ./tests/
|
|
46
|
+
|
|
47
|
+
- name: Check formatting
|
|
48
|
+
shell: bash
|
|
49
|
+
run: |
|
|
50
|
+
uv run ruff check .
|
|
51
|
+
|
|
52
|
+
- name: Check typing
|
|
53
|
+
shell: bash
|
|
54
|
+
run: |
|
|
55
|
+
uv run mypy -p uv_workspace_codegen
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"[python]": {
|
|
3
|
+
"editor.formatOnSave": true,
|
|
4
|
+
"editor.codeActionsOnSave": {
|
|
5
|
+
"source.organizeImports": "explicit"
|
|
6
|
+
},
|
|
7
|
+
"editor.defaultFormatter": "charliermarsh.ruff"
|
|
8
|
+
},
|
|
9
|
+
"python.testing.pytestArgs": [
|
|
10
|
+
"tests"
|
|
11
|
+
],
|
|
12
|
+
"python.testing.unittestEnabled": false,
|
|
13
|
+
"python.testing.pytestEnabled": true
|
|
14
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the uv-workspace-codegen package will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.6.0] - 2026-01-23
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Multiple template types per package**: `template_type` configuration now accepts a list of template types, allowing a single package to generate multiple workflow files from different templates
|
|
12
|
+
- Support for list values in workspace-level `default_template_type` configuration
|
|
13
|
+
|
|
14
|
+
### Configuration Example
|
|
15
|
+
Packages can now specify multiple template types:
|
|
16
|
+
|
|
17
|
+
**Single template (still supported):**
|
|
18
|
+
```toml
|
|
19
|
+
[tool.uv-workspace-codegen]
|
|
20
|
+
generate = true
|
|
21
|
+
template_type = "lib"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Multiple templates (new):**
|
|
25
|
+
```toml
|
|
26
|
+
[tool.uv-workspace-codegen]
|
|
27
|
+
generate = true
|
|
28
|
+
template_type = ["lib", "deploy"]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
This generates both `lib-{package}.yml` and `deploy-{package}.yml` workflow files.
|
|
32
|
+
|
|
33
|
+
### Notes
|
|
34
|
+
- Backward compatible: single string values for `template_type` continue to work as before
|
|
35
|
+
- Templates receive the current template type as a string in `package.template_type`, not the full list
|
|
36
|
+
|
|
37
|
+
## [0.5.0] - 2025-11-20
|
|
38
|
+
|
|
39
|
+
### Added
|
|
40
|
+
- Automatic cleanup of stale workflow files that are no longer generated
|
|
41
|
+
- Diff Mode: Preview changes without writing files using `--diff` flag
|
|
42
|
+
- Added ability to provide target workspace directory as a command line parameter.
|
|
43
|
+
|
|
44
|
+
## [0.4.0] - 2025-11-09
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
- Workspace-level template directory configuration (`template_dir`) and default template type (`default_template_type`)
|
|
48
|
+
- Recursive discovery of packages across the entire workspace (not limited to specific folders)
|
|
49
|
+
- Ability to load workflow templates from the target workspace's template directory (`.github/workflow-templates` or custom)
|
|
50
|
+
- "default" template type support and workspace-level default template type fallback
|
|
51
|
+
- Tests and documentation for configurable templates and default template behavior
|
|
52
|
+
|
|
53
|
+
### Changed
|
|
54
|
+
- Discovery and template-loading code refactored: `discover_packages` now scans the workspace recursively and accepts workspace config
|
|
55
|
+
- `load_template` updated to read templates from the workspace (configurable path)
|
|
56
|
+
- README updated to document generic template types, workspace config, and default behavior
|
|
57
|
+
|
|
58
|
+
### Notes
|
|
59
|
+
- Backward compatible: packages that explicitly set `template_type` are unaffected. If `template_type` is omitted, the workspace `default_template_type` (or `default`) is used.
|
|
60
|
+
|
|
61
|
+
## [0.3.0] - 2025-09-05
|
|
62
|
+
|
|
63
|
+
### Added
|
|
64
|
+
- **Multi-template system**: Support for different template types (`lib`, `project`, `tool`)
|
|
65
|
+
- **Template-specific discovery**: Automatic scanning of appropriate directories based on template type
|
|
66
|
+
- **Template caching**: Efficient template loading with caching for multiple packages of the same type
|
|
67
|
+
- **New template files**:
|
|
68
|
+
- `lib.template.yml` - For libraries in `libs/` directory
|
|
69
|
+
- `project.template.yml` - For projects in `projects/` directory or workspace root
|
|
70
|
+
- `tool.template.yml` - For tools in `tools/` directory
|
|
71
|
+
- **Enhanced workflow naming**: Files now use `{template_type}-{name}.yml` pattern
|
|
72
|
+
|
|
73
|
+
### Changed
|
|
74
|
+
- **BREAKING**: Renamed internal class from `Library` to `Package` for better terminology
|
|
75
|
+
- **BREAKING**: Template variable changed from `{{ library.* }}` to `{{ package.* }}`
|
|
76
|
+
- **BREAKING**: Function renamed from `discover_libraries()` to `discover_packages()`
|
|
77
|
+
- **BREAKING**: Removed old `library_cicd.template.yml` in favor of new template structure
|
|
78
|
+
- Enhanced discovery logic to support multiple directory types
|
|
79
|
+
- Improved variable naming throughout codebase for consistency
|
|
80
|
+
|
|
81
|
+
### Technical Details
|
|
82
|
+
- **Template Type Configuration**: New required field `template_type` in `[tool.uv-workspace-codegen]`
|
|
83
|
+
- **Multi-directory Discovery**:
|
|
84
|
+
- `lib` template: Scans `libs/` subdirectories
|
|
85
|
+
- `project` template: Scans `projects/` subdirectories and workspace root
|
|
86
|
+
- `tool` template: Scans `tools/` subdirectories
|
|
87
|
+
- **Template Loading**: Dynamic template selection based on `template_type` configuration
|
|
88
|
+
- **Workflow Naming**: Updated from `test-{name}.yml` to `{template_type}-{name}.yml`
|
|
89
|
+
|
|
90
|
+
### Configuration Migration
|
|
91
|
+
Existing configurations need to add `template_type` field:
|
|
92
|
+
|
|
93
|
+
**Before:**
|
|
94
|
+
```toml
|
|
95
|
+
[tool.uv-workspace-codegen]
|
|
96
|
+
generate = true
|
|
97
|
+
generate_standard_pytest_step = true
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**After:**
|
|
101
|
+
```toml
|
|
102
|
+
[tool.uv-workspace-codegen]
|
|
103
|
+
generate = true
|
|
104
|
+
template_type = "lib" # or "project" or "tool"
|
|
105
|
+
generate_standard_pytest_step = true
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Template Structure
|
|
109
|
+
```
|
|
110
|
+
tools/uv-workspace-codegen/
|
|
111
|
+
├── templates/
|
|
112
|
+
│ ├── lib.template.yml # For libraries
|
|
113
|
+
│ ├── project.template.yml # For projects
|
|
114
|
+
│ └── tool.template.yml # For tools
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## [0.2.0] - 2025-09-05
|
|
118
|
+
|
|
119
|
+
### Added
|
|
120
|
+
- **Autogenerated file headers**: All generated workflow files now include a comment header indicating they are autogenerated
|
|
121
|
+
- **Documentation link**: Generated files include a reference to the uv-workspace-codegen README for more information
|
|
122
|
+
- **Module execution support**: Package can now be executed with `python -m uv_workspace_codegen`
|
|
123
|
+
- **Edit warning**: Generated files warn users not to edit manually as changes will be overwritten
|
|
124
|
+
|
|
125
|
+
### Changed
|
|
126
|
+
- Enhanced `generate_workflow()` function to prepend autogenerated comments to all generated files
|
|
127
|
+
- Improved user experience with clear documentation links in generated files
|
|
128
|
+
|
|
129
|
+
### Technical Details
|
|
130
|
+
- Added `__main__.py` module entry point for Python module execution
|
|
131
|
+
- Autogenerated comment block includes:
|
|
132
|
+
- Clear indication of automatic generation by uv-workspace-codegen
|
|
133
|
+
- Direct link to documentation at `tools/uv-workspace-codegen/README.md`
|
|
134
|
+
- Warning against manual editing
|
|
135
|
+
- Maintains backward compatibility with existing `uv-workspace-codegen` command
|
|
136
|
+
- Both execution methods (`uv-workspace-codegen` and `python -m uv_workspace_codegen`) produce identical results
|
|
137
|
+
|
|
138
|
+
### Execution Methods
|
|
139
|
+
The tool now supports multiple execution patterns:
|
|
140
|
+
```bash
|
|
141
|
+
# Original method (still supported)
|
|
142
|
+
uv-workspace-codegen
|
|
143
|
+
|
|
144
|
+
# New module execution method
|
|
145
|
+
python -m uv_workspace_codegen
|
|
146
|
+
|
|
147
|
+
# With uv
|
|
148
|
+
uv run uv-workspace-codegen
|
|
149
|
+
uv run python -m uv_workspace_codegen
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## [0.1.0] - 2025-09-05
|
|
153
|
+
|
|
154
|
+
### Added
|
|
155
|
+
- Initial release of uv-workspace-codegen as a proper uv package
|
|
156
|
+
- Command-line interface accessible via `uv-workspace-codegen` command
|
|
157
|
+
- Automatic discovery of libraries with CI/CD configuration in their `pyproject.toml`
|
|
158
|
+
- Support for generating GitHub Actions workflows based on Jinja2 templates
|
|
159
|
+
- Configuration options for libraries:
|
|
160
|
+
- `generate`: Enable/disable workflow generation
|
|
161
|
+
- `generate_standard_pytest_step`: Include standard pytest testing steps
|
|
162
|
+
- `typechecker`: Choose between "mypy" and "ty" type checkers
|
|
163
|
+
- `custom_steps`: Add custom YAML steps to workflows
|
|
164
|
+
- Automatic workspace root detection
|
|
165
|
+
- Template bundled within the package for reliable discovery
|
|
166
|
+
- Comprehensive test suite with unit tests
|
|
167
|
+
- Documentation with usage examples and configuration guide
|
|
168
|
+
|
|
169
|
+
### Changed
|
|
170
|
+
- **BREAKING**: Converted from standalone script `tools/generate_cicd.py` to proper package
|
|
171
|
+
- **BREAKING**: Command changed from `uv run python tools/generate_cicd.py` to `uv-workspace-codegen`
|
|
172
|
+
- Simplified template discovery logic - template now bundled with package
|
|
173
|
+
- Enhanced workspace root detection algorithm
|
|
174
|
+
- Improved error handling and user feedback
|
|
175
|
+
|
|
176
|
+
### Removed
|
|
177
|
+
- Removed standalone `tools/generate_cicd.py` script
|
|
178
|
+
- Removed dependency on workspace structure for template location
|
|
179
|
+
|
|
180
|
+
### Technical Details
|
|
181
|
+
- Package structure follows Python standards with `src/` layout
|
|
182
|
+
- Entry point configured in `pyproject.toml` for direct command execution
|
|
183
|
+
- Integrated into workspace as a proper uv package member
|
|
184
|
+
- Template file moved from `tools/library_cicd.template.yml` to package directory
|
|
185
|
+
- Added comprehensive documentation and examples
|
|
186
|
+
|
|
187
|
+
### Migration Guide
|
|
188
|
+
For users upgrading from the old script:
|
|
189
|
+
|
|
190
|
+
**Before:**
|
|
191
|
+
```bash
|
|
192
|
+
uv run python tools/generate_cicd.py
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**After:**
|
|
196
|
+
```bash
|
|
197
|
+
uv-workspace-codegen
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
The configuration in library `pyproject.toml` files remains the same.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: uv-workspace-codegen
|
|
3
|
+
Version: 0.6.0
|
|
4
|
+
Summary: Generate individual CI/CD workflows for packages in the workspace
|
|
5
|
+
Requires-Python: >=3.12
|
|
6
|
+
Requires-Dist: click>=8.1.7
|
|
7
|
+
Requires-Dist: jinja2-ansible-filters>=1.3.2
|
|
8
|
+
Requires-Dist: jinja2>=3.1.6
|
|
9
|
+
Requires-Dist: pyyaml>=6.0.1
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# uv-workspace-codegen
|
|
2
|
+
|
|
3
|
+
A small tool that generates GitHub Actions workflows for packages in a
|
|
4
|
+
workspace.
|
|
5
|
+
|
|
6
|
+
The README below shows the minimal configuration and usage.
|
|
7
|
+
|
|
8
|
+
## Motivation
|
|
9
|
+
|
|
10
|
+
When you keep multiple Python packages together in a single `uv`-based monorepo,
|
|
11
|
+
it makes development and dependency management easier — but it also complicates
|
|
12
|
+
CI.
|
|
13
|
+
|
|
14
|
+
With several packages that depend on each other, maintaining per-package GitHub
|
|
15
|
+
Actions workflows becomes repetitive and error-prone. You often want CI to run
|
|
16
|
+
for a package when that package or any of its internal dependencies change, and
|
|
17
|
+
you want consistent, up-to-date pipelines across the repo.
|
|
18
|
+
|
|
19
|
+
This tool solves that by discovering packages in the workspace, understanding
|
|
20
|
+
their relationships, and generating (or updating) per-package GitHub Actions
|
|
21
|
+
workflows from Jinja2 templates. That lets you keep templates and policy
|
|
22
|
+
centralized while producing tailored workflows for each package automatically.
|
|
23
|
+
|
|
24
|
+
## Quick start
|
|
25
|
+
|
|
26
|
+
Install (when using `uv`-based workspaces):
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
uv tool install https://github.com/epoch8/uv-workspace-codegen.git
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Mark any package to generate it's ci/cd template. Add this section to it's
|
|
33
|
+
`pyproject.toml` file:
|
|
34
|
+
|
|
35
|
+
```toml
|
|
36
|
+
[tool.uv-workspace-codegen]
|
|
37
|
+
generate = true
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Run from the root directory of the workspace:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
uv-workspace-codegen
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Generated workflow files appear in `.github/workflows/`.
|
|
47
|
+
|
|
48
|
+
## Configuration (minimal)
|
|
49
|
+
|
|
50
|
+
Workspace-level options (root `pyproject.toml`):
|
|
51
|
+
|
|
52
|
+
```toml
|
|
53
|
+
[tool.uv-workspace-codegen]
|
|
54
|
+
template_dir = ".github/workflow-templates" # optional, default
|
|
55
|
+
default_template_type = "package" # optional, default
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Package-level options (in each package `pyproject.toml`):
|
|
59
|
+
|
|
60
|
+
```toml
|
|
61
|
+
[tool.uv-workspace-codegen]
|
|
62
|
+
generate = true # enable generation for this package
|
|
63
|
+
template_type = "my-service" # optional; selects my-service.template.yml
|
|
64
|
+
generate_standard_pytest_step = true
|
|
65
|
+
typechecker = "mypy"
|
|
66
|
+
custom_steps = """ # optional YAML list of steps
|
|
67
|
+
- name: extra step
|
|
68
|
+
run: echo hello
|
|
69
|
+
"""
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Multiple template types can be specified to generate multiple workflow files:
|
|
73
|
+
|
|
74
|
+
```toml
|
|
75
|
+
[tool.uv-workspace-codegen]
|
|
76
|
+
generate = true
|
|
77
|
+
template_type = ["lib", "deploy"] # generates lib-{name}.yml and deploy-{name}.yml
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Notes:
|
|
81
|
+
|
|
82
|
+
- `template_type` maps directly to a template filename: `X` → `X.template.yml`
|
|
83
|
+
in the template directory
|
|
84
|
+
- `template_type` can be a string or a list of strings for multiple workflows
|
|
85
|
+
- If `template_type` is omitted the workspace `default_template_type` is used
|
|
86
|
+
|
|
87
|
+
Note: If no templates directory or `package.template.yml` exists, the tool will
|
|
88
|
+
automatically create `.github/workflow-templates/` and a minimal
|
|
89
|
+
`package.template.yml` to help you quick-start.
|
|
90
|
+
|
|
91
|
+
## Templates
|
|
92
|
+
|
|
93
|
+
Templates are Jinja2 files that receive a `package` object with fields such as
|
|
94
|
+
`name`, `path`, `package_name`, `template_type`, and configuration flags. Place
|
|
95
|
+
templates in the directory configured by `template_dir`. Create a file named
|
|
96
|
+
`<type>.template.yml` to support `template_type = "<type>"`.
|
|
97
|
+
|
|
98
|
+
Template capabilities (examples):
|
|
99
|
+
|
|
100
|
+
- inject package metadata
|
|
101
|
+
- include custom steps from `custom_steps`
|
|
102
|
+
- conditionally include test/typecheck steps based on flags
|
|
103
|
+
|
|
104
|
+
## Regenerate workflows
|
|
105
|
+
|
|
106
|
+
Run the tool any time you change package or workspace configuration:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
uv run uv-workspace-codegen
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Tests
|
|
113
|
+
|
|
114
|
+
Run the unit tests locally with `pytest` (project uses `pyproject.toml` for test
|
|
115
|
+
deps):
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
uv run python -m pytest tests/
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
This README focuses on the essentials: discovery, configuration, templates,
|
|
124
|
+
usage. For examples and template samples check the `.github/workflow-templates/`
|
|
125
|
+
folder in this repository.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "uv-workspace-codegen"
|
|
3
|
+
version = "0.6.0"
|
|
4
|
+
description = "Generate individual CI/CD workflows for packages in the workspace"
|
|
5
|
+
requires-python = ">=3.12"
|
|
6
|
+
dependencies = [
|
|
7
|
+
"jinja2>=3.1.6",
|
|
8
|
+
"jinja2-ansible-filters>=1.3.2",
|
|
9
|
+
"pyyaml>=6.0.1",
|
|
10
|
+
"click>=8.1.7",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
[project.scripts]
|
|
14
|
+
uv-workspace-codegen = "uv_workspace_codegen.main:main"
|
|
15
|
+
|
|
16
|
+
[build-system]
|
|
17
|
+
requires = ["hatchling"]
|
|
18
|
+
build-backend = "hatchling.build"
|
|
19
|
+
|
|
20
|
+
[tool.hatch.build.targets.wheel]
|
|
21
|
+
packages = ["src/uv_workspace_codegen"]
|
|
22
|
+
|
|
23
|
+
[tool.uv-workspace-codegen]
|
|
24
|
+
template_type = ["test", "publish"]
|
|
25
|
+
generate = true
|
|
26
|
+
generate_standard_pytest_step = true
|
|
27
|
+
typechecker = "mypy"
|
|
28
|
+
|
|
29
|
+
[tool.mypy]
|
|
30
|
+
ignore_missing_imports = true
|
|
31
|
+
follow_imports = "silent"
|
|
32
|
+
namespace_packages = true
|
|
33
|
+
|
|
34
|
+
[dependency-groups]
|
|
35
|
+
dev = [
|
|
36
|
+
"mypy>=1.17.1",
|
|
37
|
+
"pytest>=8.4.1",
|
|
38
|
+
"ruff>=0.12.9",
|
|
39
|
+
"types-pyyaml>=6.0.12.20250822",
|
|
40
|
+
]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Generate individual CI/CD workflows for each library in the workspace.
|
|
3
|
+
|
|
4
|
+
This package scans the libs/ directory and creates individual GitHub Actions
|
|
5
|
+
workflows for each library, allowing parallel testing and better CI/CD isolation.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = "0.1.0"
|