Skip to content

[pull] master from TheAlgorithms:master #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/approved-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ jobs:
name: Add "approved" label when approved
runs-on: ubuntu-latest
steps:
- name: Add "approved" label when approved
uses: pullreminders/label-when-approved-action@master
env:
APPROVALS: "1"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ADD_LABEL: "approved"
REMOVE_LABEL: ""
- name: Add "approved" label when approved
uses: abinoda/label-when-approved-action@v1.0.7
env:
APPROVALS: "1"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ADD_LABEL: "approved"
REMOVE_LABEL: ""
46 changes: 11 additions & 35 deletions .github/workflows/awesome_workflow.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,24 @@
name: Awesome CI Workflow
on: [push, pull_request]
permissions:
pull-requests: write
contents: write
issues: write

jobs:
MainSequence:
name: Code Formatter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cpp-linter/cpp-linter-action@v2
id: linter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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
style: "file"
tidy-checks: ".clang-tidy"
thread-comments: ${{ github.event_name == 'pull_request' && 'update' }}

build:
name: Compile checks
Expand All @@ -59,6 +33,8 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: true
- name: GCC problem matcher
uses: ammaraskar/gcc-problem-matcher@0.3.0
- run: |
cmake -B ./build -S .
cmake --build build --parallel 4
Expand Down
2 changes: 1 addition & 1 deletion math/factorial.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**

Check notice on line 1 in math/factorial.cpp

View workflow job for this annotation

GitHub Actions / Code Formatter

Run clang-format on math/factorial.cpp

File math/factorial.cpp does not conform to Custom style guidelines. (lines 14)
* @file
* @brief Find the [factorial](https://en.wikipedia.org/wiki/Factorial) of a
* given number
Expand Down Expand Up @@ -27,7 +27,7 @@
* cannot be represented in 64 bit unsigned int
*/
uint64_t factorial(uint8_t n) {
if (n < 20) {
if (n > 20) {
throw std::invalid_argument("maximum value is 20\n");
}
if (n == 0) {
Expand Down
Loading