-
Notifications
You must be signed in to change notification settings - Fork 0
162 lines (139 loc) · 5.48 KB
/
lint.yml
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
name: Lint
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
env:
NODE_VERSION: '18'
PYTHON_VERSION: '3.11'
jobs:
backend-lint:
name: Backend Code Quality
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3 # actions/checkout v3
with:
fetch-depth: 0 # Required for SonarQube analysis
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v4 # actions/setup-python v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: 'pip'
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3 # actions/setup-node v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install pylint==2.17.0 flake8==6.0.0 mypy==1.3.0 pytest==7.4.0 pytest-cov==4.1.0
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
- name: Install Node.js dependencies for backend TypeScript
run: |
if [ -f package.json ]; then npm ci; fi
- name: Run ESLint on backend TypeScript
run: |
if [ -d src ] && [ -f .eslintrc.backend.js ]; then
npx eslint --config .eslintrc.backend.js "src/**/*.ts"
fi
- name: Run Pylint
run: |
if [ -d src ] && [ -f .pylintrc ]; then
pylint --rcfile=.pylintrc --fail-under=9.0 src/ tests/
fi
- name: Run Flake8
run: |
if [ -d src ] && [ -f .flake8 ]; then
flake8 --config=.flake8 src/ tests/
fi
- name: Run MyPy
run: |
if [ -d src ] && [ -f mypy.ini ]; then
mypy --config-file=mypy.ini src/
fi
- name: Run Python tests with coverage
run: |
if [ -d tests ]; then
pytest --cov=src --cov-report=xml --junitxml=test-results.xml tests/
fi
- name: SonarQube Analysis
uses: SonarSource/[email protected] # SonarSource/sonarcloud-github-action v1.8
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }}
-Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }}
-Dsonar.sources=src
-Dsonar.tests=tests
-Dsonar.python.coverage.reportPaths=coverage.xml
-Dsonar.python.xunit.reportPath=test-results.xml
-Dsonar.python.pylint.reportPath=pylint-report.txt
-Dsonar.qualitygate.wait=true
-Dsonar.coverage.exclusions=**/tests/**/*
-Dsonar.cpd.exclusions=**/tests/**/*
frontend-lint:
name: Frontend Code Quality
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3 # actions/checkout v3
with:
fetch-depth: 0 # Required for SonarQube analysis
- name: Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3 # actions/setup-node v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: |
if [ -d frontend ] && [ -f frontend/package.json ]; then
cd frontend
npm ci
fi
- name: Run ESLint
run: |
if [ -d frontend/src ] && [ -f frontend/.eslintrc.js ]; then
cd frontend
npx eslint --config .eslintrc.js "src/**/*.{ts,tsx,js,jsx}"
fi
- name: TypeScript type checking
run: |
if [ -d frontend/src ] && [ -f frontend/tsconfig.json ]; then
cd frontend
npx tsc --noEmit
fi
- name: Verify documentation coverage
run: |
if [ -d frontend/src/components ] && [ -f frontend/scripts/verify-documentation-coverage.js ]; then
cd frontend
npx react-docgen-typescript --out documentation.json "src/components/**/*.tsx"
node scripts/verify-documentation-coverage.js --min-coverage=100 --public-only
fi
- name: Run frontend tests with coverage
run: |
if [ -d frontend ] && [ -f frontend/package.json ]; then
cd frontend
npm test -- --coverage --ci --reporters=default --reporters=jest-junit
fi
- name: SonarQube Analysis
uses: SonarSource/[email protected] # SonarSource/sonarcloud-github-action v1.8
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.projectKey=${{ secrets.SONAR_PROJECT_KEY }}-frontend
-Dsonar.organization=${{ secrets.SONAR_ORGANIZATION }}
-Dsonar.sources=frontend/src
-Dsonar.tests=frontend/src/__tests__
-Dsonar.javascript.lcov.reportPaths=frontend/coverage/lcov.info
-Dsonar.testExecutionReportPaths=frontend/test-report.xml
-Dsonar.qualitygate.wait=true
-Dsonar.coverage.exclusions=**/__tests__/**,**/node_modules/**
-Dsonar.cpd.exclusions=**/__tests__/**,**/node_modules/**