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

Use latest sonar-scanner and build-wrapper on runtime #86

Merged
merged 17 commits into from
Nov 28, 2023
16 changes: 14 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ stages:
build dss_client:
stage: build
script:
# Download build wrapper from local SonarQube
- rm -rf /build-wrapper-linux-x86
- wget --no-verbose --content-disposition -E -c "$SONAR_HOST_URL/static/cpp/build-wrapper-linux-x86.zip"
- unzip -q build-wrapper-linux-x86.zip -d /
# Disable ssl verify from docker build env
- git config --global http.sslVerify false
# Download RDD deps
- ./dss_client/scripts/getrdddeps.sh
- build-wrapper-linux-x86-64 --out-dir bw-output/ ./dss_client/scripts/build.sh
# Build client with build-wrapper
- /build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output/ ./dss_client/scripts/build.sh
artifacts:
name: dss client build
expire_in: 300 seconds
Expand Down Expand Up @@ -71,7 +78,12 @@ datamover unit test:

sonar-scanner:
stage: scan
script: sonar-scanner $SONAR_BRANCH -Dsonar.python.coverage.reportPaths=$PYTEST_COV_REPORT
script:
# Download sonar-scanner from local SonarQube
- rm -rf /sonar-scanner*
- wget --no-verbose --content-disposition -E -c "https://search.maven.org/remote_content?g=org.sonarsource.scanner.cli&a=sonar-scanner-cli&v=LATEST&c=linux&e=zip"
- unzip -q sonar-scanner-cli-*.zip -d /
- /sonar-scanner-*-linux/bin/sonar-scanner $SONAR_BRANCH -Dsonar.python.coverage.reportPaths=$PYTEST_COV_REPORT
allow_failure: true
dependencies:
- datamover unit test
Expand Down
6 changes: 5 additions & 1 deletion buildspec/dss-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ phases:
commands:
# Download and extract RDD libs from prior dss-sdk target artifact for this branch
- ./dss_client/scripts/getrdddeps.sh
# Download latest build-wrapper
- rm -rf /build-wrapper-linux-x86
- wget --no-verbose --content-disposition -E -c "https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip"
- unzip -q build-wrapper-linux-x86.zip -d /
build:
commands:
# Build dss-client with Sonar build-wrapper for C/C++ static analysis
- build-wrapper-linux-x86-64 --out-dir bw-output ./dss_client/scripts/build.sh
- /build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw-output ./dss_client/scripts/build.sh
post_build:
commands:
# Copy artifacts to branch dir if this is a merge
Expand Down
9 changes: 6 additions & 3 deletions buildspec/sonar-scanner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,19 @@ phases:
- aws s3 cp --recursive "$DSSS3URI/cache/dss-ecosystem/$GITHUB_RUN_NUMBER/pytest" . --only-show-errors
# Download dss_client/build
- aws s3 cp --recursive "$DSSS3URI/cache/dss-ecosystem/$GITHUB_RUN_NUMBER/dss_client" dss_client/ --only-show-errors
# Temporary just to debug
- echo "$CODEBUILD_SRC_DIR"
# replace the old CODEBUILD_SRC_DIR with the current one in bw-output and pytest cov
- sed -i -r "s|/codebuild/output/src[^/]+/src/github.com/OpenMPDK/dss-ecosystem|$CODEBUILD_SRC_DIR|g" bw-output/build-wrapper-dump.json
- sed -i -r "s|/codebuild/output/src[^/]+/src/github.com/OpenMPDK/dss-ecosystem|$CODEBUILD_SRC_DIR|g" .coverage-reports/*.xml
# Download the latest sonar-scanner
- rm -rf /sonar-scanner*
- wget --no-verbose --content-disposition -E -c "https://search.maven.org/remote_content?g=org.sonarsource.scanner.cli&a=sonar-scanner-cli&v=LATEST&c=linux&e=zip"
- unzip -q sonar-scanner-cli-*.zip -d /
- rm -f sonar-scanner-cli*.zip
build:
commands:
# Run sonar-scanner and ingest coverage report(s)
- |
sonar-scanner \
/sonar-scanner-*-linux/bin/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 \
Expand Down