Skip to content

Commit d753fd4

Browse files
committed
feat(qa): add github workflows
1 parent cfcd90a commit d753fd4

File tree

7 files changed

+446
-0
lines changed

7 files changed

+446
-0
lines changed

.github/dependabot.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: 2
2+
updates:
3+
# Enable version updates for Python dependencies
4+
- package-ecosystem: "pip"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
day: "monday"
9+
open-pull-requests-limit: 5
10+
labels:
11+
- "dependencies"
12+
- "python"
13+
commit-message:
14+
prefix: "chore"
15+
include: "scope"
16+
17+
# Enable version updates for GitHub Actions
18+
- package-ecosystem: "github-actions"
19+
directory: "/"
20+
schedule:
21+
interval: "weekly"
22+
day: "monday"
23+
open-pull-requests-limit: 5
24+
labels:
25+
- "dependencies"
26+
- "github-actions"
27+
commit-message:
28+
prefix: "ci"
29+
include: "scope"

.github/workflows-badges.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# GitHub Actions Status Badges
2+
3+
Add these badges to your README.md:
4+
5+
```markdown
6+
[![CI](https://github.com/rande/python-simple-ioc/actions/workflows/ci.yml/badge.svg)](https://github.com/rande/python-simple-ioc/actions/workflows/ci.yml)
7+
[![Tests](https://github.com/rande/python-simple-ioc/actions/workflows/tests.yml/badge.svg)](https://github.com/rande/python-simple-ioc/actions/workflows/tests.yml)
8+
[![Test Matrix](https://github.com/rande/python-simple-ioc/actions/workflows/test-matrix.yml/badge.svg)](https://github.com/rande/python-simple-ioc/actions/workflows/test-matrix.yml)
9+
```
10+
11+
## Workflow Descriptions
12+
13+
### ci.yml
14+
- Main CI workflow that runs on every push and PR
15+
- Runs flake8 linting and the standard test suite
16+
- Tests against Python 3.9, 3.10, 3.11, and 3.12
17+
18+
### tests.yml
19+
- Comprehensive test workflow with separate jobs for:
20+
- Linting (flake8 and optional mypy)
21+
- Core tests (without optional dependencies)
22+
- Tests with individual extras (tornado, flask, etc.)
23+
- Tests with all extras installed
24+
- Documentation build
25+
- Package build and validation
26+
27+
### test-extras.yml
28+
- Tests optional dependencies combinations
29+
- Runs weekly to catch dependency compatibility issues
30+
- Smart error detection that ignores expected ImportErrors
31+
32+
### test-matrix.yml
33+
- Cross-platform testing (Linux, macOS, Windows)
34+
- Full Python version matrix
35+
- Ensures compatibility across different operating systems
36+
37+
### release.yml
38+
- Triggered on version tags
39+
- Builds and publishes to PyPI
40+
- Includes test PyPI publishing for testing
41+
42+
## Required Secrets
43+
44+
To enable package publishing, add these secrets to your GitHub repository:
45+
- `PYPI_API_TOKEN`: Your PyPI API token for publishing releases
46+
- `TEST_PYPI_API_TOKEN`: Your Test PyPI API token for testing releases

.github/workflows/ci.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
jobs:
10+
test:
11+
name: Test Python ${{ matrix.python-version }}
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
python-version: ['3.9', '3.10', '3.11', '3.12']
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install -e ".[dev]"
30+
pip install sphinx
31+
32+
- name: Run linting (flake8)
33+
run: |
34+
make lint
35+
36+
- name: Run tests
37+
run: |
38+
make test
39+
40+
- name: Run tests with type checking (optional)
41+
run: |
42+
make test-strict || true
43+
continue-on-error: true
44+
45+
- name: Run unit tests only
46+
run: |
47+
make unittest

