Skip to content

Commit

Permalink
Dev (#5)
Browse files Browse the repository at this point in the history
Format and tidy.
  • Loading branch information
andreiavrammsd authored Sep 1, 2024
1 parent a7c4da5 commit dbf188d
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 7 deletions.
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Checks: >
-llvmlibc-restrict-system-libc-headers,
-llvmlibc-implementation-in-namespace,
-llvmlibc-callee-namespace,
-llvmlibc-inline-function-decl,
-llvm-header-guard,
-fuchsia-overloaded-operator,
-modernize-use-trailing-return-type,
Expand Down
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"twxs.cmake",
"fredericbonnet.cmake-test-adapter",
"ms-vscode.cmake-tools",
"notskm.clang-tidy",
"ryanluker.vscode-coverage-gutters",
"AndreasNonslidHvardsen.clang-tidy-on-active-file",
"ryanluker.vscode-coverage-gutters"
]
}
},
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
enable_tests: "ON",
enable_coverage: "OFF",
enable_asan: "OFF",
code_quality: false,
}
- {
name: "Ubuntu 22.04 GCC (Debug)",
Expand All @@ -32,6 +33,7 @@ jobs:
enable_tests: "ON",
enable_coverage: "ON",
enable_asan: "ON",
code_quality: true,
}
- {
name: "macOS Latest Clang (Release)",
Expand All @@ -40,6 +42,7 @@ jobs:
enable_tests: "ON",
enable_coverage: "OFF",
enable_asan: "OFF",
code_quality: false,
}
- {
name: "Windows Latest (Release)",
Expand All @@ -48,23 +51,33 @@ jobs:
enable_tests: "ON",
enable_coverage: "OFF",
enable_asan: "OFF",
code_quality: false,
}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Cache
uses: actions/cache@v3
with:
path: |
build/
build-code-quality/
key: ${{ matrix.config.name }}-cmake-${{ hashFiles('CMakeLists.txt', 'cmake/*.cmake') }}

- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{github.workspace}}/build

- name: Code Quality
run: |
./code-quality.sh ${{ github.event.repository.default_branch }} ${{ github.event_name }} ${{github.workspace}} \
${{github.workspace}}/build-code-quality ${{ matrix.config.build_type }} tests
if: matrix.config.code_quality == true

- name: Configure CMake
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/build
/build*
8 changes: 4 additions & 4 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"configurations": [
{
"name": "clang",
"name": "gcc",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/clang-14",
"compilerPath": "/usr/bin/gcc-9",
"cStandard": "c17",
"intelliSenseMode": "linux-clang-x64",
"configurationProvider": "ms-vscode.cmake-tools"
},
{
"name": "gcc",
"name": "clang",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc-9",
"compilerPath": "/usr/bin/clang-10",
"cStandard": "c17",
"intelliSenseMode": "linux-clang-x64",
"configurationProvider": "ms-vscode.cmake-tools"
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"cmake.configureOnOpen": true,
"cmake.sourceDirectory": "${workspaceFolder}",
"cmake.buildDirectory": "${workspaceFolder}/build",
"cmake.options.statusBarVisibility": "visible",
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
},
Expand All @@ -26,6 +27,8 @@
"jacoco.xml",
"coverage.cobertura.xml"
],
"clang-tidy-on-active-file.autoRunOnSave": true,
"clang-tidy-on-active-file.configPath": "/workspace/.clang-tidy",
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"C_Cpp.codeAnalysis.clangTidy.enabled": true,
"C_Cpp.codeAnalysis.clangTidy.useBuildPath": true,
Expand Down
63 changes: 63 additions & 0 deletions code-quality.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

set -e

default_branch=$1 # master
event=$2 # pull_request|push
workspace=$3 # ..
build_path=$4 # build-dir
build_type=$5 # Debug
build_target=$6 # tests

echo default_branch=$default_branch
echo event=$event
echo workspace=$workspace
echo build_path=$build_path
echo build_type=$build_type
echo build_target=$build_target

if [ -z ${default_branch} ]; then
echo "Default branch is missing"
exit 1
fi

cwd=$PWD

# Build with clang for compilation database used by clang-tidy
mkdir -p ${build_path}
cd ${build_path}

cmake ${workspace} \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_BUILD_TYPE=${build_type} \
-DENABLE_TESTS=ON
cmake --build . --config ${build_type} --target ${build_target}

cd ${cwd}

# Find files
files=$(if [ $event == "pull_request" ]; then
git diff --name-only origin/$default_branch...HEAD
else
git ls-files
fi | grep '\.*pp$')

# Run tools
echo

if [ ! -z "${files}" ]; then
file_count=$(echo "${files}" | wc -w)

echo "Format ${file_count} file(s)"
clang-format -i $files

git diff --exit-code
echo

echo "Tidy ${file_count} file(s)"
clang-tidy -p ${build_path} $files
else
echo "No files changed"
fi
1 change: 1 addition & 0 deletions include/msd/zip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <cstddef>
#include <iterator>
#include <tuple>
#include <type_traits>
#include <utility>

namespace msd {
Expand Down

0 comments on commit dbf188d

Please sign in to comment.