Skip to content

Commit bfddd09

Browse files
committed
Add CI/CD and release helpers to Makefile
1 parent 45c874a commit bfddd09

File tree

8 files changed

+616
-0
lines changed

8 files changed

+616
-0
lines changed

.github/dependabot.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for Python
4+
- package-ecosystem: "pip"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
time: "09:00"
10+
open-pull-requests-limit: 10
11+
reviewers:
12+
- "abdulsagheer"
13+
assignees:
14+
- "abdulsagheer"
15+
commit-message:
16+
prefix: "pip"
17+
prefix-development: "pip-dev"
18+
include: "scope"
19+
labels:
20+
- "dependencies"
21+
- "python"
22+
ignore:
23+
# Ignore major version updates for these packages
24+
- dependency-name: "pytest"
25+
update-types: ["version-update:semver-major"]
26+
- dependency-name: "black"
27+
update-types: ["version-update:semver-major"]
28+
- dependency-name: "flake8"
29+
update-types: ["version-update:semver-major"]
30+
- dependency-name: "mypy"
31+
update-types: ["version-update:semver-major"]
32+
33+
# Enable version updates for GitHub Actions
34+
- package-ecosystem: "github-actions"
35+
directory: "/"
36+
schedule:
37+
interval: "weekly"
38+
day: "monday"
39+
time: "09:00"
40+
open-pull-requests-limit: 5
41+
reviewers:
42+
- "abdulsagheer"
43+
assignees:
44+
- "abdulsagheer"
45+
labels:
46+
- "dependencies"
47+
- "github-actions"
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Manual Release
2+
3+
on:
4+
push:
5+
tags: [ 'v*' ]
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Set up Python
15+
uses: actions/setup-python@v4
16+
with:
17+
python-version: "3.13"
18+
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install build twine
23+
24+
- name: Extract version from tag
25+
id: version
26+
run: |
27+
VERSION=${GITHUB_REF#refs/tags/v}
28+
echo "version=$VERSION" >> $GITHUB_OUTPUT
29+
echo "Release version: $VERSION"
30+
31+
- name: Update version in setup.py
32+
run: |
33+
sed -i "s/version=\"[^\"]*\"/version=\"${{ steps.version.outputs.version }}\"/" setup.py
34+
echo "Updated setup.py version to ${{ steps.version.outputs.version }}"
35+
36+
- name: Build package
37+
run: |
38+
python -m build
39+
40+
- name: Check package
41+
run: |
42+
twine check dist/*
43+
44+
- name: Publish to PyPI
45+
env:
46+
TWINE_USERNAME: __token__
47+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
48+
run: |
49+
twine upload dist/*
50+
51+
- name: Create GitHub Release
52+
uses: actions/create-release@v1
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
with:
56+
tag_name: ${{ github.ref_name }}
57+
release_name: Release ${{ github.ref_name }}
58+
body: |
59+
## Cost Katana Python SDK v${{ steps.version.outputs.version }}
60+
61+
### Installation
62+
```bash
63+
pip install cost-katana==${{ steps.version.outputs.version }}
64+
```
65+
66+
### What's New
67+
- Updated dependencies and improvements
68+
- Enhanced CLI interface
69+
- Better error handling
70+
71+
### Breaking Changes
72+
None
73+
74+
### Bug Fixes
75+
- Fixed Makefile syntax issues
76+
- Updated Python command references
77+
78+
### Documentation
79+
- Updated installation instructions
80+
- Improved examples and documentation
81+
82+
### Development
83+
- Added GitHub Actions CI/CD
84+
- Automated testing and publishing
85+
draft: false
86+
prerelease: false

.github/workflows/publish.yml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: Build and Publish to PyPI
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
tags: [ 'v*' ]
7+
pull_request:
8+
branches: [ main, master ]
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: [3.8, 3.9, 3.10, 3.11, 3.12, 3.13]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install -r requirements.txt
29+
pip install -r requirements-dev.txt
30+
pip install -e .
31+
32+
- name: Lint with flake8
33+
run: |
34+
# stop the build if there are Python syntax errors or undefined names
35+
flake8 cost_katana/ --count --select=E9,F63,F7,F82 --show-source --statistics
36+
# exit-zero treats all errors as warnings
37+
flake8 cost_katana/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
38+
39+
- name: Format check with black
40+
run: |
41+
black --check cost_katana/
42+
black --check examples/
43+
44+
- name: Type check with mypy
45+
run: |
46+
mypy cost_katana/ --ignore-missing-imports
47+
48+
- name: Test with pytest
49+
run: |
50+
pytest tests/ -v --cov=cost_katana --cov-report=xml
51+
52+
- name: Test examples
53+
run: |
54+
python -m py_compile examples/*.py
55+
56+
- name: Upload coverage to Codecov
57+
uses: codecov/codecov-action@v3
58+
with:
59+
file: ./coverage.xml
60+
fail_ci_if_error: false
61+
62+
build-and-publish:
63+
needs: test
64+
runs-on: ubuntu-latest
65+
if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
66+
67+
steps:
68+
- uses: actions/checkout@v4
69+
70+
- name: Set up Python
71+
uses: actions/setup-python@v4
72+
with:
73+
python-version: "3.13"
74+
75+
- name: Install dependencies
76+
run: |
77+
python -m pip install --upgrade pip
78+
pip install build twine
79+
80+
- name: Extract version from setup.py
81+
id: version
82+
run: |
83+
VERSION=$(python -c "import re; setup_content = open('setup.py').read(); version_match = re.search(r\"version=['\"]([^'\"]*)['\"]\", setup_content); print(version_match.group(1))")
84+
echo "version=$VERSION" >> $GITHUB_OUTPUT
85+
echo "Extracted version: $VERSION"
86+
87+
- name: Build package
88+
run: |
89+
python -m build
90+
91+
- name: Check package
92+
run: |
93+
twine check dist/*
94+
95+
- name: Publish to PyPI
96+
env:
97+
TWINE_USERNAME: __token__
98+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
99+
run: |
100+
twine upload dist/*
101+
102+
- name: Create GitHub Release
103+
if: startsWith(github.ref, 'refs/tags/v')
104+
uses: actions/create-release@v1
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
with:
108+
tag_name: ${{ github.ref_name }}
109+
release_name: Release ${{ github.ref_name }}
110+
body: |
111+
## What's Changed
112+
113+
This release includes updates to the Cost Katana Python SDK.
114+
115+
### Installation
116+
```bash
117+
pip install cost-katana==${{ steps.version.outputs.version }}
118+
```
119+
120+
### Features
121+
- Updated dependencies
122+
- Improved error handling
123+
- Enhanced CLI interface
124+
125+
### Breaking Changes
126+
None
127+
128+
### Bug Fixes
129+
- Fixed Makefile syntax issues
130+
- Updated Python command references
131+
132+
### Documentation
133+
- Updated installation instructions
134+
- Improved examples
135+
draft: false
136+
prerelease: false

.github/workflows/security.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Security
2+
3+
on:
4+
schedule:
5+
# Run security checks weekly
6+
- cron: '0 2 * * 1'
7+
push:
8+
branches: [ main, master ]
9+
pull_request:
10+
branches: [ main, master ]
11+
12+
jobs:
13+
security:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: "3.13"
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -r requirements.txt
28+
pip install -r requirements-dev.txt
29+
pip install safety bandit
30+
31+
- name: Run safety check
32+
run: |
33+
safety check --json --output safety-report.json || true
34+
safety check --full-report
35+
36+
- name: Run bandit security scan
37+
run: |
38+
bandit -r cost_katana/ -f json -o bandit-report.json || true
39+
bandit -r cost_katana/ -f txt
40+
41+
- name: Upload safety results to GitHub
42+
uses: actions/upload-artifact@v3
43+
if: always()
44+
with:
45+
name: safety-report
46+
path: safety-report.json
47+
48+
- name: Upload bandit results to GitHub
49+
uses: actions/upload-artifact@v3
50+
if: always()
51+
with:
52+
name: bandit-report
53+
path: bandit-report.json

.github/workflows/test.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ main, master, develop ]
6+
pull_request:
7+
branches: [ main, master ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: [3.8, 3.9, 3.10, 3.11, 3.12, 3.13]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install -r requirements.txt
28+
pip install -r requirements-dev.txt
29+
pip install -e .
30+
31+
- name: Lint with flake8
32+
run: |
33+
# stop the build if there are Python syntax errors or undefined names
34+
flake8 cost_katana/ --count --select=E9,F63,F7,F82 --show-source --statistics
35+
# exit-zero treats all errors as warnings
36+
flake8 cost_katana/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
37+
38+
- name: Format check with black
39+
run: |
40+
black --check cost_katana/
41+
black --check examples/
42+
43+
- name: Type check with mypy
44+
run: |
45+
mypy cost_katana/ --ignore-missing-imports
46+
47+
- name: Test with pytest
48+
run: |
49+
pytest tests/ -v --cov=cost_katana --cov-report=xml --cov-report=term
50+
51+
- name: Test examples
52+
run: |
53+
python -m py_compile examples/*.py
54+
55+
- name: Build package
56+
run: |
57+
python -m build
58+
59+
- name: Check package
60+
run: |
61+
twine check dist/*
62+
63+
- name: Upload coverage to Codecov
64+
uses: codecov/codecov-action@v3
65+
with:
66+
file: ./coverage.xml
67+
fail_ci_if_error: false

0 commit comments

Comments
 (0)