-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
133 lines (112 loc) · 4.57 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
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
# Execute Uncrustify 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, including uncrustify and ament_uncrustify
# - Get the file names of those files that has changed between base and head branch
# - Execute uncrustify over those files (only c++ ones) and store in ${result_filename} file.
#
# Arguments:
# - result_filename : file name to store the uncrustify errors [uncrustify_results.xml]
# - uncrustify_configuration_version : branch of cpp-style repo to get configuration from [master]
# - file_extensions_grep_args : grep filer for file extensions [-e '\\.h' -e '\\.hpp' -e '\\.cpp' -e '\\.ipp']
#
# Files structure:
# ${{ github.workspace }}
# ├── check
# │ ├── Sync repository <-- execute uncrustify here
# │
# ├── ament_lint_ws
# │ ├── src
# │ │ ├── ament_lint
# │ |
# │ ├── install
# │ ├── build
# │ ├── log
name: 'uncrustify'
description: 'Uncrustify action to check C++ linter over modified files.'
inputs:
result_filename:
description: 'File name to store the changes'
required: false
default: uncrustify_results.xml
uncrustify_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 '\\.h' -e '\\.hpp' -e '\\.cpp' -e '\\.ipp' -e '\\.cxx'"
# NOTE: there is no uncrustify version because it could not be set the same default for both ubuntu 20 and 22.
# And on Ubuntu 22 there is only 1 version available in apt.
runs:
using: composite
steps:
- name: Sync repository
uses: eProsima/eProsima-CI/external/checkout@main
with:
path: '${{ github.workspace }}/check'
- name: Fetch all branches and tags
uses: eProsima/eProsima-CI/ubuntu/git_fetch_all@main
with:
workspace: '${{ github.workspace }}/check'
- name: Install uncrustify
uses: eProsima/eProsima-CI/ubuntu/install_uncrustify@main
- name: Install Colcon
uses: eProsima/eProsima-CI/ubuntu/install_colcon@main
# TODO: Change to main branch when PR is merged to allow c++ check over other files different than cpp hpp
# (required for .ipp files)
- name: Clone and build ament_lint
run: |
echo "::group::Build ament_lint"
mkdir -p ${{ github.workspace }}/ament_lint_ws
cd ${{ github.workspace }}/ament_lint_ws
git clone https://github.com/eProsima/ament_lint.git src/ament_lint
colcon build --packages-up-to ament_uncrustify
echo "::endgroup::"
shell: bash
- name: Fetch uncrustify config file
run: |
cd ${{ github.workspace }}/ament_lint_ws
curl \
-l https://raw.githubusercontent.com/eProsima/cpp-style/${{ inputs.uncrustify_configuration_version }}/uncrustify.cfg \
-o uncrustify.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: ${{ github.workspace }}/check
- name: Check difference is not empty
run: |
if [[ -z "${MODIFIED_FILES}" ]]
then
touch ${{ github.workspace }}/check/__empty.hpp
echo "MODIFIED_FILES=__empty.hpp" >> $GITHUB_ENV
fi
echo "Files to check: ${MODIFIED_FILES}"
shell: bash
- name: Check style
run: |
cd ${{ github.workspace }}/ament_lint_ws
source install/local_setup.bash
cd ${{ github.workspace }}/check
echo "################################################################################################"
echo "###################################### UNCRUSTIFY RESULT #######################################"
ament_uncrustify \
-c ${{ github.workspace }}/ament_lint_ws/uncrustify.cfg \
--language CPP \
--xunit-file ../${{ inputs.result_filename }} \
${MODIFIED_FILES}
echo "################################# UNCRUSTIFY CHECK SUCCESSFUL ##################################"
echo "################################################################################################"
shell: bash