forked from EnterpriseDB/tpa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SonarQube Scan workflow to our workflows
This initial implementation is limited to Python-only in code coverage. SonarQube does not have YAML or Ansible language support so we might need to revisit this topic with another approach. Currently, it scans the project following the guidelines recommended by EDB platform team with a newly added SonarQube workflow. Closes #318
- Loading branch information
Showing
5 changed files
with
79 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[run] | ||
omit = lib/tests/* |
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,37 @@ | ||
name: SonarQube Scan | ||
on: | ||
pull_request: | ||
branches: [ master ] | ||
push: | ||
branches: [ master ] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
jobs: | ||
sonarQube: | ||
name: SonarQube-Job | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout source repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Checkout GitHub Action Repo | ||
uses: actions/checkout@master | ||
with: | ||
repository: EnterpriseDB/edb-github-actions.git | ||
ref: master | ||
token: ${{ secrets.REPO_ACCESS_TOKEN }} | ||
path: .github/actions/edb-github-actions | ||
- name: SonarQube Scan | ||
uses: ./.github/actions/edb-github-actions/sonarqube | ||
with: | ||
REPO_NAME: '${{github.event.repository.name}}' | ||
SONAR_PROJECT_KEY: '${{secrets.SONARQUBE_PROJECTKEY}}' | ||
SONAR_URL: '${{secrets.SONARQUBE_URL}}' | ||
SONAR_LOGIN: '${{secrets.SONARQUBE_LOGIN}}' | ||
PULL_REQUEST_KEY: '${{github.event.number}}' | ||
PULL_REQUEST_BRANCH: '${{github.head_ref}}' | ||
PULL_REQUEST_BASE_BRANCH: '${{github.base_ref}}' | ||
REPO_DEFAULT_BRANCH: '${{github.event.repository.default_branch}}' | ||
REPO_EXCLUDE_FILES: '**/lib/tests/**,**/docs/**/*' |
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,30 @@ | ||
#!/bin/bash | ||
|
||
|
||
########################## | ||
# Setup build environment | ||
########################## | ||
SetupEnv(){ | ||
echo "Install Requirements" | ||
sudo apt-get -y install python3-pip libpq-dev python3-dev | ||
sudo apt install python3.8-venv | ||
sudo python3 -m pip install --upgrade pip | ||
sudo python3 -m pip install tox | ||
} | ||
|
||
|
||
################## | ||
# Generate reports | ||
################## | ||
GenerateReports(){ | ||
|
||
echo "Create Coverage report" | ||
python3 -m tox -e py38-test | ||
} | ||
|
||
|
||
######## | ||
# Main | ||
######## | ||
SetupEnv | ||
GenerateReports |
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,5 @@ | ||
sonar.python.coverage.reportPaths=coverage-reports/coverage.xml | ||
sonar.python.xunit.reportPath=coverage-reports/results.xml | ||
sonar.coverage.exclusions=**/lib/tests/**/*.*, **/docs/**/*.* | ||
sonar.exclusions=**/docs/**/*.* | ||
sonar.test.exclusions=**/lib/tests/**/*.* |
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