Skip to content

Commit 3098fbc

Browse files
authored
feat: Add comprehensive CI/CD pipeline with Python-only dependencies (#16)
1 parent efb323e commit 3098fbc

15 files changed

Lines changed: 1391 additions & 83 deletions

.github/workflows/pr-checks.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: PR Checks
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
lint:
15+
name: Lint & Static Analysis
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Python
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: "3.9"
25+
26+
- name: Install Poetry
27+
uses: abatilo/actions-poetry@v3
28+
with:
29+
poetry-version: latest
30+
31+
- name: Configure Poetry
32+
run: |
33+
poetry config virtualenvs.create true --local
34+
poetry config virtualenvs.in-project true --local
35+
36+
- name: Cache Poetry dependencies
37+
uses: actions/cache@v3
38+
with:
39+
path: .venv
40+
key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
41+
42+
- name: Install Task
43+
uses: arduino/setup-task@v1
44+
with:
45+
version: 3.x
46+
repo-token: ${{ secrets.GITHUB_TOKEN }}
47+
48+
- name: Install dependencies
49+
run: task install
50+
51+
- name: Run linting
52+
run: task lint
53+
54+
- name: Run static analysis
55+
run: task static-analysis
56+
57+
test:
58+
name: Test Suite
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Checkout code
62+
uses: actions/checkout@v4
63+
64+
- name: Setup Python
65+
uses: actions/setup-python@v4
66+
with:
67+
python-version: "3.9"
68+
69+
- name: Install Poetry
70+
uses: abatilo/actions-poetry@v3
71+
with:
72+
poetry-version: latest
73+
74+
- name: Configure Poetry
75+
run: |
76+
poetry config virtualenvs.create true --local
77+
poetry config virtualenvs.in-project true --local
78+
79+
- name: Cache Poetry dependencies
80+
uses: actions/cache@v3
81+
with:
82+
path: .venv
83+
key: poetry-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
84+
85+
- name: Install Task
86+
uses: arduino/setup-task@v1
87+
with:
88+
version: 3.x
89+
repo-token: ${{ secrets.GITHUB_TOKEN }}
90+
91+
- name: Install BATS
92+
run: |
93+
sudo apt-get update
94+
sudo apt-get install -y bats
95+
96+
- name: Install dependencies
97+
run: task install
98+
99+
- name: Run tests
100+
run: task test

.github/workflows/release.yml

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
10+
permissions:
11+
contents: write
12+
issues: write
13+
pull-requests: write
14+
15+
jobs:
16+
test:
17+
name: Test Before Release
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Python
24+
uses: actions/setup-python@v4
25+
with:
26+
python-version: "3.9"
27+
28+
- name: Install Poetry
29+
uses: abatilo/actions-poetry@v3
30+
with:
31+
poetry-version: latest
32+
33+
- name: Configure Poetry
34+
run: |
35+
poetry config virtualenvs.create true --local
36+
poetry config virtualenvs.in-project true --local
37+
38+
- name: Install Task
39+
uses: arduino/setup-task@v1
40+
with:
41+
version: 3.x
42+
repo-token: ${{ secrets.GITHUB_TOKEN }}
43+
44+
- name: Install BATS
45+
run: |
46+
sudo apt-get update
47+
sudo apt-get install -y bats
48+
49+
- name: Install dependencies and run checks
50+
run: task release:prepare
51+
52+
release:
53+
name: Semantic Release
54+
runs-on: ubuntu-latest
55+
needs: test
56+
if: github.ref == 'refs/heads/main'
57+
outputs:
58+
released: ${{ steps.release.outputs.released }}
59+
version: ${{ steps.release.outputs.version }}
60+
tag: ${{ steps.release.outputs.tag }}
61+
steps:
62+
- name: Checkout code
63+
uses: actions/checkout@v4
64+
with:
65+
fetch-depth: 0
66+
token: ${{ secrets.GITHUB_TOKEN }}
67+
68+
- name: Setup Python
69+
uses: actions/setup-python@v4
70+
with:
71+
python-version: "3.9"
72+
73+
- name: Install Poetry
74+
uses: abatilo/actions-poetry@v3
75+
with:
76+
poetry-version: latest
77+
78+
- name: Configure Poetry
79+
run: |
80+
poetry config virtualenvs.create true --local
81+
poetry config virtualenvs.in-project true --local
82+
83+
- name: Install Task
84+
uses: arduino/setup-task@v1
85+
with:
86+
version: 3.x
87+
repo-token: ${{ secrets.GITHUB_TOKEN }}
88+
89+
- name: Install dependencies
90+
run: task install
91+
92+
- name: Run Semantic Release
93+
id: release
94+
env:
95+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96+
run: |
97+
task release:full
98+
# Set GitHub Actions outputs for downstream jobs
99+
if [ -f .version.txt ] && [ "$(cat .version.txt)" != "0.0.0" ]; then
100+
echo "released=true" >> $GITHUB_OUTPUT
101+
echo "version=$(cat .version.txt)" >> $GITHUB_OUTPUT
102+
echo "tag=v$(cat .version.txt)" >> $GITHUB_OUTPUT
103+
else
104+
echo "released=false" >> $GITHUB_OUTPUT
105+
fi
106+
107+
update-lock:
108+
name: Update Poetry Lock
109+
runs-on: ubuntu-latest
110+
needs: release
111+
if: needs.release.outputs.released == 'true'
112+
steps:
113+
- name: Checkout code
114+
uses: actions/checkout@v4
115+
with:
116+
ref: main
117+
token: ${{ secrets.GITHUB_TOKEN }}
118+
119+
- name: Setup Python
120+
uses: actions/setup-python@v4
121+
with:
122+
python-version: "3.9"
123+
124+
- name: Install Poetry
125+
uses: abatilo/actions-poetry@v3
126+
with:
127+
poetry-version: latest
128+
129+
- name: Configure Poetry
130+
run: |
131+
poetry config virtualenvs.create true --local
132+
poetry config virtualenvs.in-project true --local
133+
134+
- name: Install Task
135+
uses: arduino/setup-task@v1
136+
with:
137+
version: 3.x
138+
repo-token: ${{ secrets.GITHUB_TOKEN }}
139+
140+
- name: Update Poetry lock file
141+
run: |
142+
task release:setup-git
143+
task release:update-lock
144+
# Push changes if any were made
145+
if [ -n "$(git log --oneline HEAD~1..HEAD | grep 'chore: update poetry.lock')" ]; then
146+
git push
147+
fi

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,4 @@ certs/
172172
plan.md
173173
machines.yml
174174
.swarm_token
175+
bin/

.yamllint.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
extends: relaxed
2+
rules:
3+
line-length:
4+
max: 120

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,16 +287,56 @@ This project follows Test-Driven Development (TDD) principles:
287287
- **Red/Green/Refactor Cycle**: Ensures reliable, maintainable code
288288
- **No Mocking of External Dependencies**: Integration-focused testing approach
289289

290-
### Running Tests
290+
### Development Commands
291+
292+
We use [Task](https://taskfile.dev/) for development commands. All dependencies are Python-based for easy CI/CD integration:
293+
291294
```bash
295+
# Install dependencies
296+
task install
297+
292298
# Run all tests
299+
task test
300+
301+
# Run linting
302+
task lint
303+
304+
# Run static analysis
305+
task static-analysis
306+
307+
# Run all checks (CI pipeline)
308+
task check
309+
310+
# Show all available tasks
311+
task --list
312+
```
313+
314+
### Running Tests Directly
315+
```bash
316+
# Run all tests with BATS
293317
bats tests/unit/**/*.bats
294318
295319
# Run specific test suites
296320
bats tests/unit/scripts/service_generator_test.bats
297321
bats tests/unit/cli/enhanced_cli_test.bats
298322
```
299323

324+
### CI/CD Pipeline
325+
326+
The project includes automated CI/CD workflows:
327+
328+
- **Pull Request Checks**: Linting, static analysis, and tests run on every PR
329+
- **Automated Releases**: Semantic versioning and changelog generation on main branch
330+
- **Conventional Commits**: Use conventional commit messages for automated releases
331+
332+
Example commit messages:
333+
```bash
334+
feat: add new service configuration
335+
fix: resolve domain validation issue
336+
docs: update installation guide
337+
chore: update dependencies
338+
```
339+
300340
## 🤝 Contributing
301341

302342
We welcome contributions! This project emphasizes:

0 commit comments

Comments
 (0)