Skip to content

Commit 4beca63

Browse files
committed
feat: various improvements
1 parent 3689e35 commit 4beca63

File tree

1 file changed

+11
-30
lines changed

1 file changed

+11
-30
lines changed

.github/workflows/awesome_workflow.yml

+11-30
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ jobs:
88
name: Code Formatter
99
runs-on: ubuntu-latest
1010
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
1315
- name: requirements
1416
run: |
1517
sudo apt-get -qq update
@@ -20,39 +22,18 @@ jobs:
2022
run: |
2123
git config --global user.name github-actions[bot]
2224
git config --global user.email '[email protected]'
23-
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
2425
- name: Filename Formatter
2526
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
4629
- name: Update DIRECTORY.md
4730
run: |
4831
wget https://raw.githubusercontent.com/TheAlgorithms/scripts/main/build_directory_md.py
4932
python3 build_directory_md.py C-Plus-Plus . .cpp,.hpp,.h > DIRECTORY.md
5033
git commit -m "updating DIRECTORY.md" DIRECTORY.md || true
5134
- name: Get file changes
5235
run: |
53-
git remote -v
5436
git branch
55-
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
5637
git diff --diff-filter=dr --name-only origin/master > git_diff.txt
5738
echo "Files changed-- `cat git_diff.txt`"
5839
- name: Configure for static lint checks
@@ -78,10 +59,10 @@ jobs:
7859
if not cpp_files:
7960
sys.exit(0)
8061
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, "--"],
8263
check=True, text=True, stderr=subprocess.STDOUT)
8364
84-
subprocess.run(["clang-format-10", "-i", "-style=file", *cpp_files],
65+
subprocess.run(["clang-format", "-i", "-style=file", *cpp_files],
8566
check=True, text=True, stderr=subprocess.STDOUT)
8667
8768
upper_files = [file for file in cpp_files if file != file.lower()]
@@ -105,8 +86,8 @@ jobs:
10586
- name: Commit and push changes
10687
run: |
10788
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
11091
11192
build:
11293
name: Compile checks
@@ -116,7 +97,7 @@ jobs:
11697
matrix:
11798
os: [ubuntu-latest, windows-latest, macOS-latest]
11899
steps:
119-
- uses: actions/checkout@master
100+
- uses: actions/checkout@v3
120101
with:
121102
submodules: true
122103
- run: cmake -B ./build -S .

0 commit comments

Comments
 (0)