-
Notifications
You must be signed in to change notification settings - Fork 1
144 lines (121 loc) · 3.96 KB
/
Copy pathcicd.yml
File metadata and controls
144 lines (121 loc) · 3.96 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
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
workflow_dispatch:
jobs:
# ============================================================
# Job 1 -- Code Quality Checks (Python & Prettier)
# ============================================================
code_quality:
name: Code Quality Checks
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install Python formatters
run: |
python -m pip install --upgrade pip
python -m pip install autoflake black==25.11.0
- name: Check Python Code Quality
shell: bash
run: |
set -euo pipefail
echo "=== Running autoflake check ==="
autoflake --remove-all-unused-imports --remove-unused-variables --recursive --check .
echo "=== Running black check ==="
black . --check
- name: Set up Node.js 20
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install Global Formatters
run: npm install -g prettier prettier-plugin-solidity
- name: Run Global Prettier Check
shell: bash
run: |
set -euo pipefail
NODE_GLOBAL=$(npm root -g)
echo "=== Running Prettier check ==="
prettier --plugin="$NODE_GLOBAL/prettier-plugin-solidity/dist/index.js" \
--check "**/*.{js,jsx,ts,tsx,json,html,css,md,sol,yml,yaml}"
# ============================================================
# Job 2 -- Backend Tests (Python / Pytest)
# ============================================================
backend_tests:
name: Backend Tests
runs-on: ubuntu-latest
needs: code_quality
env:
BACKEND_DIR: code/backend
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
cache-dependency-path: code/backend/requirements.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
if [ -f "${BACKEND_DIR}/requirements.txt" ]; then
python -m pip install -r "${BACKEND_DIR}/requirements.txt"
fi
python -m pip install pytest pytest-cov pytest-asyncio
- name: Run backend test suite
working-directory: ${{ env.BACKEND_DIR }}
run: |
set -euo pipefail
pytest tests/ \
--tb=short \
--strict-markers \
-v \
--cov=. \
--cov-report=xml:coverage.xml
- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: backend-coverage-report
path: code/backend/coverage.xml
retention-days: 30
# ============================================================
# Job 3 -- Web Frontend Build
# ============================================================
frontend_build:
name: Frontend Build
runs-on: ubuntu-latest
needs: code_quality
defaults:
run:
working-directory: web-frontend
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js 20
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: web-frontend/package-lock.json
- name: Install dependencies
run: npm ci --legacy-peer-deps
- name: Build web-frontend
run: CI=false npm run build
- name: Upload build artifacts
if: success()
uses: actions/upload-artifact@v4
with:
name: frontend-dist
path: web-frontend/dist/
retention-days: 7