-
Notifications
You must be signed in to change notification settings - Fork 15
138 lines (124 loc) · 3.59 KB
/
flake8.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
132
133
134
135
136
137
138
#
# Author: Hari Sekhon
# Date: 2024-07-02 17:28:49 +0200 (Tue, 02 Jul 2024)
#
# vim:ts=2:sts=2:sw=2:et
#
# https://github.com/HariSekhon/GitHub-Actions
#
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback
#
# https://www.linkedin.com/in/HariSekhon
#
# ============================================================================ #
# F l a k e 8
# ============================================================================ #
# Should have a .flake8 committed in the local repo working directory for customizing the checks
#
# See templates here:
#
# https://github.com/HariSekhon/Templates/blob/master/.flake8
#
# https://github.com/HariSekhon/DevOps-Python-tools/blob/master/.flake8
#
# https://github.com/HariSekhon/pylib/blob/master/.flake8
---
name: Flake8
on:
push:
branches:
- master
- main
paths:
- '**/*.py'
pull_request:
branches:
- master
- main
paths:
- '**/*.py'
workflow_call:
inputs:
python-version:
type: string
required: false
# XXX: Python version 3.10 will need to be passed by the calling workflow as quoted '3.10' otherwise will evaluate to '3.1' and break with this error:
#
# Error: The version '3.1' with architecture 'x64' was not found for Ubuntu 22.04.
#
default: '3.10'
working-directory:
type: string
required: false
default: .
#no-pip-install:
# type: string
# required: false
# default: false
submodules:
type: string
required: false
default: recursive
debug:
type: string
required: false
default: false
workflow_dispatch:
inputs:
python-version:
type: string
required: false
default: '3.10'
working-directory:
type: string
required: false
default: .
submodules:
type: string
required: false
default: recursive
#no-pip-install:
# type: boolean
# required: false
# default: false
debug:
type: boolean
required: false
default: false
#schedule:
# - cron: '0 0 * * 1'
permissions:
contents: read
defaults:
run:
shell: bash -euxo pipefail {0}
env:
DEBUG: ${{ inputs.debug == true || github.event.inputs.debug == 'true' || '' }}
jobs:
pylint:
name: Flake8
# github.event.repository.fork isn't available in scheduled workflows
# can't prevent forks of this repo, because also prevents caller workflows
#if: github.repository == 'HariSekhon/Github-Actions'
runs-on: ubuntu-latest
steps:
- name: Environment
run: env | sort
- name: Git version
run: git --version
- uses: actions/checkout@v3
with:
submodules: ${{ inputs.submodules }} # 'recursive' default requires Git 2.18+ to be installed first
- uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}
- name: Install Flake8
run: pip install flake8
- name: Install PyPI modules
working-directory: ${{ inputs.working-directory }}
#if: ${{ hashFiles('${{ inputs.working-directory }}/requirements.txt') != '' }}
#if: ! ${{ inputs.no-pip-install ! = 'true' }}
run: pip install -r requirements.txt
- name: Flake8
working-directory: ${{ inputs.working-directory }}
run: flake8 ./*.py # should have a .flake8 committed in the local repo working directory for customizing the checks