-
Notifications
You must be signed in to change notification settings - Fork 1
164 lines (141 loc) Β· 5.78 KB
/
Copy pathlint-format.yml
File metadata and controls
164 lines (141 loc) Β· 5.78 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
# The workflow checks
# - the validity of pyproject.toml,
# - the presence and correctness of SPDX license headers,
# - linting and formatting of Python code,
# - linting and formatting of docstrings in Python code,
# - formatting of non-Python files (like markdown and toml).
# - linting of Python code in Jupyter notebooks (for library template).
#
# A summary of the checks is added to the GitHub Actions summary.
name: Lint and format checks
on:
# Trigger the workflow on push
push:
branches-ignore: [master, main] # Already verified in PR
# Do not run this workflow on creating a new tag starting with
# 'v', e.g. 'v1.0.3' (see publish-pypi.yml)
tags-ignore: ['v*']
# Trigger the workflow on pull request
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Allow only one concurrent workflow, skipping runs queued between the run
# in-progress and latest queued. And cancel in-progress runs.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
# Set the environment variables to be used in all jobs defined in this workflow
env:
CI_BRANCH: ${{ github.head_ref || github.ref_name }}
jobs:
lint-format:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up pixi
uses: ./.github/actions/setup-pixi
- name: Run post-install developer steps
run: pixi run post-install
- name: Check validity of pyproject.toml
id: pyproject
continue-on-error: true
shell: bash
run: pixi run pyproject-check
- name: Check SPDX license headers
id: license_headers
continue-on-error: true
shell: bash
run: pixi run license-check
- name: Check linting of Python code
id: py_lint
continue-on-error: true
shell: bash
run: pixi run py-lint-check
- name: Check formatting of Python code
id: py_format
continue-on-error: true
shell: bash
run: pixi run py-format-check
- name: Check linting of docstrings in Python code
id: docstring_lint
continue-on-error: true
shell: bash
run: pixi run docstring-lint-check
- name: Check docstring coverage (interrogate)
id: docstring_coverage
continue-on-error: true
shell: bash
run: pixi run docstring-coverage
- name: Check formatting of non-Python files (md, toml, etc.)
id: nonpy_format
continue-on-error: true
shell: bash
run: pixi run nonpy-format-check
- name: Check linting of Python code in Jupyter notebooks (ipynb)
id: notebook_lint
continue-on-error: true
shell: bash
run: pixi run notebook-lint-check
- name: Check unit-test directory mirrors src/ structure
id: test_structure
continue-on-error: true
shell: bash
run: pixi run test-structure-check
- name: Check spelling (codespell)
id: spell
continue-on-error: true
shell: bash
run: pixi run spell-check
- name: Check documentation links (lychee)
id: link
continue-on-error: true
shell: bash
run: pixi run link-check
- name: Build documentation strictly (no tutorial execution)
id: docs_build
continue-on-error: true
shell: bash
run: pixi run docs-build
# Add summary
- name: Add quality checks summary
if: always()
shell: bash
run: |
{
echo "## π§ͺ Checks Summary"
echo ""
echo "| Check | Status |"
echo "|-------|--------|"
echo "| pyproject.toml | ${{ steps.pyproject.outcome == 'success' && 'β
' || 'β' }} |"
echo "| license headers | ${{ steps.license_headers.outcome == 'success' && 'β
' || 'β' }} |"
echo "| py lint | ${{ steps.py_lint.outcome == 'success' && 'β
' || 'β' }} |"
echo "| py format | ${{ steps.py_format.outcome == 'success' && 'β
' || 'β' }} |"
echo "| docstring lint | ${{ steps.docstring_lint.outcome == 'success' && 'β
' || 'β' }} |"
echo "| docstring cover | ${{ steps.docstring_coverage.outcome == 'success' && 'β
' || 'β' }} |"
echo "| nonpy format | ${{ steps.nonpy_format.outcome == 'success' && 'β
' || 'β' }} |"
echo "| notebooks lint | ${{ steps.notebook_lint.outcome == 'success' && 'β
' || 'β' }} |"
echo "| test structure | ${{ steps.test_structure.outcome == 'success' && 'β
' || 'β' }} |"
echo "| spelling | ${{ steps.spell.outcome == 'success' && 'β
' || 'β' }} |"
echo "| doc links | ${{ steps.link.outcome == 'success' && 'β
' || 'β' }} |"
echo "| docs strict build| ${{ steps.docs_build.outcome == 'success' && 'β
' || 'β' }} |"
} >> "$GITHUB_STEP_SUMMARY"
# Fail job if any check failed
- name: Fail job if any check failed
if: |
steps.pyproject.outcome == 'failure'
|| steps.license_headers.outcome == 'failure'
|| steps.py_lint.outcome == 'failure'
|| steps.py_format.outcome == 'failure'
|| steps.docstring_lint.outcome == 'failure'
|| steps.docstring_coverage.outcome == 'failure'
|| steps.nonpy_format.outcome == 'failure'
|| steps.notebook_lint.outcome == 'failure'
|| steps.test_structure.outcome == 'failure'
|| steps.spell.outcome == 'failure'
|| steps.link.outcome == 'failure'
|| steps.docs_build.outcome == 'failure'
shell: bash
run: exit 1