Skip to content

Commit

Permalink
add linux g++ build github workflow (#59)
Browse files Browse the repository at this point in the history
* add linux g++ build github workflow

* remove installing docker

* remove tty docker run arguments
  • Loading branch information
cieslarmichal authored Jul 18, 2023
1 parent 3e367be commit 1d8d091
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux-clang-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
&& sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main' \
&& sudo launchpad-getkeys \
&& sudo apt-get update -y \
&& sudo apt-get install -y lld-16 ninja-build build-essential libstdc++-13-dev \
&& sudo apt-get install -y lld-16 ninja-build build-essential libstdc++-13-dev \
clang-16 clang-tools-16 llvm-16 lcov
- name: Initialize submodules
Expand Down
26 changes: 26 additions & 0 deletions .github/workflows/linux-gxx-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: g++

on:
push:
branches:
- 'main'
pull_request:

env:
BUILD_TYPE: Debug

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Build docker image
run: docker build -t test .

- name: Run docker container
run: docker run test
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ latex/

CMakeSettings.json
.vs/
out/
out/
build-linux-gxx
build-linux-clang
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ubuntu:23.10

RUN apt update -y
RUN apt install -y cmake ninja-build g++-13 libstdc++-13-dev

COPY include/ faker-cxx/include/
COPY src/ faker-cxx/src/
COPY externals/ faker-cxx/externals/
COPY cmake/ faker-cxx/cmake/
COPY CMakeLists.txt faker-cxx/CMakeLists.txt
COPY run_linux_gxx_tests.sh faker-cxx/run_linux_gxx_tests.sh

RUN chmod 777 ./faker-cxx/run_linux_gxx_tests.sh

ENTRYPOINT cd faker-cxx && ./run_linux_gxx_tests.sh
11 changes: 11 additions & 0 deletions run_linux_gxx_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
mkdir build-linux-gxx

cd build-linux-gxx || exit 1

cmake .. -DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_COMPILER=/usr/bin/g++-13 \
-GNinja

cmake --build .

ctest -C Debug --output-on-failure
11 changes: 6 additions & 5 deletions src/NumberTest.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include "faker-cxx/Number.h"

#include "gtest/gtest.h"
#include <algorithm>

#include "gtest/gtest.h"

using namespace ::testing;
using namespace faker;

Expand Down Expand Up @@ -41,20 +42,19 @@ TEST_F(NumberTest, givenSingleArgument_shouldCorrectlyResolveToTwoArgsOverload)

TEST_F(NumberTest, givenValidRangeArguments_shouldGenerateDecimalNumberThatIsInGivenRange)
{
const float actualRandomNumber = Number::decimal<float>(2.f, 10.f);
const std::floating_point auto actualRandomNumber = Number::decimal<float>(2.f, 10.f);

ASSERT_TRUE(actualRandomNumber >= 2.f);
ASSERT_TRUE(actualRandomNumber <= 10.f);
}

TEST_F(NumberTest, givenRangeWithSameNumberSection_shouldGenerateThisNumberForDecimal)
{
const float actualRandomNumber = Number::decimal<float>(2.f, 2.f);
const std::floating_point auto actualRandomNumber = Number::decimal<float>(2.f, 2.f);

ASSERT_EQ(actualRandomNumber, 2.f);
}


TEST_F(NumberTest, givenDiscreteDistribution_shouldGenerateNumberThatIsInGivenRange)
{
auto dist = std::binomial_distribution<int>(10, 0.5);
Expand All @@ -69,7 +69,8 @@ TEST_F(NumberTest, givenRealDistribution_shouldGenerateNumberThatIsInGivenRange)
{
auto dist = std::normal_distribution<float>(5.f, 2.f);

const float actualRandomNumber = Number::decimal<float, std::normal_distribution<float>>(dist, 2.f, 10.f);
const std::floating_point auto actualRandomNumber =
Number::decimal<float, std::normal_distribution<float>>(dist, 2.f, 10.f);

ASSERT_TRUE(actualRandomNumber >= 2.f);
ASSERT_TRUE(actualRandomNumber <= 10.f);
Expand Down

0 comments on commit 1d8d091

Please sign in to comment.