diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..d00ed1c --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,30 @@ +name: Build and Test + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + build-test: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y cmake ninja-build + + - name: Configure + run: cmake --preset default + + - name: Build + run: cmake --build --preset default + + - name: Run tests + run: ctest --test-dir build --output-on-failure diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..53e7a1b --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,52 @@ +name: Code Coverage + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + coverage: + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y cmake ninja-build lcov + + - name: Configure with coverage flags + run: | + cmake -B build \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_CXX_FLAGS="--coverage" \ + -DCMAKE_C_FLAGS="--coverage" \ + -DCMAKE_EXE_LINKER_FLAGS="--coverage" + + - name: Build + run: cmake --build build + + - name: Run tests + run: ctest --test-dir build --output-on-failure + + - name: Generate coverage report + run: | + lcov --directory build --capture --output-file coverage.info + lcov --remove coverage.info \ + '/usr/*' \ + '*/googletest/*' \ + '*/vremu6502/*' \ + '*/tests/*' \ + --output-file coverage.info + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + with: + files: ./coverage.info + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: false