Skip to content

SBCOSS-489: Sunbird Knowlg-asset-enrichment - add the GitHub actions to run test cases and code quality checks when a PR raised #818

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

Merged
merged 8 commits into from
Jun 20, 2025

Conversation

chethann007
Copy link
Collaborator

This PR adds a GitHub Actions workflow for PR code coverage and quality checks to the asset-enrichment flink job of Sunbird-Knowlg repository.

PR Code Coverage

  • Triggers: When a pull request is created against any branch.
  • Functionality:
    • Builds the project
    • Runs unit tests
    • Generates a coverage report using JaCoCo
    • Performs static code analysis with SonarQube

This workflow ensures that every proposed change is validated for code quality and coverage before merging.

-the blob URL's which were in the configurations had been deleted so made the config values of test cases to be picked from env
- some of the blob values were still hardcoded and that was causing test cases to fail so made those values to be picked from configurations
- the configurations of the test cases will be now picked from env
- some of the blob values were still hardcoded and that was causing test cases to fail so made those values to be picked from configurations
- the configurations of the test cases will be now picked from env
-the blob URL's which were in the configurations had been deleted so made the config values of test cases to be picked from env
- some of the blob values were still hardcoded and that was causing test cases to fail so made those values to be picked from configurations
- the configurations of the test cases will be now picked from env
- some of the blob values were still hardcoded and that was causing test cases to fail so made those values to be picked from configurations
- the configurations of the test cases will be now picked from env
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
65.6% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR centralizes configuration for blob and schema paths in test resources and introduces a GitHub Actions workflow to enforce build, test coverage, and static analysis on PRs.

  • Tests are refactored to load base-test.conf or test.conf for dynamic blob and schema URLs instead of hard-coded values.
  • Added base-test.conf and expanded test.conf to include environment-based placeholders for blob and schema paths.
  • Introduced .github/workflows/pr-actions.yml to run Maven builds, unit tests with JaCoCo coverage, and SonarQube analysis on pull requests.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
jobs-core/src/test/scala/org/sunbird/spec/HTTPUtilSpec.scala Replaced hard-coded URLs with imagePath from base-test.conf.
jobs-core/src/test/scala/org/sunbird/spec/DefinitionCacheTestSpec.scala Switched config load to base-test.conf and injected schema.basePath.
jobs-core/src/test/resources/base-test.conf Added optional env placeholders for schema.basePath and blob.input.contentImagePath.
asset-enrichment/src/test/scala/org/sunbird/job/spec/ThumbnailSpec.scala Updated tests to use contentImagePath from config.
asset-enrichment/src/test/scala/org/sunbird/job/spec/AssetEnrichmentTaskTestSpec.scala Injected imagePath and videoPath into several test cases.
asset-enrichment/src/test/resources/test.conf Expanded to include schema.base_path, blob paths, and cloud/storage settings.
.github/workflows/pr-actions.yml New CI workflow for PRs: builds, tests with coverage, and SonarQube.
Comments suppressed due to low confidence (4)

.github/workflows/pr-actions.yml:10

  • [nitpick] Job identifier uses job-core but the module directory is jobs-core. Consider renaming to root-pom-build-and-coverage-jobs-core for consistency.
  root-pom-build-and-coverage-job-core:

jobs-core/src/test/resources/base-test.conf:52

  • Provide a default URL fallback for schema.basePath to avoid a MissingKey exception when SCHEMA_BASE_PATH isn’t set, e.g., basePath = ${?SCHEMA_BASE_PATH} "https://your.default/schema/path".
  basePath = ${?SCHEMA_BASE_PATH}

jobs-core/src/test/resources/base-test.conf:58

  • Add a default blob URL for contentImagePath so tests don’t fail when BLOB_IMAGE_CONTENT_PATH is undefined, e.g., contentImagePath = ${?BLOB_IMAGE_CONTENT_PATH} "https://default/path/to/image.png".
    contentImagePath = ${?BLOB_IMAGE_CONTENT_PATH}

asset-enrichment/src/test/scala/org/sunbird/job/spec/ThumbnailSpec.scala:26

  • Incorrect copyURLToFile signature: use FileUtils.copyURLToFile(new URL(imageUrl), new File(destinationPath)) to correctly download the file.
      val file = FileUtils.copyURLToFile("do_113233717480390656195", imageUrl, imageUrl.substring(imageUrl.lastIndexOf("/") + 1))

@pallakartheekreddy pallakartheekreddy merged commit 6dee714 into release-8.0.0 Jun 20, 2025
3 of 5 checks passed
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.

2 participants