feat: improve the Awesome Workflow (#1186)

* feat: improve the Awesome Workflow

Co-authored-by: Taj <tjgurwara99@users.noreply.github.com>

* updating DIRECTORY.md

* chore: remove/add a few spaces

Co-authored-by: Taj <tjgurwara99@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions@users.noreply.github.com>
This commit is contained in:
David Leal 2022-12-17 19:27:04 -06:00 committed by GitHub
parent 50349e065e
commit af0ffcbd42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 38 deletions

View File

@ -1,46 +1,32 @@
name: Awesome CI Workflow
on: [push, pull_request]
# push:
# branches: [ master ]
# pull_request:
# branches: [ master ]
permissions:
contents: write
jobs:
MainSequence:
name: Code Formatter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1 # v2 is broken for git diff
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
- name: requirements
run: |
sudo apt-get -qq update
sudo apt-get -qq install clang-tidy clang-format
# checks are passing with less errors when used with this version.
# The default installs v6.0 which did not work out well in my tests
- name: Setup Git Specs
run: |
git config --global user.name github-actions
git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com'
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git config --global user.name github-actions[bot]
git config --global user.email 'github-actions@users.noreply.github.com'
- name: Filename Formatter
run: |
IFS=$'\n'
for fname in `find . -type f -name '*.c' -o -name '*.h'`
do
echo "${fname}"
new_fname=`echo ${fname} | tr ' ' '_'`
echo " ${new_fname}"
new_fname=`echo ${new_fname} | tr 'A-Z' 'a-z'`
echo " ${new_fname}"
new_fname=`echo ${new_fname} | tr '-' '_'`
echo " ${new_fname}"
if [ ${fname} != ${new_fname} ]
then
echo " ${fname} --> ${new_fname}"
git "mv" "${fname}" ${new_fname}
fi
done
git commit -am "formatting filenames ${GITHUB_SHA::8}" || true
wget https://raw.githubusercontent.com/TheAlgorithms/scripts/main/filename_formatter.sh
chmod +x filename_formatter.sh
./filename_formatter.sh . .c,.h
- name: Update DIRECTORY.md
run: |
wget https://raw.githubusercontent.com/TheAlgorithms/scripts/main/build_directory_md.py
@ -48,9 +34,7 @@ jobs:
git commit -m "updating DIRECTORY.md" DIRECTORY.md || true
- name: Get file changes
run: |
git remote -v
git branch
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git diff --diff-filter=dr --name-only origin/master > git_diff.txt
echo "Files changed-- `cat git_diff.txt`"
- name: Configure for static lint checks
@ -75,11 +59,9 @@ jobs:
print(f"{len(cpp_files)} C++ files were modified.")
if not cpp_files:
sys.exit(0)
subprocess.run(["clang-tidy-10", "-p=build", "--fix", *cpp_files, "--"],
subprocess.run(["clang-tidy", "-p=build", "--fix", *cpp_files, "--"],
check=True, text=True, stderr=subprocess.STDOUT)
subprocess.run(["clang-format-10", "-i", *cpp_files],
subprocess.run(["clang-format", "-i", *cpp_files],
check=True, text=True, stderr=subprocess.STDOUT)
upper_files = [file for file in cpp_files if file != file.lower()]
@ -103,12 +85,11 @@ jobs:
bad_files = nodir_file_bad_files + len(upper_files + space_files)
if bad_files:
sys.exit(bad_files)
- name: Commit and push changes
run: |
git commit -am "clang-format and clang-tidy fixes for ${GITHUB_SHA::8}" || true
git push --force origin HEAD:$GITHUB_REF || true
git diff DIRECTORY.md
git commit -am "clang-format and clang-tidy fixes for ${GITHUB_SHA::8}" || true
git push origin HEAD:$GITHUB_REF || true
build:
name: Compile checks
runs-on: ${{ matrix.os }}
@ -117,7 +98,7 @@ jobs:
matrix:
os: [ubuntu-latest, macOS-latest]
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v3
with:
submodules: true
- run: cmake -B ./build -S .

View File

@ -195,6 +195,7 @@
* [1653](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1653.c)
* [169](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/169.c)
* [1695](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1695.c)
* [1704](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1704.c)
* [173](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/173.c)
* [1752](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1752.c)
* [1769](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/1769.c)
@ -213,6 +214,8 @@
* [217](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/217.c)
* [223](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/223.c)
* [226](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/226.c)
* [2270](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/2270.c)
* [230](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/230.c)
* [2304](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/2304.c)
* [231](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/231.c)
* [234](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/234.c)
@ -227,6 +230,7 @@
* [287](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/287.c)
* [29](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/29.c)
* [3](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/3.c)
* [32](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/32.c)
* [344](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/344.c)
* [35](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/35.c)
* [367](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/367.c)
@ -258,6 +262,7 @@
* [704](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/704.c)
* [709](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/709.c)
* [771](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/771.c)
* [79](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/79.c)
* [8](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/8.c)
* [82](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/82.c)
* [83](https://github.com/TheAlgorithms/C/blob/HEAD/leetcode/src/83.c)