-
Notifications
You must be signed in to change notification settings - Fork 1
167 lines (133 loc) · 4.08 KB
/
ci.yml
File metadata and controls
167 lines (133 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
name: Blockchain CI/CD
on:
push:
branches: [ main, develop, claude/** ]
pull_request:
branches: [ main, develop ]
jobs:
test:
name: Test on Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
- name: Run tests with pytest
run: |
pytest -v --cov=blockchain_core --cov-report=xml --cov-report=term
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
lint:
name: Lint and Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 black pylint mypy
- name: Lint with flake8
run: |
# Stop the build if there are Python syntax errors or undefined names
flake8 blockchain_core --count --select=E9,F63,F7,F82 --show-source --statistics
# Exit-zero treats all errors as warnings
flake8 blockchain_core --count --exit-zero --max-complexity=10 --max-line-length=120 --statistics
- name: Check formatting with black
run: |
black --check blockchain_core tests examples
- name: Lint with pylint
run: |
pylint blockchain_core --exit-zero
- name: Type check with mypy
run: |
mypy blockchain_core --ignore-missing-imports --no-strict-optional || true
security:
name: Security Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install safety bandit
- name: Check for security vulnerabilities
run: |
safety check --json || true
- name: Run bandit security linter
run: |
bandit -r blockchain_core -f json -o bandit-report.json || true
- name: Upload bandit report
uses: actions/upload-artifact@v3
with:
name: bandit-security-report
path: bandit-report.json
docker:
name: Build Docker Image
runs-on: ubuntu-latest
needs: [test, lint]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build Docker image
run: |
docker build -t blockchain:${{ github.sha }} .
- name: Test Docker image
run: |
docker run --rm blockchain:${{ github.sha }} python -c "from blockchain_core import Blockchain; print('Docker build successful!')"
examples:
name: Run Examples
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
- name: Run basic usage example
run: |
python examples/basic_usage.py
- name: Run advanced features example
run: |
python examples/advanced_features.py