From 295ac39489b76a88a4660927fca7e4816eed6d25 Mon Sep 17 00:00:00 2001 From: Dimitri Sifoua Date: Thu, 18 Jan 2024 01:21:40 -0500 Subject: [PATCH] Setup CI (unit tests) (#1) * Setup CI (unit tests) * Add build status badge to README.md file. * Add code coverage --- .github/workflows/makefile-ci.yaml | 34 ++++++++++++++++++++++++++++++ README.md | 1 + build.gradle | 26 +++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 .github/workflows/makefile-ci.yaml diff --git a/.github/workflows/makefile-ci.yaml b/.github/workflows/makefile-ci.yaml new file mode 100644 index 0000000..643f2d5 --- /dev/null +++ b/.github/workflows/makefile-ci.yaml @@ -0,0 +1,34 @@ +name: Makefile CI +on: + push: + branches: + - master + - develop + - feature/** + - ci/** + pull_request: + branches: + - master + - develop + - feature/** + - ci/** +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup JDK + uses: actions/setup-java@v3 + with: + java-version: "20.0.1" + distribution: "temurin" + server-id: github + settings-path: ${{ github.workspace }} + - name: Unit Tests + run: ./gradlew test + - name: Code Coverage + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + fail_ci_if_error: false diff --git a/README.md b/README.md index fadb47a..08e9857 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Leetcode - Java +[![Makefile CI](https://github.com/dksifoua/leetcode/actions/workflows/makefile-ci.yaml/badge.svg)](https://github.com/dksifoua/leetcode/actions/workflows/makefile-ci.yaml) ## Types of data structures diff --git a/build.gradle b/build.gradle index 5679ad0..90b4cb8 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ plugins { id 'java' + id 'jacoco' } group = 'io.dksifoua' @@ -16,4 +17,29 @@ dependencies { test { useJUnitPlatform() + finalizedBy jacocoTestReport +} + +jacoco { + toolVersion = "0.8.9" + reportsDirectory = layout.buildDirectory.dir("reports/jacoco") +} + +jacocoTestReport { + dependsOn test + + reports { + xml.required = true + html.required = true + } +} + +jacocoTestCoverageVerification { + violationRules { + rule { + limit { + minimum = 0.5 + } + } + } } \ No newline at end of file