Skip to content

Commit

Permalink
Adds readme (#1)
Browse files Browse the repository at this point in the history
* Adds readme

* break some files

* configs lint job

* adds stuff

* adapt to bash

* adds sqlite

* minor

* add coverage report

* fix yaml?

* yaml stuff

* hello

* sdf

* skjdhf

* sdf

* asdf

* adfg

* asdjlhf

* asdgasd

* asgasdg

* blkbljb

* asdfasdf

* asdkjhbasdf

* sdfasdf

* adfgdfgsdfg

* asdgasdg

* sdfgsdfg

* asdfasdf

* fasdfdf

* asdfasdf
  • Loading branch information
diachenko-mischa authored Apr 25, 2024
1 parent 0d0f036 commit 397226a
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ CheckOptions:
- { key: readability-identifier-naming.FunctionCase, value: camelBack }
- { key: readability-identifier-naming.VariableCase, value: camelBack }
- { key: readability-identifier-naming.PrivateMemberCase, value: camelBack }
- { key: readability-identifier-naming.PrivateMemberPrefix, value: m_ }
- { key: readability-identifier-naming.EnumCase, value: CamelCase }
- { key: readability-identifier-naming.PrivateMemberPrefix, value: _ }
- { key: readability-identifier-naming.EnumCase, value: UPPER_CASE }
- { key: readability-identifier-naming.EnumConstantCase, value: UPPER_CASE }
- { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE }
- { key: readability-identifier-naming.ConstexprVariableCase, value: UPPER_CASE }
107 changes: 73 additions & 34 deletions .github/workflows/github-actions-demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,81 @@ name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
Linter:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: mkdir build
- run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- uses: cpp-linter/cpp-linter-action@v2
id: linter
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/setup-python@v5
with:
style: 'file' # Use .clang-format config file
tidy-checks: '' # Use .clang-tidy config file
# only 'update' a single comment in a pull request's thread.
thread-comments: ${{ github.event_name == 'pull_request' && 'update' }}
- name: Fail fast?!
if: steps.linter.outputs.checks-failed > 0
run: exit 1
Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: mkdir build
- run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- run: cmake build --build
python-version: '3.x'
cache: 'pip' # caching pip dependencies

- uses: ammaraskar/gcc-problem-matcher@master

- name: Install PIP packages
run: pip install -r requirements.txt

- name: Check code formatting
run: clang-format -n -Werror `find src -name '*.cpp'`

- name: Cmake Configure
run: |
mkdir build
cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: Run clang-tidy (Static analysis & Code style checks)
run: clang-tidy -p=build `find src -name '*.cpp'` `find src -name '*.h'`

- name: Build
run: cmake --build build

- name: Run unit tests
run: ./build/src/main --gtest_output=xml:gtest_report.xml

- name: Generate coverage reports
run: |
mkdir coverage
python3 -m gcovr --filter "src/*" --cobertura cobertura-coverage-details.xml
python3 -m gcovr --filter "src/*" --html-details coverage/coverage-details.html
- name: Publish Test Report
uses: mikepenz/action-junit-report@v4
if: success() || failure() # always run even if the previous step fails
with:
report_paths: 'gtest_report.xml'
include_passed: true

- name: Code Coverage Report
uses: irongut/[email protected]
with:
filename: cobertura-coverage-details.xml
badge: true
fail_below_min: true
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '60 80'

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md

- name: Upload gtest report
uses: actions/upload-artifact@v3 # upload test results
if: success() || failure() # run this step even if previous step failed
with:
name: gtest_report
path: gtest_report.xml

- name: Upload coverage report
uses: actions/upload-artifact@v3 # upload test results
if: success() || failure() # run this step even if previous step failed
with:
name: coverage
path: coverage/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
And example project with a lot of checks
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gcovr==7.2
32 changes: 32 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@
cmake_minimum_required(VERSION 3.14)
project(my_project)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
OVERRIDE_FIND_PACKAGE
)

# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)


FetchContent_Declare(
SQLite3
GIT_REPOSITORY https://github.com/ClickHouse/sqlite-amalgamation.git
GIT_TAG master
OVERRIDE_FIND_PACKAGE
)

FetchContent_MakeAvailable(googletest SQLite3)

find_package(SQLite3 REQUIRED CONFIG)

set(CMAKE_CXX_STANDARD 20)
add_executable(main main.cpp)
target_link_libraries(main SQLite3 GTest::gtest_main)
target_compile_options(main PRIVATE --coverage)
target_link_options(main PRIVATE --coverage)
19 changes: 13 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
#include <gtest/gtest.h>
#include <array>
#include <iostream>
#include "table.h"

struct Foobar {
public:
explicit Foobar(int value) : _helloField(value) {}

[[nodiscard]] int value() const { return _helloField; }

private:
int m_helloField;
int _helloField;
};

int main(int argc, char** argv) {
constexpr auto ARRAY_SIZE = 100;
std::array<int, ARRAY_SIZE> array;
std::cout << "Hello world" << std::endl;
return 0;
TEST(Foobar, goodTest) {
using ::testing::Eq;
constexpr auto EXPECTED_VALUE = 10;
const auto foobar = Foobar{EXPECTED_VALUE};
EXPECT_EQ(foobar.value(), EXPECTED_VALUE);
}
5 changes: 5 additions & 0 deletions src/table.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <string>

struct Table {
void methodA() {}
};

0 comments on commit 397226a

Please sign in to comment.