Skip to content

Commit c1966ec

Browse files
Merge pull request #8 from OpenSecFlow/housekeeping-6-fixes
Housekeeping 6 fixes
2 parents fbc2df3 + 5f6c86f commit c1966ec

File tree

258 files changed

+3144
-2077
lines changed

Some content is hidden

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

258 files changed

+3144
-2077
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ wheels/
2424
*.egg-info/
2525
.installed.cfg
2626
*.egg
27-
projects/*/dist/
27+
packages/*/dist/
2828

2929
# Virtual environments
3030
.venv

.github/Dockerfile.ci

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Dockerfile for CI/CD with Poetry and Python pre-installed
2-
FROM python:3.12-slim
1+
# Dockerfile for CI/CD with uv and Python pre-installed
2+
FROM ghcr.io/astral-sh/uv:python3.12-trixie
33

44
LABEL org.opencontainers.image.source="https://github.com/OpenSecFlow/netdriver"
5-
LABEL org.opencontainers.image.description="CI/CD image with Python 3.12 and Poetry"
5+
LABEL org.opencontainers.image.description="CI/CD image with Python 3.12 and uv"
66
LABEL org.opencontainers.image.licenses="Apache-2.0"
77

88
# Install system dependencies
@@ -11,22 +11,10 @@ RUN apt-get update && apt-get install -y \
1111
curl \
1212
&& rm -rf /var/lib/apt/lists/*
1313

14-
# Install Poetry
15-
ENV POETRY_VERSION=1.8.3
16-
ENV POETRY_HOME=/opt/poetry
17-
ENV POETRY_NO_INTERACTION=1
18-
ENV POETRY_VIRTUALENVS_IN_PROJECT=false
19-
ENV POETRY_VIRTUALENVS_CREATE=true
20-
21-
RUN curl -sSL https://install.python-poetry.org | python3 - \
22-
&& ln -s /opt/poetry/bin/poetry /usr/local/bin/poetry
23-
24-
# Install Poetry plugins
25-
RUN poetry self add poetry-multiproject-plugin \
26-
&& poetry self add poetry-polylith-plugin
27-
28-
# Verify installation
29-
RUN poetry --version && poetry self show plugins
14+
# Set uv environment variables
15+
ENV UV_PYTHON=python3.12
16+
ENV UV_COMPILE_BYTECODE=1
17+
ENV UV_LINK_MODE=copy
3018

3119
WORKDIR /workspace
3220

.github/workflows/QUICKSTART.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ The `publish-pypi.yml` workflow uses a pre-built Docker image for faster executi
5555
**Or build locally:**
5656

5757
```bash
58-
docker build -t ghcr.io/opensecflow/netdriver/python-poetry:3.12 -f .github/Dockerfile.ci .
59-
docker push ghcr.io/opensecflow/netdriver/python-poetry:3.12
58+
docker build -t ghcr.io/opensecflow/netdriver/python-uv:3.12 -f .github/Dockerfile.ci .
59+
docker push ghcr.io/opensecflow/netdriver/python-uv:3.12
6060
```
6161

6262
**Note**: This only needs to be done once. The image will be cached and reused.
@@ -103,11 +103,11 @@ Before publishing to production PyPI, test with TestPyPI:
103103

104104
```bash
105105
# 1. Update version numbers
106-
poetry version -P projects/agent 0.3.1
107-
poetry version -P projects/simunet 0.3.1
106+
sed -i 's/^version = ".*"/version = "0.3.1"/' packages/agent/pyproject.toml
107+
sed -i 's/^version = ".*"/version = "0.3.1"/' packages/simunet/pyproject.toml
108108

109109
# 2. Commit changes
110-
git add projects/*/pyproject.toml
110+
git add packages/*/pyproject.toml
111111
git commit -m "chore: bump version to 0.3.1"
112112
git push
113113

@@ -156,27 +156,28 @@ The `release.yml` workflow will automatically:
156156
**Solution:** Version already exists on PyPI. Bump the version:
157157

158158
```bash
159-
poetry version -P projects/agent patch
160-
poetry version -P projects/simunet patch
159+
# Manually update version in pyproject.toml files
160+
sed -i 's/^version = ".*"/version = "0.3.2"/' packages/agent/pyproject.toml
161+
sed -i 's/^version = ".*"/version = "0.3.2"/' packages/simunet/pyproject.toml
161162
# Then rebuild and publish
162163
```
163164

164-
### Workflow fails with "Poetry not found" or image pull error
165+
### Workflow fails with "uv not found" or image pull error
165166

166167
**Solution:** Build the CI Docker image first
167168

168169
```bash
169170
# Go to Actions → "Build CI Image" → Run workflow
170171
```
171172

172-
Or check the image name matches: `ghcr.io/opensecflow/netdriver/python-poetry:3.12`
173+
Or check the image name matches: `ghcr.io/opensecflow/netdriver/python-uv:3.12`
173174

174175
### Package shows as "0 B" or malformed
175176

176177
**Solution:** Check build output - Polylith path warnings are normal, verify wheel contents:
177178

178179
```bash
179-
unzip -l projects/agent/dist/netdriver_agent-*.whl
180+
unzip -l packages/agent/dist/netdriver_agent-*.whl
180181
```
181182

182183
## Best Practices
@@ -185,7 +186,7 @@ unzip -l projects/agent/dist/netdriver_agent-*.whl
185186

186187
**DO:**
187188

188-
- Keep version numbers in sync across `projects/agent/pyproject.toml` and `projects/simunet/pyproject.toml`
189+
- Keep version numbers in sync across `packages/agent/pyproject.toml` and `packages/simunet/pyproject.toml`
189190
- Use semantic versioning: `MAJOR.MINOR.PATCH`
190191
- Test on TestPyPI before production
191192

@@ -198,7 +199,7 @@ unzip -l projects/agent/dist/netdriver_agent-*.whl
198199
### Release Process
199200

200201
1. Develop features on branches
201-
2. Test locally: `poetry build-project -C projects/agent`
202+
2. Test locally: `uv build --directory packages/agent`
202203
3. Create PR and verify build test passes
203204
4. Merge to master
204205
5. Test on TestPyPI

.github/workflows/README.md

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ This directory contains GitHub Actions workflows for automated building, testing
3030

3131
**What it does**:
3232

33-
- Uses pre-built Docker container with Poetry installed
33+
- Uses pre-built Docker container with uv installed
3434
- Builds wheel packages for selected projects
3535
- Publishes to PyPI or TestPyPI
3636
- Uploads build artifacts
@@ -68,10 +68,10 @@ The project supports independent release workflows for agent and simunet:
6868

6969
```bash
7070
# Update agent version in pyproject.toml (optional, will be updated by workflow)
71-
poetry version 1.0.0 -C projects/agent
71+
sed -i 's/^version = ".*"/version = "1.0.0"/' packages/agent/pyproject.toml
7272

7373
# Commit version changes (optional)
74-
git add projects/agent/pyproject.toml
74+
git add packages/agent/pyproject.toml
7575
git commit -m "chore: bump agent version to 1.0.0"
7676

7777
# Create and push agent tag
@@ -98,10 +98,10 @@ git push origin agent-1.0.0
9898

9999
```bash
100100
# Update simunet version in pyproject.toml (optional, will be updated by workflow)
101-
poetry version 2.5.0 -C projects/simunet
101+
sed -i 's/^version = ".*"/version = "2.5.0"/' packages/simunet/pyproject.toml
102102

103103
# Commit version changes (optional)
104-
git add projects/simunet/pyproject.toml
104+
git add packages/simunet/pyproject.toml
105105
git commit -m "chore: bump simunet version to 2.5.0"
106106

107107
# Create and push simunet tag
@@ -165,13 +165,13 @@ Use this when you only need to release the agent:
165165
1. **Update version number** (optional):
166166

167167
```bash
168-
poetry version 1.0.0 -C projects/agent
168+
sed -i 's/^version = ".*"/version = "1.0.0"/' packages/agent/pyproject.toml
169169
```
170170

171171
2. **Commit changes** (optional):
172172

173173
```bash
174-
git add projects/agent/pyproject.toml
174+
git add packages/agent/pyproject.toml
175175
git commit -m "chore: bump agent version to 1.0.0"
176176
git push origin master
177177
```
@@ -197,13 +197,13 @@ Use this when you need to release simunet:
197197
1. **Update version number** (optional):
198198

199199
```bash
200-
poetry version 2.5.0 -C projects/simunet
200+
sed -i 's/^version = ".*"/version = "2.5.0"/' packages/simunet/pyproject.toml
201201
```
202202

203203
2. **Commit changes** (optional):
204204

205205
```bash
206-
git add projects/simunet/pyproject.toml
206+
git add packages/simunet/pyproject.toml
207207
git commit -m "chore: bump simunet version to 2.5.0"
208208
git push origin master
209209
```
@@ -235,8 +235,8 @@ To test publishing before official release:
235235
2. **Or use CLI**:
236236

237237
```bash
238-
poetry publish -P projects/agent -r testpypi
239-
poetry publish -P projects/simunet -r testpypi
238+
uv publish --directory packages/agent --publish-url https://test.pypi.org/legacy/ --token $TESTPYPI_TOKEN
239+
uv publish --directory packages/simunet --publish-url https://test.pypi.org/legacy/ --token $TESTPYPI_TOKEN
240240
```
241241

242242
3. **Verify on TestPyPI**:
@@ -382,12 +382,12 @@ The project uses prefixed tag patterns for independent releases:
382382

383383
### 5. Build CI Image (`build-ci-image.yml`)
384384

385-
**Purpose**: Creates a Docker image with Poetry and Python pre-installed for faster CI/CD
385+
**Purpose**: Creates a Docker image with uv and Python pre-installed for faster CI/CD
386386

387387
**What it includes**:
388388

389389
- Python 3.12
390-
- Poetry with multiproject and polylith plugins
390+
- uv package manager
391391
- Git and essential build tools
392392

393393
**Building the image**:
@@ -408,24 +408,24 @@ The `publish-pypi.yml` workflow uses this approach:
408408
jobs:
409409
publish:
410410
runs-on: ubuntu-latest
411-
container:
412-
image: ghcr.io/${{ github.repository }}/python-poetry:3.12
413411
steps:
414412
- uses: actions/checkout@v4
415-
# Poetry and plugins are already installed!
416-
- run: poetry build-project -C projects/agent
413+
- uses: astral-sh/setup-uv@v4
414+
- run: uv python install
415+
- run: uv sync
416+
- run: uv build --directory packages/agent
417417
```
418418
419419
**Benefits of using Docker image**:
420420
421-
- ⚡ **Faster**: No need to install Poetry and plugins on every run
421+
- ⚡ **Faster**: No need to install uv on every run
422422
- 🔒 **Consistent**: Same environment across all workflows
423423
- 💾 **Cacheable**: Image layers are cached by Docker
424424
- 🎯 **Reproducible**: Exact same versions every time
425425
426426
**Image locations**:
427427
428-
- GitHub Container Registry: `ghcr.io/opensecflow/netdriver/python-poetry:3.12`
428+
- GitHub Container Registry: `ghcr.io/opensecflow/netdriver/python-uv:3.12`
429429
- Available tags: `latest`, `master`, `<branch>-<sha>`
430430

431431
**Benefits**:
@@ -452,7 +452,7 @@ netdriver/
452452
│ ├── agent/ # REST API service
453453
│ └── simunet/ # Simulation network
454454
├── components/ # Shared components
455-
└── projects/
455+
└── packages/
456456
├── agent/
457457
│ └── pyproject.toml
458458
└── simunet/
@@ -485,20 +485,18 @@ container:
485485
password: ${{ secrets.DOCKER_PASSWORD }}
486486
```
487487

488-
### 3. Verify Poetry is available
488+
### 3. Verify uv is available
489489

490-
Poetry and plugins are pre-installed, so you can use them directly:
490+
uv is pre-installed, so you can use it directly:
491491

492492
```yaml
493-
- name: Verify Poetry installation
493+
- name: Verify uv installation
494494
run: |
495-
poetry --version
496-
poetry self show plugins
495+
uv --version
497496
```
498497

499498
## References
500499

501-
- [Poetry Documentation](https://python-poetry.org/docs/)
502-
- [Poetry Polylith Plugin](https://github.com/DavidVujic/poetry-polylith-plugin)
503-
- [PyPI Publishing Guide](https://packaging.python.org/tutorials/packaging-projects/)
500+
- [uv Documentation](https://docs.astral.sh/uv/)
501+
- [PyPI Publishing Guide](https://packaging.python.org/tutorials/packaging-packages/)
504502
- [GitHub Actions - Python](https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python)

.github/workflows/build-ci-image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
env:
1313
REGISTRY: ghcr.io
14-
IMAGE_NAME: opensecflow/netdriver/python-poetry
14+
IMAGE_NAME: opensecflow/netdriver/python-uv
1515

1616
jobs:
1717
build:

0 commit comments

Comments
 (0)