1- name : Python CI
1+ name : CI/CD Pipeline
22
33on :
44 push :
5+ branches : [ main, develop ]
56 pull_request :
7+ branches : [ main ]
8+ release :
9+ types : [ published ]
610
711jobs :
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
0 commit comments