-
Notifications
You must be signed in to change notification settings - Fork 22
122 lines (116 loc) · 3.49 KB
/
code-quality.yml
File metadata and controls
122 lines (116 loc) · 3.49 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
# Code quality: flake8, isort, bandit
name: Code quality
on:
push:
branches: ["*"]
pull_request:
branches: ["*"]
jobs:
skip-check:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.check.outputs.should_skip }}
steps:
- uses: actions/github-script@v7
id: check
with:
script: |
const branch = process.env.BRANCH || '';
const { data: { workflow_runs } } = await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
status: 'in_progress',
});
const otherRunning = workflow_runs.filter(
r => r.id != context.runId &&
r.name === context.workflow &&
(!branch || r.head_branch === branch)
);
core.setOutput('should_skip', otherRunning.length > 0 ? 'true' : 'false');
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
lint:
needs: skip-check
if: needs.skip-check.outputs.should_skip != 'true'
name: flake8
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Create venv and install
run: |
python -m venv env
source env/bin/activate
pip install --upgrade pip flake8
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
pip install -e .
- name: Run flake8
run: |
source env/bin/activate
flake8 pymdoccbor
isort:
needs: skip-check
if: needs.skip-check.outputs.should_skip != 'true'
name: isort
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Create venv and install
run: |
python -m venv env
source env/bin/activate
pip install --upgrade pip isort
pip install -e .
- name: Check import order with isort
run: |
source env/bin/activate
isort pymdoccbor --check-only --diff
bandit:
needs: skip-check
if: needs.skip-check.outputs.should_skip != 'true'
name: Bandit security scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Create venv and install
run: |
python -m venv env
source env/bin/activate
pip install --upgrade pip bandit
pip install -e .
- name: Run Bandit security scan
run: |
source env/bin/activate
bandit -r -x pymdoccbor/tests pymdoccbor -f txt
radon:
needs: skip-check
if: needs.skip-check.outputs.should_skip != 'true'
name: Radon complexity
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Create venv and install
run: |
python -m venv env
source env/bin/activate
pip install --upgrade pip radon
pip install -e .
- name: Run Radon (maintainability index, no fail)
run: |
source env/bin/activate
radon cc pymdoccbor -a -n B || true
- name: Run Radon (raw metrics)
run: |
source env/bin/activate
radon raw pymdoccbor -s || true