-
Notifications
You must be signed in to change notification settings - Fork 224
54 lines (47 loc) · 1.42 KB
/
style_checks.yaml
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
# Code lint and style checks
#
# This workflow runs code style and lint checks to check if the codes have
# consistent code style and are high-quality.
#
# It is run on every commit to the main and pull request branches. It is also
# scheduled to run daily on the main branch.
#
name: Style Checks
on:
push:
branches: [ main ]
pull_request:
# Schedule daily tests
schedule:
- cron: '0 0 * * *'
jobs:
style_check:
name: Style Checks
runs-on: ubuntu-latest
steps:
# Checkout current git repository
- name: Checkout
uses: actions/checkout@v4.2.2
# Setup Python
- name: Set up Python
uses: actions/setup-python@v5.3.0
with:
python-version: '3.12'
- name: Install packages
run: |
python -m pip install ruff pre-commit
python -m pip list
- name: Formatting check (ruff + pre-commit)
run: |
make check
pre-commit run --all-files
- name: Ensure example scripts have at least one code block separator
run: |
git ls-files 'examples/**/*.py' | xargs grep --files-without-match '# %%' > output.txt
nfiles=$(wc --lines output.txt | awk '{print $1}')
if [[ $nfiles > 0 ]]; then
echo "Code block separator '# %%' is required in following example files:"
cat output.txt
rm output.txt
exit $nfiles
fi