From b2b1d35e637bdc64e7b7a343c7009e8beb3e9f72 Mon Sep 17 00:00:00 2001 From: Spiros Maggioros <51701672+spirosmaggioros@users.noreply.github.com> Date: Sun, 21 Jan 2024 18:01:06 +0200 Subject: [PATCH] Create awesome_workflow.yml --- .github/workflows/awesome_workflow.yml | 75 ++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/awesome_workflow.yml diff --git a/.github/workflows/awesome_workflow.yml b/.github/workflows/awesome_workflow.yml new file mode 100644 index 00000000..ffb54787 --- /dev/null +++ b/.github/workflows/awesome_workflow.yml @@ -0,0 +1,75 @@ +name: Awesome CI Workflow +on: [push, pull_request] +permissions: + contents: write + +jobs: + MainSequence: + name: Code Formatter + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + 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[bot] + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + - name: Filename Formatter + run: | + wget https://raw.githubusercontent.com/TheAlgorithms/scripts/main/filename_formatter.sh + chmod +x filename_formatter.sh + ./filename_formatter.sh . .cpp,.hpp + - name: Get file changes + run: | + git branch + 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 + # compiling first gives clang-tidy access to all the header files and settings used to compile the programs. + # This will check for macros, if any, on linux and not for Windows. But the use of portability checks should + # be able to catch any errors for other platforms. + run: cmake -B build -S . -DCMAKE_EXPORT_COMPILE_COMMANDS=ON + - name: Lint modified files + shell: bash + run: python3 scripts/file_linter.py + - name: Commit and push changes + run: | + 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 }} + needs: [MainSequence] + permissions: + pull-requests: write + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - run: | + cmake -B ./build -S . + cmake --build build + - name: Label on PR fail + uses: actions/github-script@v6 + if: ${{ failure() && matrix.os == 'ubuntu-latest' && github.event_name == 'pull_request' }} + with: + script: | + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['automated tests are failing'] + })