Skip to content

Commit 2801e34

Browse files
authored
Merge pull request #3 from mithun50/main
Added Some GitHub Workflows
2 parents 50574f8 + 99be7b1 commit 2801e34

63 files changed

Lines changed: 3327 additions & 464 deletions

Some content is hidden

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

.github/WORKFLOWS.md

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
# GitHub Workflows Documentation
2+
3+
This directory contains automated workflows for the FastApps project.
4+
5+
## Workflows Overview
6+
7+
### 1. CI Pipeline (`ci.yml`)
8+
**Triggers**: Push/PR to main or develop branches
9+
10+
**Jobs**:
11+
- **Test**: Runs tests on multiple OS (Ubuntu, macOS, Windows) and Python versions (3.11, 3.12)
12+
- Runs pytest with coverage
13+
- Uploads coverage to Codecov
14+
- **Lint**: Checks code formatting with Black and lints with Ruff
15+
- **Type Check**: Runs mypy for type checking
16+
- **Build**: Builds the package and validates it with twine
17+
18+
### 2. PyPI Publishing (`publish.yml`)
19+
**Triggers**: GitHub release is published
20+
21+
**Actions**:
22+
- Builds the package
23+
- Publishes to PyPI using API token
24+
- Requires `PYPI_API_TOKEN` secret
25+
26+
### 3. Test PyPI Publishing (`test-publish.yml`)
27+
**Triggers**: GitHub release is created (draft)
28+
29+
**Actions**:
30+
- Builds the package
31+
- Publishes to Test PyPI for validation
32+
- Requires `TEST_PYPI_API_TOKEN` secret
33+
34+
### 4. Dependency Review (`dependency-review.yml`)
35+
**Triggers**: Pull requests to main
36+
37+
**Actions**:
38+
- Reviews dependencies for security vulnerabilities
39+
- Fails on moderate or higher severity issues
40+
41+
### 5. CodeQL Analysis (`codeql.yml`)
42+
**Triggers**:
43+
- Push to main
44+
- Pull requests to main
45+
- Weekly schedule (Mondays)
46+
47+
**Actions**:
48+
- Scans code for security vulnerabilities
49+
- Analyzes Python codebase
50+
- Reports findings to GitHub Security
51+
52+
### 6. Release Drafter (`release-drafter.yml`)
53+
**Triggers**: Push to main
54+
55+
**Actions**:
56+
- Automatically drafts release notes
57+
- Categorizes changes by labels
58+
- Suggests version bumps based on labels
59+
60+
## Setup Requirements
61+
62+
### Required Secrets
63+
64+
Add these secrets in GitHub Settings → Secrets and variables → Actions:
65+
66+
1. **PYPI_API_TOKEN**
67+
- Get from: https://pypi.org/manage/account/token/
68+
- Scope: Entire account or specific to fastapps
69+
- Used by: `publish.yml`
70+
71+
2. **TEST_PYPI_API_TOKEN** (Optional)
72+
- Get from: https://test.pypi.org/manage/account/token/
73+
- Used by: `test-publish.yml`
74+
- Useful for testing releases before production
75+
76+
### Codecov Integration (Optional)
77+
78+
1. Sign up at https://codecov.io
79+
2. Connect your GitHub repository
80+
3. Token is automatically provided by GitHub Actions
81+
82+
## Release Process
83+
84+
### Standard Release Flow
85+
86+
1. **Develop** → Merge features into `develop` branch
87+
- CI runs on every commit
88+
- Tests must pass
89+
90+
2. **Prepare Release**
91+
- Update version in `pyproject.toml` and `setup.py`
92+
- Merge `develop``main`
93+
- Release Drafter creates draft release notes
94+
95+
3. **Create Release**
96+
- Go to Releases → Edit draft
97+
- Review and edit release notes
98+
- Create tag (e.g., `v1.0.9`)
99+
- Publish release
100+
101+
4. **Automatic Publishing**
102+
- `publish.yml` triggers on release publish
103+
- Package builds and publishes to PyPI
104+
- Users can install with `pip install fastapps`
105+
106+
### Testing Releases (Optional)
107+
108+
Before publishing to production PyPI:
109+
110+
1. Create a **draft** release
111+
2. `test-publish.yml` publishes to Test PyPI
112+
3. Test installation: `pip install -i https://test.pypi.org/simple/ fastapps`
113+
4. If successful, publish the release
114+
115+
## PR Labels for Release Notes
116+
117+
Use these labels on pull requests for automatic categorization:
118+
119+
- `feature`, `enhancement` → 🚀 Features
120+
- `fix`, `bugfix`, `bug` → 🐛 Bug Fixes
121+
- `chore`, `dependencies` → 🧰 Maintenance
122+
- `documentation`, `docs` → 📚 Documentation
123+
124+
Version bump labels:
125+
- `major` → Breaking changes (1.0.0 → 2.0.0)
126+
- `minor`, `feature` → New features (1.0.0 → 1.1.0)
127+
- `patch`, `fix` → Bug fixes (1.0.0 → 1.0.1)
128+
129+
## Dependabot
130+
131+
Configured in `.github/dependabot.yml`:
132+
- Updates GitHub Actions weekly
133+
- Updates Python dependencies weekly
134+
- Automatically creates PRs for updates
135+
136+
## Running Tests Locally
137+
138+
```bash
139+
# Install dev dependencies
140+
pip install -e ".[dev]"
141+
142+
# Run tests
143+
pytest
144+
145+
# Run tests with coverage
146+
pytest --cov=fastapps --cov-report=html
147+
148+
# Format code
149+
black .
150+
151+
# Lint code
152+
ruff check .
153+
154+
# Build package
155+
python -m build
156+
157+
# Check package
158+
twine check dist/*
159+
```
160+
161+
## Troubleshooting
162+
163+
### CI Failures
164+
165+
**Tests fail**:
166+
- Check test output in GitHub Actions logs
167+
- Run tests locally: `pytest -v`
168+
169+
**Linting fails**:
170+
- Run `black .` to auto-format
171+
- Run `ruff check .` to see issues
172+
173+
**Build fails**:
174+
- Ensure `pyproject.toml` is valid
175+
- Check dependencies are correct
176+
177+
### Publishing Failures
178+
179+
**PyPI upload fails**:
180+
- Verify `PYPI_API_TOKEN` is set correctly
181+
- Ensure version number is unique (not already published)
182+
- Check package name isn't taken
183+
184+
**Test PyPI works but production fails**:
185+
- Version might already exist on PyPI
186+
- Token might have wrong permissions
187+
188+
## Badge Examples
189+
190+
Add to your README.md:
191+
192+
```markdown
193+
[![CI](https://github.com/fastapps-framework/fastapps/actions/workflows/ci.yml/badge.svg)](https://github.com/fastapps-framework/fastapps/actions/workflows/ci.yml)
194+
[![codecov](https://codecov.io/gh/fastapps-framework/fastapps/branch/main/graph/badge.svg)](https://codecov.io/gh/fastapps-framework/fastapps)
195+
[![PyPI version](https://badge.fury.io/py/fastapps.svg)](https://badge.fury.io/py/fastapps)
196+
[![Python Versions](https://img.shields.io/pypi/pyversions/fastapps.svg)](https://pypi.org/project/fastapps/)
197+
```

