8
8
name : Code Formatter
9
9
runs-on : ubuntu-latest
10
10
steps :
11
- - uses : actions/checkout@v1 # v2 is broken for git diff
12
- - uses : actions/setup-python@v2
11
+ - uses : actions/checkout@v3
12
+ with :
13
+ fetch-depth : 0
14
+ - uses : actions/setup-python@v4
13
15
- name : requirements
14
16
run : |
15
17
sudo apt-get -qq update
@@ -20,39 +22,18 @@ jobs:
20
22
run : |
21
23
git config --global user.name github-actions[bot]
22
24
git config --global user.email '[email protected] '
23
- git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
24
25
- name : Filename Formatter
25
26
run : |
26
- IFS=$'\n'
27
- for fname in `find . -type f -name '*.cpp' -o -name '*.cc' -o -name '*.h'`
28
- do
29
- echo "${fname}"
30
- new_fname=`echo ${fname} | tr ' ' '_'`
31
- echo " ${new_fname}"
32
- new_fname=`echo ${new_fname} | tr 'A-Z' 'a-z'`
33
- echo " ${new_fname}"
34
- new_fname=`echo ${new_fname} | tr '-' '_'`
35
- echo " ${new_fname}"
36
- new_fname=${new_fname/.cc/.cpp}
37
- echo " ${new_fname}"
38
- if [ ${fname} != ${new_fname} ]
39
- then
40
- echo " ${fname} --> ${new_fname}"
41
- git "mv" "${fname}" ${new_fname}
42
- fi
43
- done
44
- git commit -am "formatting filenames ${GITHUB_SHA::8}" || true
45
-
27
+ wget https://raw.githubusercontent.com/TheAlgorithms/scripts/main/filename_formatter.sh
28
+ ./filename_formatter.sh . .cpp,.hpp
46
29
- name : Update DIRECTORY.md
47
30
run : |
48
31
wget https://raw.githubusercontent.com/TheAlgorithms/scripts/main/build_directory_md.py
49
32
python3 build_directory_md.py C-Plus-Plus . .cpp,.hpp,.h > DIRECTORY.md
50
33
git commit -m "updating DIRECTORY.md" DIRECTORY.md || true
51
34
- name : Get file changes
52
35
run : |
53
- git remote -v
54
36
git branch
55
- git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
56
37
git diff --diff-filter=dr --name-only origin/master > git_diff.txt
57
38
echo "Files changed-- `cat git_diff.txt`"
58
39
- name : Configure for static lint checks
@@ -78,10 +59,10 @@ jobs:
78
59
if not cpp_files:
79
60
sys.exit(0)
80
61
81
- subprocess.run(["clang-tidy-10 ", "--fix", "-p=build", "--extra-arg=-std=c++11", *cpp_files, "--"],
62
+ subprocess.run(["clang-tidy", "--fix", "-p=build", "--extra-arg=-std=c++11", *cpp_files, "--"],
82
63
check=True, text=True, stderr=subprocess.STDOUT)
83
64
84
- subprocess.run(["clang-format-10 ", "-i", "-style=file", *cpp_files],
65
+ subprocess.run(["clang-format", "-i", "-style=file", *cpp_files],
85
66
check=True, text=True, stderr=subprocess.STDOUT)
86
67
87
68
upper_files = [file for file in cpp_files if file != file.lower()]
105
86
- name : Commit and push changes
106
87
run : |
107
88
git diff DIRECTORY.md
108
- git commit -am "clang-format and clang-tidy fixes for ${GITHUB_SHA::8}" || true
109
- git push --force origin HEAD:$GITHUB_REF || true
89
+ git commit -am "clang-format and clang-tidy fixes for ${GITHUB_SHA::8}" || true
90
+ git push origin HEAD:$GITHUB_REF || true
110
91
111
92
build :
112
93
name : Compile checks
116
97
matrix :
117
98
os : [ubuntu-latest, windows-latest, macOS-latest]
118
99
steps :
119
- - uses : actions/checkout@master
100
+ - uses : actions/checkout@v3
120
101
with :
121
102
submodules : true
122
103
- run : cmake -B ./build -S .
0 commit comments