Skip to content

Commit 022e6aa

Browse files
committed
feat: Make repository reusable with one-command install & run
1 parent 6e24957 commit 022e6aa

File tree

22 files changed

+848
-42378
lines changed

22 files changed

+848
-42378
lines changed

.dockerignore

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Git
2+
.git
3+
.gitignore
4+
5+
# Python
6+
__pycache__
7+
*.pyc
8+
*.pyo
9+
*.pyd
10+
.Python
11+
env
12+
pip-log.txt
13+
pip-delete-this-directory.txt
14+
.tox
15+
.coverage
16+
.coverage.*
17+
.cache
18+
nosetests.xml
19+
coverage.xml
20+
*.cover
21+
*.log
22+
.git
23+
.mypy_cache
24+
.pytest_cache
25+
.hypothesis
26+
27+
# Virtual environments
28+
_venv
29+
venv
30+
ENV
31+
env
32+
.venv
33+
34+
# IDE
35+
.vscode
36+
.idea
37+
*.swp
38+
*.swo
39+
*~
40+
41+
# OS
42+
.DS_Store
43+
.DS_Store?
44+
._*
45+
.Spotlight-V100
46+
.Trashes
47+
ehthumbs.db
48+
Thumbs.db
49+
50+
# Build artifacts
51+
build/
52+
dist/
53+
*.egg-info/
54+
*.egg
55+
56+
# Documentation
57+
docs/
58+
*.md
59+
!README.md
60+
61+
# Tests
62+
tests/
63+
test_*
64+
*_test.py
65+
66+
# CI/CD
67+
.github/
68+
.gitlab-ci.yml
69+
.travis.yml
70+
.circleci/
71+
72+
# Temporary files
73+
*.tmp
74+
*.temp
75+
out.txt
76+
77+
# Local development
78+
maps/
79+
tours/
80+
contracts/
81+
traces/

.github/workflows/ci.yml

Lines changed: 143 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,155 @@
1-
name: Python CI
1+
name: CI/CD Pipeline
22

33
on:
44
push:
5+
branches: [ main, develop ]
56
pull_request:
7+
branches: [ main ]
8+
release:
9+
types: [ published ]
610

711
jobs:
8-
build:
12+
test:
913
runs-on: ubuntu-latest
10-
steps:
11-
- name: Check out code
12-
uses: actions/checkout@v4
14+
strategy:
15+
matrix:
16+
python-version: [3.9, 3.10, 3.11, 3.12]
1317

14-
- name: Set up Python
15-
uses: actions/setup-python@v5
16-
with:
17-
python-version: "3.10"
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 .
30+
pip install -r requirements.txt
31+
pip install pytest pytest-cov
32+
33+
- name: Run tests
34+
run: |
35+
pytest --cov=cli --cov-report=xml --cov-report=html
36+
37+
- name: Upload coverage to Codecov
38+
uses: codecov/codecov-action@v3
39+
with:
40+
file: ./coverage.xml
41+
flags: unittests
42+
name: codecov-umbrella
1843

