Merge branch 'master' into temp

This commit is contained in:
David Leal 2022-12-30 00:35:56 -06:00 committed by GitHub
commit addb3b408f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 116 additions and 104 deletions

View File

@ -1,5 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Discord community
url: https://discord.gg/c7MnfGFGa6
url: https://the-algorithms.com/discord/
about: Have any questions or found any bugs? Please contact us via Discord

View File

@ -1,13 +1,10 @@
name: Other
name: Other issue
description: Use this for any other issues. Do NOT create blank issues
title: "[OTHER]"
labels: [triage]
labels: ["awaiting triage"]
body:
- type: markdown
attributes:
value: "# Other issue"
- type: textarea
id: issuedescription
id: description
attributes:
label: What would you like to share?
description: Provide a clear and concise explanation of your issue.

View File

@ -1,51 +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 -qq -y update
sudo apt -qq install clang-tidy-10 clang-format-10
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 David Leal
git config --global user.email 'Panquesito7@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 '*.cpp' -o -name '*.cc' -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}"
new_fname=${new_fname/.cc/.cpp}
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 . .cpp,.hpp
- name: Update DIRECTORY.md
run: |
wget https://raw.githubusercontent.com/TheAlgorithms/scripts/main/build_directory_md.py
@ -53,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
@ -81,10 +60,10 @@ jobs:
if not cpp_files:
sys.exit(0)
subprocess.run(["clang-tidy-10", "--fix", "-p=build", "--extra-arg=-std=c++11", *cpp_files, "--"],
subprocess.run(["clang-tidy", "--fix", "-p=build", "--extra-arg=-std=c++11", *cpp_files, "--"],
check=True, text=True, stderr=subprocess.STDOUT)
subprocess.run(["clang-format-10", "-i", "-style=file", *cpp_files],
subprocess.run(["clang-format", "-i", "-style=file", *cpp_files],
check=True, text=True, stderr=subprocess.STDOUT)
upper_files = [file for file in cpp_files if file != file.lower()]
@ -108,8 +87,8 @@ jobs:
- 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 --force origin HEAD:$GITHUB_REF || true
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
@ -119,7 +98,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v3
with:
submodules: true
- run: cmake -B ./build -S .

51
.github/workflows/codeql.yml vendored Normal file
View File

@ -0,0 +1,51 @@
name: "CodeQL"
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: cpp
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
# Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh
#
# In our case, this would be a CMake build step.
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:cpp"

View File

@ -1,48 +0,0 @@
name: "CodeQL"
on: [push, pull_request]
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'cpp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@main
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@main
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@main
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@main

View File

@ -8,7 +8,7 @@ jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v3
with:
submodules: true
- name: Install requirements
@ -19,7 +19,7 @@ jobs:
- name: build
run: cmake --build build -t doc
- name: gh-pages
uses: actions/checkout@master
uses: actions/checkout@v3
with:
ref: "gh-pages"
clean: false

View File

@ -9,9 +9,9 @@ jobs:
- uses: actions/stale@v4
with:
stale-issue-message: 'This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
close-issue-message: 'Please ping one of the maintainers once you add more information and updates here. If this is not the case and you need some help, feel free to ask for help in our [Gitter](https://gitter.im/TheAlgorithms) channel or our [Discord server](https://discord.gg/c7MnfGFGa6). Thank you for your contributions!'
close-issue-message: 'Please ping one of the maintainers once you add more information and updates here. If this is not the case and you need some help, feel free to ask for help in our [Gitter](https://gitter.im/TheAlgorithms) channel or our [Discord server](https://the-algorithms.com/discord/). Thank you for your contributions!'
stale-pr-message: 'This pull request has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.'
close-pr-message: 'Please ping one of the maintainers once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to ask for help in our [Gitter](https://gitter.im/TheAlgorithms) channel or our [Discord server](https://discord.gg/c7MnfGFGa6). Thank you for your contributions!'
close-pr-message: 'Please ping one of the maintainers once you commit the changes requested or make improvements on the code. If this is not the case and you need some help, feel free to ask for help in our [Gitter](https://gitter.im/TheAlgorithms) channel or our [Discord server](https://the-algorithms.com/discord/). Thank you for your contributions!'
exempt-issue-labels: 'dont-close,approved'
exempt-pr-labels: 'dont-close,approved'
days-before-stale: 30

View File

@ -2,7 +2,7 @@
## Before contributing
Welcome to [TheAlgorithms/C-Plus-Plus](https://github.com/TheAlgorithms/C-Plus-Plus)! Before submitting pull requests, please make sure that you have **read the whole guidelines**. If you have any doubts about this contribution guide, please open [an issue](https://github.com/TheAlgorithms/C-Plus-Plus/issues/new/choose) or ask on our [Discord server](https://discord.gg/c7MnfGFGa6), and clearly state your concerns.
Welcome to [TheAlgorithms/C-Plus-Plus](https://github.com/TheAlgorithms/C-Plus-Plus)! Before submitting pull requests, please make sure that you have **read the whole guidelines**. If you have any doubts about this contribution guide, please open [an issue](https://github.com/TheAlgorithms/C-Plus-Plus/issues/new/choose) or ask on our [Discord server](https://the-algorithms.com/discord/), and clearly state your concerns.
## Contributing
@ -134,7 +134,7 @@ int main(int argc, char *argv[]) {
}
```
#### New File Name guidelines
#### File Name guidelines
- Use lowercase words with ``"_"`` as a separator
- For instance
@ -148,7 +148,7 @@ my_new_cpp_class.cpp is correct format
- File name validation will run on Docker to ensure validity.
- If an implementation of the algorithm already exists and your version is different from that implemented, please use incremental numeric digit as a suffix. For example: if `median_search.cpp` already exists in the `search` folder, and you are contributing a new implementation, the filename should be `median_search2.cpp`. For a third implementation, `median_search3.cpp`, and so on.
#### New Directory guidelines
#### Directory guidelines
- We recommend adding files to existing directories as much as possible.
- Use lowercase words with ``"_"`` as separator ( no spaces or ```"-"``` allowed )
@ -162,6 +162,40 @@ some_new_fancy_category is correct
- Filepaths will be used to dynamically create a directory of our algorithms.
- Filepath validation will run on GitHub Actions to ensure compliance.
##### Integrating CMake in a new directory
In case a new directory is 100% required, `CMakeLists.txt` file in the root directory needs to be updated, and a new `CMakeLists.txt` file needs to be created within the new directory.
An example of how your new `CMakeLists.txt` file should look like. Note that if there are any extra libraries/setup required, you must include that in this file as well.
```cmake
# If necessary, use the RELATIVE flag, otherwise each source file may be listed
# with full pathname. The RELATIVE flag makes it easier to extract an executable's name
# automatically.
file( GLOB APP_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp )
foreach( testsourcefile ${APP_SOURCES} )
string( REPLACE ".cpp" "" testname ${testsourcefile} ) # File type. Example: `.cpp`
add_executable( ${testname} ${testsourcefile} )
set_target_properties(${testname} PROPERTIES LINKER_LANGUAGE CXX)
if(OpenMP_CXX_FOUND)
target_link_libraries(${testname} OpenMP::OpenMP_CXX)
endif()
install(TARGETS ${testname} DESTINATION "bin/<foldername>") # Folder name. Do NOT include `<>`
endforeach( testsourcefile ${APP_SOURCES} )
```
The `CMakeLists.txt` file in the root directory should be updated to include the new directory.\
Include your new directory after the last subdirectory. Example:
```cmake
...
add_subdirectory(divide_and_conquer)
add_subdirectory(<foldername>)
```
#### Commit Guidelines
- It is recommended to keep your changes grouped logically within individual commits. Maintainers find it easier to understand changes that are logically spilled across multiple commits. Try to modify just one or two files in the same directory. Pull requests that span multiple directories are often rejected.

View File

@ -2,15 +2,14 @@
<!-- the suffix in the above line is required for doxygen to consider this as the index page of the generated documentation site -->
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/TheAlgorithms/C-Plus-Plus)
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/TheAlgorithms/C-Plus-Plus.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/TheAlgorithms/C-Plus-Plus/context:cpp)
[![CodeQL CI](https://github.com/TheAlgorithms/C-Plus-Plus/actions/workflows/codeql_analysis.yml/badge.svg)](https://github.com/TheAlgorithms/C-Plus-Plus/actions/workflows/codeql_analysis.yml)
[![CodeQL CI](https://github.com/TheAlgorithms/C-Plus-Plus/actions/workflows/codeql.yml/badge.svg)](https://github.com/TheAlgorithms/C-Plus-Plus/actions/workflows/codeql_analysis.yml)
[![Gitter chat](https://img.shields.io/badge/Chat-Gitter-ff69b4.svg?label=Chat&logo=gitter&style=flat-square)](https://gitter.im/TheAlgorithms)
[![contributions welcome](https://img.shields.io/static/v1.svg?label=Contributions&message=Welcome&color=0059b3&style=flat-square)](https://github.com/TheAlgorithms/C-Plus-Plus/blob/master/CONTRIBUTING.md)
![GitHub repo size](https://img.shields.io/github/repo-size/TheAlgorithms/C-Plus-Plus?color=red&style=flat-square)
[![Doxygen CI](https://github.com/TheAlgorithms/C-Plus-Plus/workflows/Doxygen%20CI/badge.svg)](https://TheAlgorithms.github.io/C-Plus-Plus)
[![Awesome CI](https://github.com/TheAlgorithms/C-Plus-Plus/workflows/Awesome%20CI%20Workflow/badge.svg)](https://github.com/TheAlgorithms/C-Plus-Plus/actions?query=workflow%3A%22Awesome+CI+Workflow%22)
[![Income](https://img.shields.io/liberapay/receives/TheAlgorithms.svg?logo=liberapay)](https://liberapay.com/TheAlgorithms)
[![Discord chat](https://img.shields.io/discord/808045925556682782.svg?logo=discord&colorB=5865F2)](https://discord.gg/c7MnfGFGa6)
[![Discord chat](https://img.shields.io/discord/808045925556682782.svg?logo=discord&colorB=5865F2)](https://the-algorithms.com/discord/)
[![Donate](https://liberapay.com/assets/widgets/donate.svg)](https://liberapay.com/TheAlgorithms/donate)
## Overview