Skip to content

Commit 5c0ff70

Browse files
committed
master
1 parent ec39ea5 commit 5c0ff70

40 files changed

Lines changed: 1159 additions & 125 deletions

.github/workflows/ci.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: [3.11, 3.12]
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: Cache pip dependencies
25+
uses: actions/cache@v3
26+
with:
27+
path: ~/.cache/pip
28+
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
29+
restore-keys: |
30+
${{ runner.os }}-pip-
31+
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
pip install -e .[dev]
36+
37+
- name: Lint with flake8
38+
run: |
39+
flake8 reversibleai tests --count --select=E9,F63,F7,F82 --show-source --statistics
40+
flake8 reversibleai tests --count --exit-zero --max-complexity=10 --max-line-length=88 --statistics
41+
42+
- name: Type check with mypy
43+
run: |
44+
mypy reversibleai --ignore-missing-imports
45+
46+
- name: Run tests with pytest
47+
run: |
48+
pytest tests/ -v --cov=reversibleai --cov-report=xml --cov-report=html
49+
50+
- name: Upload coverage to Codecov
51+
uses: codecov/codecov-action@v3
52+
with:
53+
file: ./coverage.xml
54+
flags: unittests
55+
name: codecov-umbrella
56+
57+
security:
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- name: Set up Python
63+
uses: actions/setup-python@v4
64+
with:
65+
python-version: '3.11'
66+
67+
- name: Install dependencies
68+
run: |
69+
python -m pip install --upgrade pip
70+
pip install bandit safety
71+
72+
- name: Run security scan with bandit
73+
run: |
74+
bandit -r reversibleai -f json -o bandit-report.json
75+
76+
- name: Check dependencies with safety
77+
run: |
78+
safety check --json --output safety-report.json
79+
80+
- name: Upload security reports
81+
uses: actions/upload-artifact@v3
82+
with:
83+
name: security-reports
84+
path: |
85+
bandit-report.json
86+
safety-report.json
87+
88+
build:
89+
needs: [test]
90+
runs-on: ubuntu-latest
91+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
92+
93+
steps:
94+
- uses: actions/checkout@v4
95+
96+
- name: Set up Python
97+
uses: actions/setup-python@v4
98+
with:
99+
python-version: '3.11'
100+
101+
- name: Install build dependencies
102+
run: |
103+
python -m pip install --upgrade pip
104+
pip install build twine
105+
106+
- name: Build package
107+
run: |
108+
python -m build
109+
110+
- name: Build documentation
111+
run: |
112+
pip install -e .[docs]
113+
cd docs
114+
make html
115+
116+
- name: Upload build artifacts
117+
uses: actions/upload-artifact@v3
118+
with:
119+
name: dist
120+
path: dist/
121+
122+
- name: Upload documentation
123+
uses: actions/upload-artifact@v3
124+
with:
125+
name: docs
126+
path: docs/_build/html/
127+
128+
publish:
129+
needs: [test, security, build]
130+
runs-on: ubuntu-latest
131+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
132+
133+
steps:
134+
- uses: actions/checkout@v4
135+
136+
- name: Set up Python
137+
uses: actions/setup-python@v4
138+
with:
139+
python-version: '3.11'
140+
141+
- name: Download build artifacts
142+
uses: actions/download-artifact@v3
143+
with:
144+
name: dist
145+
path: dist/
146+
147+
- name: Publish to PyPI
148+
env:
149+
TWINE_USERNAME: __token__
150+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
151+
run: |
152+
twine upload dist/*

.pre-commit-config.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- id: check-merge-conflict
10+
- id: debug-statements
11+
12+
- repo: https://github.com/psf/black
13+
rev: 23.7.0
14+
hooks:
15+
- id: black
16+
language_version: python3.11
17+
18+
- repo: https://github.com/pycqa/isort
19+
rev: 5.12.0
20+
hooks:
21+
- id: isort
22+
args: ["--profile", "black"]
23+
24+
- repo: https://github.com/pycqa/flake8
25+
rev: 6.1.0
26+
hooks:
27+
- id: flake8
28+
args: [--max-line-length=88, --extend-ignore=E203,W503]
29+
30+
- repo: https://github.com/pre-commit/mirrors-mypy
31+
rev: v1.5.1
32+
hooks:
33+
- id: mypy
34+
additional_dependencies: [types-all]
35+
args: [--ignore-missing-imports]

0 commit comments

Comments
 (0)