diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..dd4340a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,76 @@ +name: CI +on: + push: + branches: + - master + pull_request: + branches: + - master + workflow_dispatch: + +jobs: + build-and-test-cpp-unix: + strategy: + matrix: + # os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest] + cpp_standard: [c++11, c++14, c++17, c++20] + compiler: [gcc, clang] + fail-fast: false + runs-on: ${{ matrix.os }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up cmake + uses: jwlawson/actions-setup-cmake@v2 + + - name: Setup build + run: + cmake -DRING_BUFFER_BUILD_TESTS=ON -S . -B build \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_CXX_STANDARD=${{ matrix.cpp_standard }} \ + -DCMAKE_CXX_COMPILER=$([[ ${{ matrix.compiler }} == "gcc" ]] && echo "g++" || echo "clang++") \ + -DCMAKE_C_COMPILER=$([[ ${{ matrix.compiler }} == "gcc" ]] && echo "gcc" || echo "clang") \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic" \ + -DCMAKE_C_FLAGS="-Wall -Wextra -Wpedantic" + + - name: Build + run: cmake --build build --config Debug + + - name: Run tests + run: | + find build/test -type f -executable -name 'test-*' -exec sh -c 'echo "Running test: $1"; $1' _ {} \; + build-and-test-c99-unix: + strategy: + matrix: + # os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest] + compiler: [gcc, clang] + fail-fast: false + runs-on: ${{ matrix.os }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up cmake + uses: jwlawson/actions-setup-cmake@v2 + + - name: Setup build + run: + cmake -DRING_BUFFER_BUILD_TESTS=ON -S . -B build \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_C_STANDARD=99 \ + -DCMAKE_C_COMPILER=$([[ ${{ matrix.compiler }} == "gcc" ]] && echo "gcc" || echo "clang") \ + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ + -DCMAKE_CXX_FLAGS="-Wall -Wextra -Wpedantic" \ + -DCMAKE_C_FLAGS="-Wall -Wextra -Wpedantic" + + - name: Build + run: cmake --build build --config Debug + + - name: Run tests + run: | + # search for all executables in build/test/test-* + find build/test -type f -executable -name 'test-*' -exec sh -c 'echo "Running test: $1"; $1' _ {} \; \ No newline at end of file