-
-
Notifications
You must be signed in to change notification settings - Fork 5
131 lines (129 loc) · 4.68 KB
/
linting.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
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
---
name: Linting
# yamllint disable-line rule:truthy
on:
push:
pull_request:
workflow_dispatch:
jobs:
precommit:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- id: bandit
name: Check with bandit
- id: black
name: Check code style
- id: blacken-docs
name: Check code style in documentation
- id: check-ast
name: Check Python AST
- id: check-case-conflict
name: Check for case conflicts
- id: check-docstring-first
name: Check docstring is first
- id: check-executables-have-shebangs
name: Check that executables have shebangs
- id: check-json
name: Check JSON files
- id: check-merge-conflict
name: Check for merge conflicts
- id: check-symlinks
name: Check for broken symlinks
- id: check-toml
name: Check TOML files
- id: check-xml
name: Check XML files
- id: check-yaml
name: Check YAML files
- id: codespell
name: Check code for common misspellings
- id: debug-statements
name: Debug Statements and imports (Python)
- id: detect-private-key
name: Detect Private Keys
- id: end-of-file-fixer
name: Check End of Files
- id: fix-byte-order-marker
name: Check UTF-8 byte order marker
- id: flake8
name: Enforcing style guide with flake8
- id: isort
name: Check imports are sorted
- id: poetry
name: Check pyproject file
- id: prettier
name: Check if code is prettier
- id: pylint
name: Check with pylint
- id: pyupgrade
name: Check for upgradable syntax
- id: trailing-whitespace
name: Trim Trailing Whitespace
- id: vulture
name: Check for unused Python code
- id: yamllint
name: Check YAML style
steps:
- name: ⤵️ Check out code from GitHub
uses: actions/checkout@v3
- name: 🏗 Set up Python 3.8
id: python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: 🏗 Read .nvmrc
if: ${{ matrix.id == 'prettier' }}
id: nvm
run: echo "##[set-output name=nvmrc;]$(cat .nvmrc)"
- name: 🏗 Set up Node.js ${{ steps.nvm.outputs.nvmrc }}
if: ${{ matrix.id == 'prettier' }}
uses: actions/setup-node@v3.7.0
with:
node-version: "${{ steps.nvm.outputs.nvmrc }}"
- name: 🏗 Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: ⤵️ Restore cached Python PIP packages
uses: actions/cache@v3
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: pip-${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('.github/workflows/requirements.txt') }}
restore-keys: |
pip-${{ runner.os }}-${{ steps.python.outputs.python-version }}-
- name: 🏗 Install workflow dependencies
run: |
pip install -r .github/workflows/requirements.txt
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
- name: ⤵️ Restore cached Python virtual environment
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: >-
venv-${{ runner.os }}-${{ steps.python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
venv-${{ runner.os }}-${{ steps.python.outputs.python-version }}-
- name: 🏗 Install Python dependencies
run: poetry install --no-interaction
- name: 🏗 Get npm cache directory
if: ${{ matrix.id == 'prettier' }}
id: npm-cache
run: |
echo "::set-output name=dir::$(npm config get cache)"
- name: ⤵️ Restore cached node modules
if: ${{ matrix.id == 'prettier' }}
uses: actions/cache@v3
with:
path: ${{ steps.npm-cache.outputs.dir }}
key: node-${{ runner.os }}-${{ steps.nvm.outputs.nvmrc }}-${{ hashFiles('.github/workflows/requirements.txt') }}
restore-keys: |
node-${{ runner.os }}-${{ steps.nvm.outputs.nvmrc }}-
- name: 🏗 Install NPM dependencies
if: ${{ matrix.id == 'prettier' }}
run: npm install
- name: 🚀 Run pre-commit for ${{ matrix.id }}
run: poetry run pre-commit run ${{ matrix.id }} --all-files