add:sigmoid.cpp #384
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cpp testing menggunakan clang-tidy-10 dan clang-format | |
# informasi dan dokumentasi clang-tidy | |
# https://clang.llvm.org/extra/clang-tidy/ | |
# informasi dan dokumentasi clang-format | |
# https://clang.llvm.org/docs/ClangFormat.html | |
name: Cpp Testing | |
on: [push, pull_request] | |
# push: | |
# branches: [ main ] | |
# pull_request: | |
# branches: [ main ] | |
permissions: | |
contents: write | |
jobs: | |
TestingUtama: | |
name: cpp test | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-python@v4 | |
- name: install requirement | |
run: | | |
sudo apt-get -qq update | |
sudo apt-get -qq install clang-tidy clang-format | |
- name: git | |
run: | | |
git config --global user.name github-actions[bot] | |
git config --global user.email '[email protected]' | |
- name: format filename | |
run: | | |
wget https://raw.githubusercontent.com/bellshade/unitesting-script/main/filename_formatter.sh | |
chmod +x filename_formatter.sh | |
./filename_formatter.sh .cpp, .hpp | |
- name: mengambil file yang telah dirubah | |
run: | | |
git branch | |
git diff --diff-filter=dr --name-only origin/main > git_diff.txt | |
echo "file diubah-- `cat git_diff.txt`" | |
- name: Konfigurasi statik lint cpp | |
run: cmake -B build -S . -DCMAKE_EXPORT_COMPILE_COMMANDS=ON | |
- name: lint file yang telah di commit | |
shell: python | |
run: | | |
import os | |
import sys | |
import subprocess | |
print("Python {}.{}.{}".format(*sys.version_info)) | |
with open("git_diff.txt") as in_file: | |
file_modifikasi = sorted(in_file.read().splitlines()) | |
print("{} file yang termodifikasi".format(len(file_modifikasi))) | |
cpp_exts = tuple(".c .c++ .cc .cpp .cu .cuh .cxx .h .h++ .hh .hpp .hxx".split()) | |
cpp_files = [file for file in file_modifikasi if file.lower().endswith(cpp_exts)] | |
print(f"{len(cpp_files)} C++ file yang termodifikasi") | |
if not cpp_files: | |
sys.exit(0) | |
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", "-i", "-style=file", *cpp_files], | |
check=True, text=True, stderr=subprocess.STDOUT) | |
upper_files = [file for file in cpp_files if file != file.lower()] | |
if upper_files: | |
print(f"{len(upper_files)} files contain uppercase characters:") | |
print("\n".join(upper_files) + "\n") | |
space_files = [file for file in cpp_files if " " in file or "-" in file] | |
if space_files: | |
print(f"{len(space_files)} file mengandung spasi dan garis tengah:") | |
print("\n".join(space_files) + "\n") | |
nodir_files = [file for file in cpp_files if file.count(os.sep) != 1] | |
if nodir_files: | |
print(f"{len(nodir_files)} files are not in one and only one directory:") | |
print("\n".join(nodir_files) + "\n") | |
bad_files = len(upper_files + space_files + nodir_files) | |
if bad_files: | |
sys.exit(bad_files) | |
- name: commit | |
run: | | |
git commit -am "chore: clang formatter and clang-tidy fixing ${GITHUB_SHA:8}" || true | |
git push origin HEAD:$GITHUB_REF || true | |
build: | |
name: cek compile | |
runs-on: ${{ matrix.os }} | |
needs: [TestingUtama] | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- run: cmake -B ./build -S . | |
- run: cmake --build build | |