Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: setup quality checks #148

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

OmarAlJarrah
Copy link
Contributor

@OmarAlJarrah OmarAlJarrah commented Dec 23, 2024

Situation

At the moment of creating the pull request, we have not yet setup quality checks on the repository.

Task

Setup quality checks with the following acceptance criteria:

  • GitHub Action: On each commit, a GitHub action will run all the quality checks and fail if any quality rules are violated.
  • Tests & Coverage: On each build, all tests shall be run, and a coverage report will be generated and uploaded such that it can be downloaded and consumed.
  • Lint: Enable lint rules similar to what we already have in our expediagroup-java-sdk repository. Project build should fail if any rules are violated.

Action

GitHub Action

We have created a new GitHub action that runs on each commit. The action will run all tests, and validate coverage threshold and code lint.

For coverage generated reports, even in case of coverage threshold violation, a report will still be generated and uploaded, where engineers can download it from the action run webpage. Look the artifacts section in the image below:
image

Coverage

We have modified the already existing configuration of kover to verify coverage generate HTML reports.

html {
    htmlDir = file("$buildDir/reports/kover")
}

As agreed on with @Mohammad-Dwairi, we have setup the minimum coverage value to the current coverage state of the repository. The value shall be updated till we reach a 100.

verify {
    rule {
        disabled = false
        bound {
            minValue = 56
        }
    }
}

Lint

We have used the ktlint-gradle plugin to trigger running ktlint verification on the repository. We have ignored any automatically generated files.

filter {
    include("**/*.kt")

    exclude(
            "**/generated/**",
            "**/com/expediagroup/sdk/lodgingconnectivity/**/adapter/**",
            "**/com/expediagroup/sdk/lodgingconnectivity/**/fragment/**",
            "**/com/expediagroup/sdk/lodgingconnectivity/**/operation/**",
    )

    exclude {
        element -> element.file.path.contains("generated/") // for generated sources outside the code dir.
    }
}

Testing

NaN

Results

Now the repository has rules that can verify certain qualities (tests are running, coverage is satisfied, code style is proper). These rules are run per push event.

Notes

Due to new lint rules proposal, we have run automatic linting on the repository, resulting in many files being changed. The only files that were modified manually are:

  • .github/workflows/code-quality-checks.yaml
  • code/build.gradle
  • code/tasks-gradle/lint.gradle
  • code/tasks-gradle/test.gradle

@OmarAlJarrah OmarAlJarrah requested a review from a team as a code owner December 23, 2024 14:38
@OmarAlJarrah OmarAlJarrah requested a review from mohnoor94 January 7, 2025 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants