Skip to content

Commit

Permalink
added sonarscan workflow. (#566)
Browse files Browse the repository at this point in the history
* added sonarscan workflow.

* added sonarscan workflow with html output format.

* added sonar properties with html output format.

* renamed sonar-project.properties.

* Reverted renaming sonar-project.properties.

---------

Co-authored-by: Raj Burnwal <[email protected]>
  • Loading branch information
rajburnwal07 and Raj Burnwal authored Sep 24, 2024
1 parent d27d1a1 commit 0f216ea
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/sonarscan_run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Run Pebblo Scanner Tests
on:
push:
branches:
- main
schedule:
- cron: '30 2,14 * * *'

workflow_dispatch: # Activate this workflow manually
env:
PYTHON_VERSION: ${{ github.event.inputs.python_version || '3.11.x' }}
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
SLACK_CH: ${{ secrets.SLACK_CH }}
jobs:
Setup_Pebblo_Run_Tests:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v4
with:
ref: 'main'
python-version: ${{ env.PYTHON_VERSION }}

- name: Build Pebblo
run: |
pip install build
python -m build --wheel
ls -la dist/
- name: Install Pebblo Packages
run: |
echo 'Install Pebblo Package'
pkg_file=$(ls dist | grep .whl)
pip3 install dist/$pkg_file --force-reinstall
pip3 install --upgrade pip
- name: SonarCloud Scan
id: sonarqube-scan-check
uses: SonarSource/[email protected]
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

# - name: SonarQube Quality Gate check
# id: sonarqube-quality-gate-check
# uses: sonarsource/sonarqube-quality-gate-action@master
# # Force to fail step after specific time.
# timeout-minutes: 5
# env:
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}


- name: Install Sonar Report and generate
id: sonar-report-gen
run: |
echo 'Installing sonar-report NPM package.'
npm install -g sonar-report
sonar-report \
--sonarurl="https://sonarcloud.io" \
--sonarcomponent="daxa-ai_pebblo" \
--sonarorganization="daxa-ai" \
--project="daxa-ai_pebblo" \
--application="sonar-report" \
--release="1.0.0" \
--branch="main" \
--output="./pebblo_sonar.html" \
--sonartoken ${{ secrets.SONAR_TOKEN }}
- name: Upload Pebblo SonarQube report File
if: steps.sonar-report-gen.outcome == 'success'
run: |
curl -F file=@pebblo_sonar.html https://slack.com/api/files.upload -H "Authorization: Bearer $SLACK_TOKEN" -F channels=$SLACK_CH -F "initial_comment=Pebblo Sonar Scan Report"
- name: Report Status if sonarscanner failure
if: ${{ always() }} || steps.sonarqube-scan-check.outcome == 'failure'
uses: ravsamhq/notify-slack-action@master
with:
status: ${{ job.status }}
notify_when: 'failure'
message_format: "{emoji} *{workflow}* {status_message} with Scan status ${{ steps.sonarqube-scan-check.outcome }}"
env:
SLACK_WEBHOOK_URL: ${{ secrets.WEBHOOK_SECRET }}
4 changes: 4 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sonar.projectKey=daxa-ai_pebblo
sonar.organization=daxa-ai
sonar.python.version=3
sonar.dynamicAnalysis=reuseReports

0 comments on commit 0f216ea

Please sign in to comment.