.github/dependabot.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: 2
2+
updates:
3+
# GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
labels:
9+
- "dependencies"
10+
- "github-actions"
11+
12+
# Python dependencies
13+
- package-ecosystem: "pip"
14+
directory: "/"
15+
schedule:
16+
interval: "weekly"
17+
labels:
18+
- "dependencies"
19+
- "python"
20+
versioning-strategy: increase

.github/release-drafter.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name-template: 'v$RESOLVED_VERSION'
2+
tag-template: 'v$RESOLVED_VERSION'
3+
4+
categories:
5+
- title: '🚀 Features'
6+
labels:
7+
- 'feature'
8+
- 'enhancement'
9+
- title: '🐛 Bug Fixes'
10+
labels:
11+
- 'fix'
12+
- 'bugfix'
13+
- 'bug'
14+
- title: '🧰 Maintenance'
15+
labels:
16+
- 'chore'
17+
- 'dependencies'
18+
- title: '📚 Documentation'
19+
labels:
20+
- 'documentation'
21+
- 'docs'
22+
23+
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
24+
25+
version-resolver:
26+
major:
27+
labels:
28+
- 'major'
29+
- 'breaking'
30+
minor:
31+
labels:
32+
- 'minor'
33+
- 'feature'
34+
patch:
35+
labels:
36+
- 'patch'
37+
- 'fix'
38+
- 'bugfix'
39+
default: patch
40+
41+
template: |
42+
## Changes
43+
44+
$CHANGES
45+
46+
## Contributors
47+
48+
$CONTRIBUTORS

.github/workflows/ci.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
types: [ opened, synchronize, reopened ]
9+
10+
jobs:
11+
test:
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest, macos-latest, windows-latest]
17+
python-version: ['3.11', '3.12']
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install -e ".[dev]"
31+
32+
- name: Run tests with pytest
33+
run: |
34+
pytest --verbose --cov=fastapps --cov-report=xml --cov-report=term
35+
36+
- name: Upload coverage to Codecov
37+
uses: codecov/codecov-action@v4
38+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
39+
with:
40+
file: ./coverage.xml
41+
fail_ci_if_error: false
42+
43+
type-check:
44+
runs-on: ubuntu-latest
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
49+
- name: Set up Python
50+
uses: actions/setup-python@v5
51+
with:
52+
python-version: '3.11'
53+
54+
- name: Install dependencies
55+
run: |
56+
python -m pip install --upgrade pip
57+
pip install -e ".[dev]"
58+
pip install mypy
59+
60+
- name: Type check with mypy
61+
run: |
62+
mypy fastapps --ignore-missing-imports
63+
continue-on-error: true
64+
65+
build:
66+
runs-on: ubuntu-latest
67+
68+
steps:
69+
- uses: actions/checkout@v4
70+
71+
- name: Set up Python
72+
uses: actions/setup-python@v5
73+
with:
74+
python-version: '3.11'
75+
76+
- name: Install dependencies
77+
run: |
78+
python -m pip install --upgrade pip
79+
pip install build twine
80+
81+
- name: Build package
82+
run: python -m build
83+
84+
- name: Check package
85+
run: twine check dist/*
86+
87+
- name: Upload artifacts
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: dist-packages
91+
path: dist/

.github/workflows/codeql.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CodeQL Analysis
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
- cron: '0 0 * * 1' # Run every Monday at midnight
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
language: [ 'python' ]
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Initialize CodeQL
30+
uses: github/codeql-action/init@v3
31+
with:
32+
languages: ${{ matrix.language }}
33+
34+
- name: Autobuild
35+
uses: github/codeql-action/autobuild@v3
36+
37+
- name: Perform CodeQL Analysis
38+
uses: github/codeql-action/analyze@v3

0 commit comments

Comments
 (0)