-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests and refactor stages (#50)
* Add unit tests and refactor stages * Fix aws cp cmd * Fixes - remove test stage - add regex for CODEBUILD_SRC_DIR - add pre_build to sonar stage * fix order of artifact download * update reports dir * fix regex * Fix coverage format
- Loading branch information
Showing
5 changed files
with
92 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
version: 0.2 | ||
|
||
env: | ||
secrets-manager: | ||
DSSS3URI: Codebuild-DSS:DSSS3URI | ||
variables: | ||
DSSGLOBLIST: "nkv-sdk-*.tgz nkv-target-*.tgz" | ||
|
||
phases: | ||
build: | ||
commands: | ||
# Build dss-sdk with Sonar build-wrapper for C/C++ static analysis | ||
- build-wrapper-linux-x86-64 --out-dir bw-output ./scripts/build_all.sh kdd-samsung-remote | ||
post_build: | ||
commands: | ||
# Copy artifacts to branch dir if this is a merge | ||
- /stagemergeartifacts.sh | ||
# Copy df_out, host_out, and bw-output for later sonar-scanner stage | ||
- aws s3 cp --recursive bw-output "$DSSS3URI/cache/dss-sdk/$GITHUB_RUN_NUMBER/sonar/bw-output" --only-show-errors | ||
- aws s3 cp --recursive df_out "$DSSS3URI/cache/dss-sdk/$GITHUB_RUN_NUMBER/build/df_out" --only-show-errors | ||
- aws s3 cp --recursive host_out "$DSSS3URI/cache/dss-sdk/$GITHUB_RUN_NUMBER/build/host_out" --only-show-errors | ||
artifacts: | ||
files: | ||
- df_out/nkv-target-*.tgz | ||
- host_out/nkv-sdk-bin-*.tgz | ||
discard-paths: yes | ||
name: builds/dss-sdk/$GITHUB_RUN_NUMBER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
version: 0.2 | ||
|
||
env: | ||
secrets-manager: | ||
DSSS3URI: Codebuild-DSS:DSSS3URI | ||
|
||
phases: | ||
build: | ||
commands: | ||
# Build dss-sdk target with unit tests | ||
- ./target/build.sh --run-tests --with-coverage | ||
post_build: | ||
commands: | ||
# Copy df_out for later sonar-scanner stage | ||
- aws s3 cp --recursive df_out "$DSSS3URI/cache/dss-sdk/$GITHUB_RUN_NUMBER/unit/df_out" --only-show-errors |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
version: 0.2 | ||
|
||
env: | ||
secrets-manager: | ||
SONAR_TOKEN: Codebuild-DSS:SONAR_TOKEN | ||
DSSS3URI: Codebuild-DSS:DSSS3URI | ||
variables: | ||
SONAR_UNIT_TEST_REPORT: df_out/reports/sonar_qube_ut_coverage_report.xml | ||
|
||
phases: | ||
pre_build: | ||
commands: | ||
# Download build wrapper output from build job | ||
- aws s3 cp --recursive "$DSSS3URI/cache/dss-sdk/$GITHUB_RUN_NUMBER/sonar" . --only-show-errors | ||
# Download df_out and host_out | ||
- aws s3 cp --recursive "$DSSS3URI/cache/dss-sdk/$GITHUB_RUN_NUMBER/build" . --only-show-errors | ||
# Download unit test coverage report(s) | ||
- aws s3 cp --recursive "$DSSS3URI/cache/dss-sdk/$GITHUB_RUN_NUMBER/unit/df_out/reports/" df_out/reports/ --only-show-errors | ||
# Correct paths of target files in coverage report | ||
- sed -i -r 's/path="/path="target\//g' $SONAR_UNIT_TEST_REPORT | ||
# replace the old CODEBUILD_SRC_DIR with the current one in bw-output | ||
- sed -i -r "s|/codebuild/output/src[^/]+/src/github.com/OpenMPDK/dss-sdk|$CODEBUILD_SRC_DIR|g" bw-output/build-wrapper-dump.json | ||
build: | ||
commands: | ||
# Run sonar-scanner and ingest coverage report(s) | ||
- | | ||
sonar-scanner \ | ||
-Dsonar.branch.name="$([[ "$GITHUB_REF_NAME" != *"/merge" ]] && echo "$GITHUB_REF_NAME")" \ | ||
-Dsonar.host.url=https://sonarcloud.io \ | ||
-Dsonar.pullrequest.github.summary_comment=true \ | ||
-Dsonar.pullrequest.provider=GitHub \ | ||
-Dsonar.pullrequest.github.repository=OpenMPDK/dss-sdk \ | ||
-Dsonar.pullrequest.key=$(echo $GITHUB_REF | grep -oP "^refs/pull/\K[^/]+") \ | ||
-Dsonar.pullrequest.base=$GITHUB_BASE_REF \ | ||
-Dsonar.pullrequest.branch=$GITHUB_HEAD_REF \ | ||
-Dsonar.coverageReportPaths=$SONAR_UNIT_TEST_REPORT |