generated from inovintell/template
-
Notifications
You must be signed in to change notification settings - Fork 8
86 lines (79 loc) · 3.1 KB
/
code-linter.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
---
name: Code Linter
on:
pull_request:
branches:
- main
paths:
- '**.py'
- '**.yml'
- '**.yaml'
permissions:
checks: write
contents: write
jobs:
lint:
if: ${{ ! contains(github.repository, 'template') }}
runs-on: ubuntu-latest
concurrency:
group: lint-${{ github.ref }}
cancel-in-progress: true
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
files.pythonhosted.org:443
github.com:443
pypi.org:443
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Dependencies
uses: ./.github/actions/setup-poetry
with:
python-version: "3.10" # Due to pytype not supporting 3.11
- name: Run Poetry check
run: poetry check
- name: Run YAML linter
run: poetry run yamllint .
- name: Run Python autoflake
run: poetry run autoflake --recursive --check src test
- name: Run Python tryceratops
run: poetry run tryceratops src test
- name: Run Python docformatter
run: poetry run docformatter --recursive --check src test
- name: Run Python black
run: poetry run black --check src test
- name: Run Python interrogate
run: poetry run interrogate -c pyproject.toml src test
- name: Run Python ruff
run: poetry run ruff --no-fix --format github src test
- name: Run Python pytype
run: poetry run pytype src test
- name: Run reporters
run: |
echo "# Code condition report" >> $GITHUB_STEP_SUMMARY
echo "## Basic code statistics (radon)" >> $GITHUB_STEP_SUMMARY
echo "Class | Function | Method " >> $GITHUB_STEP_SUMMARY
echo "---|---|---" >> $GITHUB_STEP_SUMMARY
echo "C | F | M " >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Good | Bad | Worst " >> $GITHUB_STEP_SUMMARY
echo "---|---|---" >> $GITHUB_STEP_SUMMARY
echo "A | C | F " >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Maintainability Index" >> $GITHUB_STEP_SUMMARY
poetry run radon mi src >> $GITHUB_STEP_SUMMARY
echo "### Cyclomatic Complexity" >> $GITHUB_STEP_SUMMARY
poetry run radon cc --total-average src >> $GITHUB_STEP_SUMMARY
echo "## Cohesion levels (cohesion)" >> $GITHUB_STEP_SUMMARY
poetry run cohesion -d src >> $GITHUB_STEP_SUMMARY
echo "## Possibly dead code (vulture)" >> $GITHUB_STEP_SUMMARY
poetry run vulture src >> $GITHUB_STEP_SUMMARY || true
echo "## Advanced code statistics (radon)" >> $GITHUB_STEP_SUMMARY
echo "### Halstead Metrics" >> $GITHUB_STEP_SUMMARY
poetry run radon hal src >> $GITHUB_STEP_SUMMARY
echo "### Raw Metrics" >> $GITHUB_STEP_SUMMARY
poetry run radon raw src >> $GITHUB_STEP_SUMMARY