Skip to content

Commit 12e927e

Browse files
committed
rocprofiler-register: add formatting workflow
1 parent 3527cac commit 12e927e

File tree

13 files changed

+184
-24
lines changed

13 files changed

+184
-24
lines changed
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
2+
name: rocprofiler-register Formatting
3+
4+
on:
5+
workflow_dispatch:
6+
pull_request:
7+
paths:
8+
- 'projects/rocprofiler-register/**'
9+
- '!**/*.md'
10+
- '!**/*.rtf'
11+
- '!**/*.rst'
12+
- '!**/.markdownlint-ci2.yaml'
13+
- '!**/.readthedocs.yaml'
14+
- '!**/.spellcheck.local.yaml'
15+
- '!**/.wordlist.txt'
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
cmake:
23+
runs-on: ubuntu-22.04
24+
env:
25+
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
sparse-checkout: projects/rocprofiler-register
31+
32+
- name: Extract branch name
33+
shell: bash
34+
run: |
35+
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_HEAD_REF#refs/heads/}}" >> $GITHUB_OUTPUT
36+
id: extract_branch
37+
38+
- name: Install dependencies
39+
working-directory: projects/rocprofiler-register
40+
run: |
41+
sudo apt-get update
42+
sudo apt-get install -y python3-pip
43+
python3 -m pip install -r requirements.txt
44+
45+
- name: Run cmake-format
46+
working-directory: projects/rocprofiler-register
47+
run: |
48+
FORMAT_FILES=$(find . -type f | egrep 'CMakeLists.txt|\.cmake$')
49+
command -v cmake-format
50+
cmake-format --version
51+
set +e
52+
cmake-format -i ${FORMAT_FILES}
53+
if [ $(git diff | wc -l) -ne 0 ]; then
54+
echo -e "\nError! CMake code not formatted. Run cmake-format...\n"
55+
echo -e "\nFiles:\n"
56+
git diff --name-only
57+
echo -e "\nFull diff:\n"
58+
git diff
59+
exit 1
60+
fi
61+
62+
source:
63+
runs-on: ubuntu-22.04
64+
env:
65+
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
67+
steps:
68+
- uses: actions/checkout@v4
69+
with:
70+
sparse-checkout: projects/rocprofiler-register
71+
72+
- name: Extract branch name
73+
shell: bash
74+
run: |
75+
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_HEAD_REF#refs/heads/}}" >> $GITHUB_OUTPUT
76+
id: extract_branch
77+
78+
- name: Install dependencies
79+
working-directory: projects/rocprofiler-register
80+
run: |
81+
DISTRIB_CODENAME=$(cat /etc/lsb-release | grep DISTRIB_CODENAME | awk -F '=' '{print $NF}')
82+
sudo apt-get update
83+
sudo apt-get install -y software-properties-common python3 python3-pip
84+
python3 -m pip install -r requirements.txt
85+
86+
- name: Run clang-format
87+
working-directory: projects/rocprofiler-register
88+
run: |
89+
FORMAT_FILES=$(find samples source tests benchmark -type f | egrep '\.(h|hpp|hh|c|cc|cpp)(|\.in)$')
90+
command -v git
91+
command -v clang-format
92+
git --version
93+
clang-format --version
94+
set +e
95+
FORMAT_OUT=$(clang-format -i ${FORMAT_FILES})
96+
git status
97+
if [ $(git diff | wc -l) -ne 0 ]; then
98+
echo -e "\nError! Code not formatted. Run clang-format (version 11)...\n"
99+
echo -e "\nFiles:\n"
100+
git diff --name-only
101+
echo -e "\nFull diff:\n"
102+
git diff
103+
exit 1
104+
fi
105+
106+
python:
107+
runs-on: ubuntu-22.04
108+
strategy:
109+
matrix:
110+
python-version: ['3.10']
111+
env:
112+
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113+
114+
steps:
115+
- uses: actions/checkout@v4
116+
with:
117+
sparse-checkout: projects/rocprofiler-register
118+
119+
- name: Extract branch name
120+
shell: bash
121+
run: |
122+
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_HEAD_REF#refs/heads/}}" >> $GITHUB_OUTPUT
123+
id: extract_branch
124+
125+
- name: Set up Python ${{ matrix.python-version }}
126+
uses: actions/setup-python@v5
127+
with:
128+
python-version: ${{ matrix.python-version }}
129+
130+
- name: Install dependencies
131+
working-directory: projects/rocprofiler-register
132+
run: |
133+
python -m pip install --upgrade pip
134+
python -m pip install -r requirements.txt
135+
136+
- name: black format
137+
working-directory: projects/rocprofiler-register
138+
run: |
139+
black .
140+
if [ $(git diff | wc -l) -ne 0 ]; then
141+
echo -e "\nError! Python code not formatted. Run black...\n"
142+
echo -e "\nFiles:\n"
143+
git diff --name-only
144+
echo -e "\nFull diff:\n"
145+
git diff
146+
exit 1
147+
fi
148+
149+
missing-new-line:
150+
runs-on: ubuntu-22.04
151+
152+
steps:
153+
- uses: actions/checkout@v4
154+
with:
155+
sparse-checkout: projects/rocprofiler-register
156+
157+
- name: Extract branch name
158+
shell: bash
159+
run: |
160+
echo "branch=${GITHUB_HEAD_REF:-${GITHUB_HEAD_REF#refs/heads/}}" >> $GITHUB_OUTPUT
161+
id: extract_branch
162+
163+
- name: Find missing new line
164+
shell: bash
165+
working-directory: projects/rocprofiler-register
166+
run: |
167+
OUTFILE=missing_newline.txt
168+
for i in $(find source tests samples benchmark docker cmake -type f | egrep -v '\.(bin|png|csv)$|source/docs/_(build|doxygen)'); do VAL=$(tail -c 1 ${i}); if [ -n "${VAL}" ]; then echo "- ${i}" >> ${OUTFILE}; fi; done
169+
if [[ -f ${OUTFILE} && $(cat ${OUTFILE} | wc -l) -gt 0 ]]; then
170+
echo -e "\nError! Source code missing new line at end of file...\n"
171+
echo -e "\nFiles:\n"
172+
cat ${OUTFILE}
173+
exit 1
174+
fi

