Skip to content

Commit a67dc49

Browse files
authored
Change project name and implement CI/CD pipeline with testing, security scans, and deployment to PyPI (#77)
* feat(ci): implement CI/CD pipeline with testing, security scans, and deployment to PyPI * Implement code changes to enhance functionality and improve performance * refactor: reorganizer and enhancement imports * fix(ci): adjust line length for black linting in CI configuration * fix(ci): restrict OS matrix to ubuntu-latest for CI jobs * feat(ci): expand OS matrix to include windows-latest and macos-latest for CI jobs fix(makefile): update check command to use poetry for linting fix(template_renderer): enable autoescaping in Jinja2 environment fix(input_method_helper): improve docstring for HTML input generation chore(poetry): add bandit for security analysis in development dependencies * fix(ci): restringir matriz de OS para ubuntu-latest no pipeline de CI * fix: adjust formating in template_renderer.py and input_method_helper.py * fix: remove isort and flake8 checks from makefile; format exception imports in cli.py * fix(ci): remove type checking and safety check steps from CI pipeline * fix: revert version to 0.1.0 in __version__.py * fix: update minimum expected version in test_version_functional.py to 0.1.0; add unit tests for ControllerGenerator in test_generators.py * fix: format version comparison and update exception imports in tests * fix: update upload-artifact action to version 4 in CI pipeline
1 parent 81d3e33 commit a67dc49

30 files changed

+2156
-259
lines changed

.github/workflows/ci.yml

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
release:
9+
types: [ published ]
10+
11+
env:
12+
PYTHON_VERSION: "3.10"
13+
14+
jobs:
15+
test:
16+
name: Test Suite
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os: [ubuntu-latest]
22+
python-version: ["3.9", "3.10", "3.11", "3.12"]
23+
24+
steps:
25+
- name: Checkout code
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 Poetry
34+
uses: snok/install-poetry@v1
35+
with:
36+
version: latest
37+
virtualenvs-create: true
38+
virtualenvs-in-project: true
39+
40+
- name: Cache dependencies
41+
uses: actions/cache@v3
42+
with:
43+
path: .venv
44+
key: ${{ runner.os }}-python-${{ matrix.python-version }}-poetry-${{ hashFiles('**/poetry.lock') }}
45+
restore-keys: |
46+
${{ runner.os }}-python-${{ matrix.python-version }}-poetry-
47+
48+
- name: Install dependencies
49+
run: poetry install --with dev
50+
51+
- name: Run linting
52+
run: |
53+
make check
54+
55+
- name: Run tests
56+
run: poetry run pytest --cov=mvc_flask --cov-report=xml --cov-report=term-missing
57+
58+
- name: Upload coverage to Codecov
59+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
60+
uses: codecov/codecov-action@v3
61+
with:
62+
file: ./coverage.xml
63+
flags: unittests
64+
name: codecov-umbrella
65+
66+
security:
67+
name: Security Scan
68+
runs-on: ubuntu-latest
69+
steps:
70+
- name: Checkout code
71+
uses: actions/checkout@v4
72+
73+
- name: Set up Python
74+
uses: actions/setup-python@v4
75+
with:
76+
python-version: ${{ env.PYTHON_VERSION }}
77+
78+
- name: Install Poetry
79+
uses: snok/install-poetry@v1
80+
81+
- name: Install dependencies
82+
run: poetry install --with dev
83+
84+
- name: Run security checks
85+
run: |
86+
poetry run bandit -r mvc_flask
87+
88+
build:
89+
name: Build Package
90+
runs-on: ubuntu-latest
91+
needs: [test, security]
92+
steps:
93+
- name: Checkout code
94+
uses: actions/checkout@v4
95+
96+
- name: Set up Python
97+
uses: actions/setup-python@v4
98+
with:
99+
python-version: ${{ env.PYTHON_VERSION }}
100+
101+
- name: Install Poetry
102+
uses: snok/install-poetry@v1
103+
104+
- name: Build package
105+
run: poetry build
106+
107+
- name: Upload build artifacts
108+
uses: actions/upload-artifact@v4
109+
with:
110+
name: dist
111+
path: dist/
112+
113+
publish:
114+
name: Publish to PyPI
115+
runs-on: ubuntu-latest
116+
needs: [test, security, build]
117+
if: github.event_name == 'release' && github.event.action == 'published'
118+
environment: release
119+
120+
steps:
121+
- name: Checkout code
122+
uses: actions/checkout@v4
123+
124+
- name: Set up Python
125+
uses: actions/setup-python@v4
126+
with:
127+
python-version: ${{ env.PYTHON_VERSION }}
128+
129+
- name: Install Poetry
130+
uses: snok/install-poetry@v1
131+
132+
- name: Build package
133+
run: poetry build
134+
135+
- name: Publish to PyPI
136+
env:
137+
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
138+
run: poetry publish
139+
140+
docs:
141+
name: Build Documentation
142+
runs-on: ubuntu-latest
143+
steps:
144+
- name: Checkout code
145+
uses: actions/checkout@v4
146+
147+
- name: Set up Python
148+
uses: actions/setup-python@v4
149+
with:
150+
python-version: ${{ env.PYTHON_VERSION }}
151+
152+
- name: Install Poetry
153+
uses: snok/install-poetry@v1
154+
155+
- name: Install dependencies
156+
run: poetry install --with docs
157+
158+
- name: Build documentation
159+
run: poetry run mkdocs build
160+
161+
- name: Deploy to GitHub Pages
162+
if: github.ref == 'refs/heads/main'
163+
uses: peaceiris/actions-gh-pages@v3
164+
with:
165+
github_token: ${{ secrets.GITHUB_TOKEN }}
166+
publish_dir: ./site

.github/workflows/test.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)