19-
- name: Install dependencies
20-
run: |
21-
python -m pip install --upgrade pip
22-
pip install -r requirements.txt
23-
pip install ruff
44+
build:
45+
needs: test
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
- name: Set up Python
52+
uses: actions/setup-python@v4
53+
with:
54+
python-version: '3.11'
55+
56+
- name: Install build dependencies
57+
run: |
58+
python -m pip install --upgrade pip
59+
pip install build twine
60+
61+
- name: Build package
62+
run: python -m build
63+
64+
- name: Check package
65+
run: twine check dist/*
66+
67+
- name: Upload build artifacts
68+
uses: actions/upload-artifact@v3
69+
with:
70+
name: dist
71+
path: dist/
2472

25-
- name: Lint
26-
run: ruff check .
73+
docker:
74+
needs: test
75+
runs-on: ubuntu-latest
76+
77+
steps:
78+
- uses: actions/checkout@v4
79+
80+
- name: Set up Docker Buildx
81+
uses: docker/setup-buildx-action@v3
82+
83+
- name: Log in to GitHub Container Registry
84+
uses: docker/login-action@v3
85+
with:
86+
registry: ghcr.io
87+
username: ${{ github.actor }}
88+
password: ${{ secrets.GITHUB_TOKEN }}
89+
90+
- name: Build and push Docker image
91+
uses: docker/build-push-action@v5
92+
with:
93+
context: .
94+
push: true
95+
tags: |
96+
ghcr.io/${{ github.repository }}:latest
97+
ghcr.io/${{ github.repository }}:${{ github.sha }}
98+
cache-from: type=gha
99+
cache-to: type=gha,mode=max
27100

28-
- name: Compose contracts and generate Lean stubs
29-
run: |
30-
python u.py contracts compose -i contracts/contracts_from_openapi.yaml -i contracts/contracts_from_proto.yaml -o contracts/contracts.yaml
31-
python u.py contracts lean-stubs contracts/contracts.yaml -o contracts/lean/
32-
python u.py contracts verify-lean contracts/contracts.yaml -l contracts/lean
101+
publish:
102+
needs: [test, build]
103+
runs-on: ubuntu-latest
104+
if: github.event_name == 'release'
105+
106+
steps:
107+
- uses: actions/checkout@v4
108+
109+
- name: Download build artifacts
110+
uses: actions/download-artifact@v3
111+
with:
112+
name: dist
113+
path: dist/
114+
115+
- name: Set up Python
116+
uses: actions/setup-python@v4
117+
with:
118+
python-version: '3.11'
119+
120+
- name: Install twine
121+
run: pip install twine
122+
123+
- name: Publish to PyPI
124+
env:
125+
TWINE_USERNAME: __token__
126+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
127+
run: twine upload dist/*
33128

34-
- name: Run tests
35-
run: pytest -q
129+
security:
130+
runs-on: ubuntu-latest
131+
132+
steps:
133+
- uses: actions/checkout@v4
134+
135+
- name: Set up Python
136+
uses: actions/setup-python@v4
137+
with:
138+
python-version: '3.11'
139+
140+
- name: Install dependencies
141+
run: |
142+
python -m pip install --upgrade pip
143+
pip install safety bandit
144+
145+
- name: Run safety check
146+
run: safety check
147+
148+
- name: Run bandit security linter
149+
run: bandit -r cli/ -f json -o bandit-report.json || true
150+
151+
- name: Upload security report
152+
uses: actions/upload-artifact@v3
153+
with:
154+
name: security-report
155+
path: bandit-report.json

.gitignore

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
# Virtual environments
2-
_venv/
3-
venv/
4-
env/
5-
ENV/
6-
7-
# Python cache
1+
# Byte-compiled / optimized / DLL files
82
__pycache__/
93
*.py[cod]
104
*$py.class
5+
6+
# C extensions
117
*.so
128

139
# Distribution / packaging
@@ -24,12 +20,16 @@ parts/
2420
sdist/
2521
var/
2622
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
2725
*.egg-info/
2826
.installed.cfg
2927
*.egg
3028
MANIFEST
3129

3230
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
3333
*.manifest
3434
*.spec
3535

@@ -40,12 +40,14 @@ pip-delete-this-directory.txt
4040
# Unit test / coverage reports
4141
htmlcov/
4242
.tox/
43+
.nox/
4344
.coverage
4445
.coverage.*
4546
.cache
4647
nosetests.xml
4748
coverage.xml
4849
*.cover
50+
*.py,cover
4951
.hypothesis/
5052
.pytest_cache/
5153

@@ -57,6 +59,7 @@ coverage.xml
5759
*.log
5860
local_settings.py
5961
db.sqlite3
62+
db.sqlite3-journal
6063

6164
# Flask stuff:
6265
instance/
@@ -74,11 +77,26 @@ target/
7477
# Jupyter Notebook
7578
.ipynb_checkpoints
7679

80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
7784
# pyenv
7885
.python-version
7986

80-
# celery beat schedule file
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
8198
celerybeat-schedule
99+
celerybeat.pid
82100

83101
# SageMath parsed files
84102
*.sage.py
@@ -107,6 +125,18 @@ venv.bak/
107125
.dmypy.json
108126
dmypy.json
109127

128+
# Pyre type checker
129+
.pyre/
130+
131+
# Understand-First specific
132+
maps/
133+
tours/
134+
traces/
135+
contracts/lean/
136+
*.json
137+
!schemas/*.json
138+
!examples/**/*.json
139+
110140
# IDE
111141
.vscode/
112142
.idea/
@@ -116,9 +146,24 @@ dmypy.json
116146

117147
# OS
118148
.DS_Store
149+
.DS_Store?
150+
._*
151+
.Spotlight-V100
152+
.Trashes
153+
ehthumbs.db
119154
Thumbs.db
120155

121156
# Temporary files
122157
*.tmp
123158
*.temp
124-
out.txt
159+
out.txt
160+
161+
# Build artifacts
162+
build/
163+
dist/
164+
*.egg-info/
165+
166+
# Virtual environments
167+
_venv/
168+
.venv/
169+
venv/

0 commit comments

Comments
 (0)