Skip to content

Commit

Permalink
Dat 10564 (#73)
Browse files Browse the repository at this point in the history
* fix(sonar-test-scan.yml): add installation of sqlcmd to setup docker step for MacOS compatibility
refactor(sonar-test-scan.yml): remove installation of sqlplus for integration tests as it is no longer needed
refactor(sonar-test-scan.yml): remove unnecessary environment variable exports and sourcing of bash profile in SonarCloud step

* chore(sonar-test-scan.yml): update runs-on field from macos-latest-xl to ubuntu-22.04 for better compatibility
feat(sonar-test-scan.yml): update mvnd installation process to download and unzip the latest release from the official Apache Maven mvnd repository
feat(sonar-test-scan.yml): add installation steps for sqlplus and instantclient for integration tests
chore(sonar-test-scan.yml): remove unnecessary setup steps for docker and sqlcmd

* chore(sonar-test-scan.yml): add support for downloading and merging integration test reports

feat(sonar-test-scan.yml): add support for downloading unit test report artifact

feat(sonar-test-scan.yml): add support for downloading integration test report artifacts for different databases (mssql, mysql, oracle, postgresql)

chore(sonar-test-scan.yml): remove unnecessary step to install mvnd

chore(sonar-test-scan.yml): remove unnecessary step to install sqlplus for integration tests

chore(sonar-test-scan.yml): cache SonarCloud packages to improve build performance

chore(sonar-test-scan.yml): merge integration and unit tests reports before running Sonar Scan

* chore(sonar-test-scan.yml): add optional coverageModuleName input to specify the name of the coverage module
fix(sonar-test-scan.yml): fix the directory change command to use the coverageModuleName input value instead of a hardcoded value

* fix(sonar-test-scan.yml): fix typo in mvn command to merge integration and unit tests reports
feat(sonar-test-scan.yml): add separate mvn command to merge jacoco results for better clarity and maintainability

* chore(sonar-test-scan.yml): update Maven settings.xml action to version v21 for compatibility and potential bug fixes

* fix(sonar-test-scan.yml): remove duplicate 'mvn' command in the 'Merge integration and unit tests reports' step

* fix(sonar-test-scan.yml): update download-artifact action to use dawidd6/[email protected] to fix compatibility issue
feat(sonar-test-scan.yml): add if_no_artifact_found: warn option to download-artifact actions to prevent failure when no artifact is found
refactor(sonar-test-scan.yml): update download artifact names to use dynamic inputs for integration test reports to improve flexibility and reusability
refactor(sonar-test-scan.yml): update download artifact names to use dynamic inputs for integration test reports to improve flexibility and reusability

* chore(sonar-test-scan.yml): update maven-settings-xml-action to v20 for Maven settings.xml setup
chore(sonar-test-scan.yml): update docker/login-action to v2 for GitHub Container Registry login
chore(sonar-test-scan.yml): update action-download-artifact to v2.27.0 for downloading integration test reports
chore(sonar-test-scan.yml): add installation steps for sqlplus and instantclient for Integration tests
chore(sonar-test-scan.yml): remove merge integration and unit tests reports step
chore(sonar-test-scan.yml): update mvn command to include ORACLE_HOME, PATH, SQLPATH, NLS_LANG, and LD_LIBRARY_PATH environment variables for Oracle integration tests

* chore(sonar-test-scan.yml): add step to save test results as artifacts if archive_test_results input is true

* chore(sonar-test-scan.yml): update Maven settings.xml action to version v21 for compatibility and potential bug fixes

* chore(sonar-test-scan.yml): remove unnecessary if condition for saving test results artifact

* chore(sonar-test-scan.yml): remove matrix variable from liquibase-integration-test-results artifact name to simplify naming convention

* chore(sonar-test-scan.yml): add optional inputs for unit test report artifact name, integration test report artifact name, and coverage module name to improve flexibility and customization
fix(sonar-test-scan.yml): remove unnecessary step to install mvnd
feat(sonar-test-scan.yml): download unit test report artifact and integration test report artifacts for mssql, mysql, oracle, and postgresql databases
feat(sonar-test-scan.yml): merge integration and unit tests reports using jacoco
feat(sonar-test-scan.yml): add step to cache SonarCloud packages for faster subsequent runs
feat(sonar-test-scan.yml): add step to perform Sonar Scan with necessary environment variables and configurations
chore(sonar-test-scan.yml): remove unnecessary step to save test results as artifacts

* fix(sonar-test-scan.yml): fix duplicate '-DskipTests' flag in the Maven command

The duplicate '-DskipTests' flag in the Maven command was causing an error. Removed the duplicate flag to fix the issue.

* fix(sonar-test-scan.yml): remove duplicate '-DskipTests' flag in the Maven command to avoid redundancy and improve readability

* chore(sonar-test-scan.yml): update java-version from 11 to 17 to use the latest version of Java for the Sonar test scan workflow

* chore(sonar-test-scan.yml): add specific paths for downloaded artifacts to improve organization and readability

* chore(sonar-test-scan.yml): improve merging and moving of test reports

The changes in this commit improve the merging and moving of test reports in the sonar-test-scan.yml workflow file.

- Added commands to list the contents of directories for debugging purposes.
- Created a new directory called "reports" to store the merged test reports.
- Moved the unit test coverage report to the "reports" directory.
- Moved the integration test coverage reports for different databases (mssql, mysql, oracle, postgresql) to the "reports" directory.
- Moved the aggregated coverage reports for different databases to the "reports" directory.
- Updated the commands to use the correct paths for moving the files.
- Added comments to explain the purpose of each command.

* chore(sonar-test-scan.yml): add ls command to list files in reports directory for debugging purposes

* chore(sonar-test-scan.yml): update download-artifact action to version 3 for unit and integration test reports
chore(sonar-test-scan.yml): remove if_no_artifact_found option from download-artifact action for integration test reports
chore(sonar-test-scan.yml): update download-artifact action for integration test reports to use correct artifact names and paths
chore(sonar-test-scan.yml): remove if_no_artifact_found option from download-artifact action for postgresql integration test report
chore(sonar-test-scan.yml): remove unnecessary whitespace

* chore(sonar-test-scan.yml): add a sleep step to wait for test reports before continuing the workflow execution
chore(sonar-test-scan.yml): update comment to disable shallow clones for better analysis relevancy
chore(sonar-test-scan.yml): add step to set up JDK for the workflow execution

* chore(sonar-test-scan.yml): update file paths for jacoco coverage reports

The file paths for the jacoco coverage reports have been updated in the sonar-test-scan.yml workflow file. The following changes were made:

- The unit test coverage report file path has been changed from "unit-tests/liquibase-pro-coverage/target/aggregate.exec" to "unit-tests/liquibase-pro-coverage/target/jacoco.exec" and it has been moved to the "./reports/jacoco-unit.exec" directory.
- The integration test coverage report file paths for mssql and mysql have been updated from "integration-tests/mssql/liquibase-pro-integration-tests/target/jacoco.exec" and "integration-tests/mysql/liquibase-pro-integration-tests/target/jacoco.exec" respectively.

* fix(sonar-test-scan.yml): fix file path for moving coverage reports to the correct directory
feat(sonar-test-scan.yml): add step to save Jacoco mixed results as an artifact for further analysis

* chore(sonar-test-scan.yml): remove unnecessary ls command in the workflow file

* fix(sonar-test-scan.yml): remove unnecessary directory creation step to simplify the workflow

The directory creation step was creating an unnecessary directory in the workflow. This step has been removed to simplify the workflow and improve readability.

* chore(sonar-test-scan.yml): update file paths for aggregated coverage reports to match new directory structure

The file paths for the aggregated coverage reports in the integration tests have been updated to match the new directory structure. The "aggregate.exec" files are now moved to the "target" directory instead of the "reports" directory. This change ensures that the coverage reports are generated in the correct location for each database type (mssql, mysql, oracle, postgresql).

* fix(sonar-test-scan.yml): update file paths for jacoco coverage reports to match the new directory structure
feat(sonar-test-scan.yml): add steps to download jacoco cli, move it to the appropriate directory, and generate coverage report using jacoco cli

* chore(sonar-test-scan.yml): reorganize build steps for better readability and maintainability
fix(sonar-test-scan.yml): move 'mvn package' command before 'mvn jacoco:merge@cli-merge-results' to ensure correct coverage results
feat(sonar-test-scan.yml): add liquibase version parameter to 'mvn package' command for better control over liquibase version used

* refactor(sonar-test-scan.yml): simplify file paths for moving jacoco coverage files

The file paths for moving jacoco coverage files were simplified to improve readability and maintainability.

* fix(sonar-test-scan.yml): update jacoco download link to use the official GitHub release URL
fix(sonar-test-scan.yml): fix the path to move jacococli.jar to the correct location

* fix(sonar-test-scan.yml): fix typo in the file path for jacococli.jar
fix(sonar-test-scan.yml): move the 'cd' command before merging jacoco results to the correct directory

* fix(sonar-test-scan.yml): fix the path to jacococli.jar in the java command to generate Jacoco report

* chore(sonar-test-scan.yml): add missing cd command to navigate to the target directory before running jacococli.jar command

* fix(sonar-test-scan.yml): remove redundant file path in java -jar command to fix jacoco report generation

The file path "./target" was duplicated in the java -jar command, causing the jacoco report generation to fail. This commit removes the redundant file path to fix the issue.

* fix(sonar-test-scan.yml): fix the path to classfiles in the jacoco report command

The path to the classfiles in the jacoco report command was incorrect. It was pointing to "../../pro/target/" instead of "../../pro/target/classes/". This fix corrects the path to ensure that the jacoco report command can find the necessary classfiles for generating the coverage report.

* chore(sonar-test-scan.yml): downgrade Java version from 17 to 8 and change distribution from 'temurin' to 'adopt' for compatibility reasons

* fix(sonar-test-scan.yml): fix classfiles path in Jacoco report command to point to the correct directory

* chore(sonar-test-scan.yml): add optional inputs for testedClassesModuleName and integrationTestsModuleName to improve flexibility
fix(sonar-test-scan.yml): update file paths to use the new inputs for testedClassesModuleName and integrationTestsModuleName
fix(sonar-test-scan.yml): update artifact name for jacoco mixed report to improve clarity

* chore(sonar-test-scan.yml): update Java version and distribution to use Java 17 with Temurin
chore(sonar-test-scan.yml): refactor file moving logic to handle different integration test directories
chore(sonar-test-scan.yml): remove unnecessary -T flag from Maven command

* fix(sonar-test-scan.yml): remove redundant line that duplicates the mvn command

The redundant line `mvn -B verify -P 'unit,!run-proguard' -Dliquibase.version=${{ inputs.liquibaseBranchName }}-SNAPSHOT` is removed to avoid duplication and improve code readability.

* chore(sonar-test-scan.yml): update action-download-artifact version to v2.27.0 for all artifact downloads
chore(sonar-test-scan.yml): add 'if_no_artifact_found: warn' option to all artifact downloads to handle missing artifacts gracefully
chore(sonar-test-scan.yml): remove unnecessary whitespace

* chore(sonar-test-scan.yml): install mvnd and use it instead of mvn for build and analysis steps

* chore(sonar-test-scan.yml): add workflow and run_id parameters to download test reports

The workflow file 'sonar-test-scan.yml' was modified to include the 'workflow' and 'run_id' parameters in the steps that download test reports. This change allows the download step to be associated with the correct workflow run and ensures that the test reports are downloaded from the correct workflow run.

* chore(sonar-test-scan.yml): update download-artifact action to version 3 for unit and integration tests reports
chore(sonar-test-scan.yml): remove unnecessary if_no_artifact_found option from download-artifact actions
chore(sonar-test-scan.yml): remove unnecessary workflow and run_id options from download-artifact actions
chore(sonar-test-scan.yml): add if: always() condition to download-artifact actions for integration tests reports
chore(sonar-test-scan.yml): add if: always() condition to cache SonarCloud packages action
chore(sonar-test-scan.yml): add if: always() condition to merge integration and unit tests reports step
chore(sonar-test-scan.yml): add if: always() condition to save Jacoco Mixed Results step
chore(sonar-test-scan.yml): add if: always() condition to Sonar Scan step

* chore(sonar-test-scan.yml): remove unnecessary sleep command in the workflow
chore(sonar-test-scan.yml): remove unused step to wait for test reports in the workflow

* chore(sonar-test-scan.yml): remove installation of mvnd and update Maven commands to use 'mvn' command instead of './mvnd/bin/mvnd'

The installation of mvnd has been removed as it is no longer needed. The Maven commands have been updated to use the 'mvn' command instead of './mvnd/bin/mvnd' for consistency and to align with standard Maven usage.

* chore(sonar-test-scan.yml): remove unused integrationTestsModuleName input variable
refactor(sonar-test-scan.yml): simplify file path for moving jacoco.exec files in integration tests

* fix(sonar-test-scan.yml): add 'package' phase to the Maven command to ensure the project is built before running SonarQube analysis

* fix(sonar-test-scan.yml): update file path for moving jacoco.exec file to improve accuracy and consistency

* fix(sonar-test-scan.yml): update file path for moving jacoco.exec file to improve accuracy and consistency

* chore(sonar-test-scan.yml): remove unnecessary artifact saving step for Jacoco mixed results
chore(sonar-test-scan.yml): rename sonar-push job to sonar-scan for better clarity and consistency

* fix(sonar-test-scan.yml): change sonar.login to sonar.token to align with SonarQube API changes and improve security

The SonarQube API has changed and now requires the use of the `sonar.token` parameter instead of `sonar.login` for authentication. This change ensures that the correct parameter is used and improves the security of the SonarQube integration.

* chore(sonar-test-scan.yml): add default value for sonar.coverage.exclusions to exclude test files and pom.xml from coverage analysis

* chore(sonar-test-scan.yml): remove unused coverageModuleName input variable
chore(sonar-test-scan.yml): update paths for merging and moving coverage reports to match new project structure
chore(sonar-test-scan.yml): update paths for jacococli.jar and classfiles in jacoco:merge step to match new project structure

* chore(sonar-test-scan.yml): download and move jacoco.exec files for h2, hsqldb, and mariadb integration tests to the appropriate directories

The changes were made to the sonar-test-scan.yml workflow file. The following changes were made:

- Added a step to download the h2 integration tests report artifact and move the jacoco.exec file to the integration-tests/h2 directory.
- Added a step to download the hsqldb integration tests report artifact and move the jacoco.exec file to the integration-tests/hsqldb directory.
- Added a step to download the mariadb integration tests report artifact and move the jacoco.exec file to the integration-tests/mariadb directory.

These changes were made to ensure that the jacoco.exec files for the h2, hsqldb, and mariadb integration tests are available in the correct directories for further processing.

* chore(sonar-test-scan.yml): add support for downloading and processing sqlite integration test reports
chore(sonar-test-scan.yml): move jacoco.exec file from sqlite integration test report to liquibase-coverage target directory

* chore(sonar-test-scan.yml): add step to download firebird integration tests report artifact
chore(sonar-test-scan.yml): move firebird jacoco.exec file to target directory for coverage analysis

* chore(create-release.yml): update sonar-push.yml version to v0.4.3 for improved functionality
chore(extension-attach-artifact-release.yml): update script file versions to v0.4.3 for improved functionality
chore(extension-release-published.yml): update extension-release-prepare.yml version to v0.4.3 for improved functionality
chore(os-extension-test.yml): update sonar-pull-request.yml version to v0.4.3 for improved functionality
chore(package-deb.yml): update file versions to v0.4.3 for improved functionality
chore(pom-release-published.yml): update extension-release-prepare.yml version to v0.4.3 for improved functionality
chore(pro-extension-test.yml): update sonar-pull-request.yml version to v0.4.3 for improved functionality

* chore(sonar-test-scan.yml): refactor Maven command to improve readability and remove unnecessary step

The Maven command in the workflow file has been refactored to improve readability and remove an unnecessary step. The `mvn clean package` command has been separated from the `mvn sonar:sonar` command. This change allows for better organization and clarity in the workflow file.

* chore(sonar-test-scan.yml): update Maven command to include package phase and exclude unnecessary profiles

The Maven command in the workflow file has been updated to include the package phase and exclude unnecessary profiles. This change ensures that the project is built and packaged before running the SonarQube analysis. The profiles '!unit', '!integration-test', '!testAll', and '!run-proguard' have been added to exclude unnecessary tests and proguard execution. This improves the efficiency of the workflow and reduces the time required for the SonarQube scan.

* chore(sonar-test-scan.yml): update Maven command to exclude unit and integration tests, and remove unused profiles

The Maven command in the Sonar test scan workflow has been updated to exclude unit and integration tests. The profiles '!unit' and '!integration-test' have been removed from the command. Additionally, the 'testAll' profile has been removed as it is not being used. The 'run-proguard' profile is still included. This change improves the accuracy of the Sonar analysis by excluding unnecessary tests.

The updated command is as follows:

```
mvn -B package sonar:sonar -P 'no-test,!run-proguard' -DskipTests -Dliquibase.version=${{ inputs.liquibaseBranchName }}-SNAPSHOT \
${{ inputs.mavenArgs  }} \
-Dsonar.scm.revision=${{ inputs.thisSha }} \
-Dsonar.token=$SONAR_TOKEN
```

* chore(sonar-test-scan.yml): remove unnecessary whitespace and improve readability of the Maven command

* feat(sonar-test-scan.yml): add support for specifying database platforms to be tested

- Add `dbPlatforms` input parameter to specify the database platforms to be tested
- Set default value of `dbPlatforms` to include `mssql`, `mysql`, `oracle`, `postgresql`, `hsqldb`
- Modify the download steps for integration test reports to conditionally download based on the specified `dbPlatforms`
- Add conditional checks for each database platform in the download steps to download the corresponding integration test report

* fix(sonar-test-scan.yml): change 'mvn package' command to 'mvn verify' to include test execution in the build process
  • Loading branch information
jandroav committed Sep 19, 2023
1 parent a1e8087 commit 2b9bdad
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions .github/workflows/sonar-test-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ on:
description: 'The name of the tested classes module'
type: string
required: false
dbPlatforms:
description: 'The database platforms to be tested'
type: string
required: false
default: mssql,mysql,oracle,postgresql,hsqldb,

env:
MAVEN_VERSION: '3.8.7'
Expand Down Expand Up @@ -120,63 +125,63 @@ jobs:
path: unit-tests

- name: Download mssql integration tests report
if: always()
if: contains(inputs.dbPlatforms, 'mssql')
uses: actions/download-artifact@v3
with:
name: ${{ inputs.integrationTestReportArtifactName }}-mssql
path: integration-tests/mssql

- name: Download mysql integration tests report
if: always()
if: contains(inputs.dbPlatforms, 'mysql')
uses: actions/download-artifact@v3
with:
name: ${{ inputs.integrationTestReportArtifactName }}-mysql
path: integration-tests/mysql

- name: Download oracle integration tests report
if: always()
if: contains(inputs.dbPlatforms, 'oracle')
uses: actions/download-artifact@v3
with:
name: ${{ inputs.integrationTestReportArtifactName }}-oracle
path: integration-tests/oracle

- name: Download postgresql integration tests report
if: always()
if: contains(inputs.dbPlatforms, 'postgresql')
uses: actions/download-artifact@v3
with:
name: ${{ inputs.integrationTestReportArtifactName }}-postgresql
path: integration-tests/postgresql

- name: Download h2 integration tests report
if: always()
if: contains(inputs.dbPlatforms, 'h2')
uses: actions/download-artifact@v3
with:
name: ${{ inputs.integrationTestReportArtifactName }}-h2
path: integration-tests/h2

- name: Download hsqldb integration tests report
if: always()
if: contains(inputs.dbPlatforms, 'hsqldb')
uses: actions/download-artifact@v3
with:
name: ${{ inputs.integrationTestReportArtifactName }}-hsqldb
path: integration-tests/hsqldb

- name: Download mariadb integration tests report
if: always()
if: contains(inputs.dbPlatforms, 'mariadb')
uses: actions/download-artifact@v3
with:
name: ${{ inputs.integrationTestReportArtifactName }}-mariadb
path: integration-tests/mariadb

- name: Download sqlite integration tests report
if: always()
if: contains(inputs.dbPlatforms, 'sqlite')
uses: actions/download-artifact@v3
with:
name: ${{ inputs.integrationTestReportArtifactName }}-sqlite
path: integration-tests/sqlite

- name: Download firebird integration tests report
if: always()
if: contains(inputs.dbPlatforms, 'firebird')
uses: actions/download-artifact@v3
with:
name: ${{ inputs.integrationTestReportArtifactName }}-firebird
Expand Down Expand Up @@ -241,7 +246,7 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
LIQUIBASE_PRO_LICENSE_KEY: ${{ secrets.PRO_LICENSE_KEY }}
run: |
mvn -B package sonar:sonar -P '!run-proguard' -DskipTests -Dliquibase.version=${{ inputs.liquibaseBranchName }}-SNAPSHOT \
mvn -B verify sonar:sonar -P 'no-test,!run-proguard' -Dliquibase.version=${{ inputs.liquibaseBranchName }}-SNAPSHOT \
${{ inputs.mavenArgs }} \
-Dsonar.scm.revision=${{ inputs.thisSha }} \
-Dsonar.token=$SONAR_TOKEN \
Expand Down

0 comments on commit 2b9bdad

Please sign in to comment.