.github/workflows/release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
- '[0-9]+.[0-9]+.[0-9]+'
8+
9+
jobs:
10+
test:
11+
uses: ./.github/workflows/ci.yml
12+
13+
build-and-publish:
14+
needs: test
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: '3.11'
24+
25+
- name: Install build dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install build twine
29+
30+
- name: Build package
31+
run: |
32+
python -m build
33+
34+
- name: Check package
35+
run: |
36+
twine check dist/*
37+
38+
- name: Publish to Test PyPI
39+
env:
40+
TWINE_USERNAME: __token__
41+
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
42+
run: |
43+
twine upload --repository testpypi dist/*
44+
if: env.TWINE_PASSWORD != ''
45+
continue-on-error: true
46+
47+
- name: Publish to PyPI
48+
env:
49+
TWINE_USERNAME: __token__
50+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
51+
run: |
52+
twine upload dist/*
53+
if: env.TWINE_PASSWORD != '' && startsWith(github.ref, 'refs/tags/')

.github/workflows/test-extras.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Test with Optional Dependencies
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
schedule:
9+
# Run weekly to catch issues with dependency updates
10+
- cron: '0 0 * * 0'
11+
12+
jobs:
13+
test-extras:
14+
name: Test with ${{ matrix.extras }} on Python ${{ matrix.python-version }}
15+
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
python-version: ['3.9', '3.11']
20+
extras:
21+
- 'tornado'
22+
- 'flask'
23+
- 'jinja2'
24+
- 'redis'
25+
- 'twisted'
26+
- 'tornado,flask,jinja2'
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- name: Set up Python ${{ matrix.python-version }}
32+
uses: actions/setup-python@v4
33+
with:
34+
python-version: ${{ matrix.python-version }}
35+
36+
- name: Install dependencies with ${{ matrix.extras }}
37+
run: |
38+
python -m pip install --upgrade pip
39+
pip install -e ".[${{ matrix.extras }}]"
40+
41+
- name: Run tests
42+
run: |
43+
python -m unittest discover -s tests -p "test_*.py" -v 2>&1 | tee test_output.txt
44+
45+
# Count passed tests vs errors
46+
echo "=== Test Summary ==="
47+
grep -E "^(test_|Ran)" test_output.txt || true
48+
49+
# Check if core tests are passing (ignore import errors for optional deps)
50+
if grep -q "FAILED" test_output.txt; then
51+
errors=$(grep -c "ImportError.*No module named" test_output.txt || echo 0)
52+
total_errors=$(grep -oE "errors=([0-9]+)" test_output.txt | grep -oE "[0-9]+" || echo 0)
53+
54+
if [ "$errors" -eq "$total_errors" ]; then
55+
echo "All errors are due to missing optional dependencies - this is expected"
56+
exit 0
57+
else
58+
echo "Found unexpected test failures"
59+
exit 1
60+
fi
61+
fi

.github/workflows/test-matrix.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Test Matrix
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
pull_request:
7+
branches: [ master, main ]
8+
9+
jobs:
10+
test-matrix:
11+
name: ${{ matrix.os }} / Python ${{ matrix.python-version }}
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.9', '3.10', '3.11', '3.12']
18+
exclude:
19+
# Reduce matrix size by excluding some combinations
20+
- os: macos-latest
21+
python-version: '3.10'
22+
- os: windows-latest
23+
python-version: '3.10'
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Set up Python ${{ matrix.python-version }}
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: ${{ matrix.python-version }}
32+
33+
- name: Install core dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
pip install -e .
37+
38+
- name: Run core tests
39+
run: |
40+
python -m unittest discover -s tests/ioc -p "test_*.py" -v
41+
42+
- name: Install dev dependencies
43+
run: |
44+
pip install -e ".[dev]"
45+
46+
- name: Run linting
47+
run: |
48+
flake8 ioc/ tests/
49+
50+
- name: Summary
51+
if: always()
52+
run: |
53+
echo "Tests completed for ${{ matrix.os }} / Python ${{ matrix.python-version }}"

0 commit comments

Comments
 (0)