From 26dfa76faa883c35fe3e5ff4b2b33f4102059a81 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov <0x7fffff@guattari.ru> Date: Fri, 5 Aug 2022 21:17:16 +0400 Subject: Async function & unit-testing --- .github/workflows/build_and_test.yml | 120 +++++++++++++++++++++++++++++++++++ .github/workflows/cleanup.yml | 21 ++++++ 2 files changed, 141 insertions(+) create mode 100644 .github/workflows/build_and_test.yml create mode 100644 .github/workflows/cleanup.yml (limited to '.github/workflows') diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml new file mode 100644 index 0000000..50aad28 --- /dev/null +++ b/.github/workflows/build_and_test.yml @@ -0,0 +1,120 @@ +name: Build and test + +on: + push: + branches: [ dev, stable ] + pull_request: + branches: [ dev, stable ] + schedule: + - cron: '0 0 */16 * *' + workflow_dispatch: + +env: + BUILD_TYPE: Debug + +jobs: + build: + strategy: + matrix: + os: [ ubuntu-latest, macos-latest, windows-2019 ] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + + - name: Set up CMake 3.18 + uses: jwlawson/actions-setup-cmake@v1.8 + with: + cmake-version: 3.18 + + - name: Install gcovr + if: runner.os != 'Windows' + run: | + python3 -m pip install gcovr==5.0 + + - name: Install OpenCppCoverage + if: runner.os == 'Windows' + shell: bash + run: | + choco install opencppcoverage + echo "C:/Program Files/OpenCppCoverage" >> $GITHUB_PATH + + - name: Build + if: runner.os != 'Windows' + run: | + cmake -D CMAKE_BUILD_TYPE=$BUILD_TYPE -B build -S . + cmake --build build --config $BUILD_TYPE + + - name: Build with Visual Studio + if: runner.os == 'Windows' + shell: bash + run: | + cmake -B build -S . + cmake --build build --config $BUILD_TYPE + + - name: Run tests & generate coverage on Linux + if: runner.os == 'Linux' + working-directory: ${{ github.workspace }}/build + run: | + ctest -V -C $BUILD_TYPE + gcovr --gcov-executable gcov-11 -j $(nproc) --delete --root ../source/ --exclude '\.\./source/test/' --print-summary --xml-pretty --xml coverage.xml . + + - name: Run tests & generate coverage on macOS + if: runner.os == 'macOS' + working-directory: ${{ github.workspace }}/build + run: | + ctest -V -C $BUILD_TYPE + gcovr --gcov-executable gcov-11 -j 2 --delete --root ../source/ --exclude '\.\./source/test/' --print-summary --xml-pretty --xml coverage.xml . + + - name: Run tests & generate coverage on Windows + if: runner.os == 'Windows' + shell: bash + working-directory: ${{ github.workspace }}/build + run: | + OpenCppCoverage.exe --sources source\\* --excluded_sources source\\test\\* --export_type cobertura:coverage.xml --cover_children -- ctest -V -C $BUILD_TYPE + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2 + with: + files: ./build/coverage.xml + flags: ${{ runner.os }} + name: ${{ runner.os }} build + fail_ci_if_error: false + + integration: + strategy: + matrix: + os: [ ubuntu-latest, macos-latest, windows-2019 ] + name: [ fetch_content, find_package ] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + + - name: Set up CMake 3.18 + uses: jwlawson/actions-setup-cmake@v1.8 + with: + cmake-version: 3.18 + + - name: Build with GCC + if: runner.os != 'Windows' + run: | + cmake -D CMAKE_BUILD_TYPE=$BUILD_TYPE -B build -S . + cmake --build build --config $BUILD_TYPE + working-directory: ./source/test/integration/${{ matrix.name }} + + - name: Build with Visual Studio + if: runner.os == 'Windows' + shell: bash + run: | + cmake -B build -S . + cmake --build build --config $BUILD_TYPE + working-directory: ./source/test/integration/${{ matrix.name }} + + - name: Run + shell: bash + run: | + ctest -V -C $BUILD_TYPE + working-directory: ./source/test/integration/${{ matrix.name }}/build diff --git a/.github/workflows/cleanup.yml b/.github/workflows/cleanup.yml new file mode 100644 index 0000000..74e8d4a --- /dev/null +++ b/.github/workflows/cleanup.yml @@ -0,0 +1,21 @@ +name: Cleanup + +on: + schedule: + - cron: '0 0 */16 * *' + workflow_dispatch: + +jobs: + delete_runs: + permissions: + actions: write + runs-on: ubuntu-latest + + steps: + - name: Delete workflow runs + uses: Mattraks/delete-workflow-runs@main + with: + token: ${{ secrets.GITHUB_TOKEN }} + repository: ${{ github.repository }} + retain_days: 30 + keep_minimum_runs: 4 -- cgit v1.2.3