projects/rocprofiler-register/samples/library-implementation/demo.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
// THE SOFTWARE.
2222

23-
2423
#include "demo.hpp"
2524

2625
#include <rocprofiler-register/rocprofiler-register.h>

projects/rocprofiler-register/tests/CMakeLists.txt

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,8 @@ function(rocp_register_test_executable _NAME)
170170
set(_BASE_PRELOAD "${ROCPROFILER_REGISTER_MEMCHECK_PRELOAD_ENV}")
171171
endif()
172172

173-
rocp_register_add_test(
174-
${_NAME} ${_NAME} "${_BASE_PRELOAD}"
175-
"${RRTE_CORE_PASS_REGEX}" "${RRTE_CORE_FAIL_REGEX}")
173+
rocp_register_add_test(${_NAME} ${_NAME} "${_BASE_PRELOAD}" "${RRTE_CORE_PASS_REGEX}"
174+
"${RRTE_CORE_FAIL_REGEX}")
176175

177176
# Build LD_PRELOAD list for -preload tests
178177
set(_PRELOAD_LIBS "librocprofiler-register.so" "libgeneric-tool.so")
@@ -181,10 +180,8 @@ function(rocp_register_test_executable _NAME)
181180
endif()
182181
list(JOIN _PRELOAD_LIBS ":" _PRELOAD_STRING)
183182

184-
rocp_register_add_test(
185-
${_NAME}-preload ${_NAME}
186-
"LD_PRELOAD=${_PRELOAD_STRING}"
187-
"${RRTE_PRELOAD_PASS_REGEX}" "${RRTE_PRELOAD_FAIL_REGEX}")
183+
rocp_register_add_test(${_NAME}-preload ${_NAME} "LD_PRELOAD=${_PRELOAD_STRING}"
184+
"${RRTE_PRELOAD_PASS_REGEX}" "${RRTE_PRELOAD_FAIL_REGEX}")
188185

189186
rocp_register_add_test(
190187
${_NAME}-env
@@ -194,16 +191,16 @@ function(rocp_register_test_executable _NAME)
194191
"${RRTE_PRELOAD_FAIL_REGEX}")
195192

196193
rocp_register_add_test(
197-
${_NAME}-wrap ${_NAME}
194+
${_NAME}-wrap
195+
${_NAME}
198196
"LD_PRELOAD=librocprofiler-register.so;ROCP_REG_TEST_WRAP=1;${ROCPROFILER_REGISTER_MEMCHECK_PRELOAD_ENV}"
199-
"${RRTE_WRAP_PASS_REGEX}" "${RRTE_WRAP_FAIL_REGEX}")
197+
"${RRTE_WRAP_PASS_REGEX}"
198+
"${RRTE_WRAP_FAIL_REGEX}")
200199

201200
rocp_register_add_test(
202-
${_NAME}-preload-wrap
203-
${_NAME}
201+
${_NAME}-preload-wrap ${_NAME}
204202
"LD_PRELOAD=${_PRELOAD_STRING};ROCP_REG_TEST_WRAP=1"
205-
"${RRTE_PRELOAD_WRAP_PASS_REGEX}"
206-
"${RRTE_PRELOAD_WRAP_FAIL_REGEX}")
203+
"${RRTE_PRELOAD_WRAP_PASS_REGEX}" "${RRTE_PRELOAD_WRAP_FAIL_REGEX}")
207204

208205
rocp_register_add_test(
209206
${_NAME}-env-wrap

projects/rocprofiler-register/tests/generic-tool/generic-tool.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
// THE SOFTWARE.
2222

23-
2423
#include <pthread.h>
2524
#include <cstdint>
2625
#include <stdexcept>

projects/rocprofiler-register/tests/rccl/rccl.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
// THE SOFTWARE.
2222

23-
2423
#pragma once
2524

2625
#define RCCL_API_TRACE_VERSION_MAJOR 0

projects/rocprofiler-register/tests/rocprofiler/rocprofiler.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
// THE SOFTWARE.
2222

23-
2423
#include <rocprofiler-register/rocprofiler-register.h>
2524
#include <amdhip/amdhip.hpp>
2625
#include <hsa-runtime/hsa-runtime.hpp>

projects/rocprofiler-register/tests/roctx/roctx.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
// THE SOFTWARE.
2222

23-
2423
#ifdef NDEBUG
2524
# undef NDEBUG
2625
#endif

projects/rocprofiler-register/tests/roctx/roctx.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
// THE SOFTWARE.
2222

23-
2423
#pragma once
2524

2625
#define ROCTX_VERSION_MAJOR 4

projects/rocprofiler-register/tests/test-amdhip-ctor-mt.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
// THE SOFTWARE.
2222

23-
2423
#include <dlfcn.h>
2524
#include <pthread.h>
2625
#include <cstdlib>

projects/rocprofiler-register/tests/test-amdhip-ctor.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
// THE SOFTWARE.
2222

23-
2423
#include <dlfcn.h>
2524
#include <cstdlib>
2625
#include <string>

0 commit comments

Comments
 (0)