-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaction.yml
96 lines (80 loc) · 2.86 KB
/
action.yml
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
# Execute flake8 Python linter job from the same repo that calls this action.
#
# Runs on:
# - Ubuntu 20.04
# - Ubuntu 22.04
#
# Steps:
# - Checkout repository and fetch unshallow to be able to compare
# - Install packages required
# - Get the file names of those files that has changed between base and head branch
# - Execute flake8 over those files (only python ones).
#
# Arguments:
# - linter_configuration_version : branch of cpp-style repo to get configuration from [master]
# - file_extensions_grep_args : grep filer for file extensions [-e '\\.py']
name: 'python_linter'
description: 'Python Linter action to check Python modified files.'
inputs:
linter_configuration_version:
description: 'Branch of eProsima/cpp-style'
required: false
default: "master"
file_extensions_grep_args:
description: 'Extensions of the files to check as C++, as grep filter arguments.'
required: false
default: "-e '\\.py'"
runs:
using: composite
steps:
- name: Sync repository
uses: eProsima/eProsima-CI/external/checkout@main
with:
path: src
- name: Fetch all branches and tags
uses: eProsima/eProsima-CI/ubuntu/git_fetch_all@main
with:
workspace: src
- name: Install Flake8
uses: eProsima/eProsima-CI/ubuntu/install_python_packages@main
with:
packages: flake8==5.0.4 flake8-quotes
- name: Fetch python linter config file
run: |
curl \
-l https://raw.githubusercontent.com/eProsima/cpp-style/${{ inputs.linter_configuration_version }}/python_linter.cfg \
-o python_linter.cfg
shell: bash
- name: Get Git difference
id: GetGitDifference
uses: eProsima/eProsima-CI/ubuntu/get_git_diff_files@main
with:
result_env_var:
MODIFIED_FILES
head_ref:
origin/${GITHUB_HEAD_REF}
base_ref:
origin/${GITHUB_BASE_REF}
grep_args:
${{ inputs.file_extensions_grep_args }}
workspace:
src
- name: Check difference is not empty
run: |
cd src
if [[ -z "${MODIFIED_FILES}" ]]
then
touch __empty.py
echo "MODIFIED_FILES=__empty.py" >> $GITHUB_ENV
fi
echo "Files to check: ${MODIFIED_FILES}"
shell: bash
- name: Check style
run: |
cd src
echo "################################################################################################"
echo "#################################### PYTHON LINTER RESULTS #####################################"
python3 -m flake8 --config ../python_linter.cfg --count --statistics ${MODIFIED_FILES}
echo "################################ PYTHON LINTER CHECK SUCCESSFUL ################################"
echo "################################################################################################"
shell: bash