Skip to content

Commit

Permalink
Merge pull request #13 from coders-school/basic_github_actions
Browse files Browse the repository at this point in the history
Basic version of github actions
  • Loading branch information
Vicx95 authored Feb 21, 2024
2 parents 5abb7c2 + 8627423 commit 4ff1692
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 4 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/ci_basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Basic CI ubuntu

on: [push, pull_request, workflow_dispatch]

env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
BUILD_PATH: ${{github.workspace}}/communicator/build
SOURCE: ${{github.workspace}}/communicator
TEST_BUILD_PATH: ${{github.workspace}}/communicator/tests/build
TEST_SOURCE: ${{github.workspace}}/communicator/tests


jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install Qt
uses: jurplel/install-qt-action@v3 # Installs Qt.
with:
version: '6.2.1' # The version of Qt to install.

- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: '3.22.1'

- name: Configure CMake
run: cmake -B ${{env.BUILD_PATH}} -S ${{env.SOURCE}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Build
# Build your program with the given configuration
run: cmake --build ${{env.BUILD_PATH}} --config ${{env.BUILD_TYPE}}

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y llvm cppcheck
sudo apt-get install -y iwyu
- name: Pre-commit actions
uses: pre-commit/[email protected]

- name: Configure Test CMake
run: cmake -B ${{env.TEST_BUILD_PATH}} -S ${{env.TEST_SOURCE}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: BuildTests
# Build your program with the given configuration
run: cmake --build ${{env.TEST_BUILD_PATH}} --config ${{env.BUILD_TYPE}}

- name: Test
working-directory: ${{env.TEST_BUILD_PATH}}
run: ctest -C ${{env.BUILD_TYPE}}

8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ repos:
hooks:
- id: clang-format
args: [--style=Google]
exclude: '^communicator/main.cpp$|^communicator/mainwindow.cpp$|^communicator/mainwindow.h$' #auto generated files
- id: clang-tidy
- id: oclint
- id: uncrustify
exclude: '^communicator/main.cpp$|^communicator/mainwindow.cpp$|^communicator/mainwindow.h$|^communicator/tests/exampleTest.cpp$' #auto generated files
- id: cppcheck
- id: cpplint
- id: include-what-you-use
- id: include-what-you-use
exclude: '^communicator/main.cpp$|^communicator/mainwindow.cpp$|^communicator/mainwindow.h$|^communicator/tests/exampleTest.cpp$' #auto generated files
18 changes: 18 additions & 0 deletions communicator/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.5)
project(CommunicatorGTest)

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

set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)

# Now simply link against gtest or gtest_main as needed. Eg
add_executable(example-gt exampleTest.cpp)
target_link_libraries(example-gt gtest_main)
enable_testing()
add_test(NAME example_test COMMAND example-gt)
9 changes: 9 additions & 0 deletions communicator/tests/exampleTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "gtest/gtest.h"

// Demonstrate some basic assertions.
TEST(exampleTest, BasicAssertions) {
// Expect two strings not to be equal.
EXPECT_STRNE("hello", "world");
// Expect equality.
EXPECT_EQ(7 * 6, 42);
}

0 comments on commit 4ff1692

Please sign in to comment.