Skip to content

Commit

Permalink
Update sonar.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
jihuayu authored Mar 14, 2024
1 parent fd88c8b commit 1c08324
Showing 1 changed file with 19 additions and 31 deletions.
50 changes: 19 additions & 31 deletions .github/workflows/sonar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ jobs:
run: |
./x.py build -j$(nproc) --compiler gcc --skip-build
- name: Run sonar-scanner(PUSH)
if: github.event_name != 'pull_request'
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
Expand All @@ -79,35 +78,24 @@ jobs:
REF=$(jq -r '.ref | select (.!=null)' sonarcloud-data/github-event.json)
echo "The PR number is $PR_NUMBER, ref is $REF, head ref is $HEAD_REF, base ref is $BASE_REF"
sonar-scanner \
--define sonar.cfamily.build-wrapper-output="sonarcloud-data" \
--define sonar.coverageReportPaths=sonarcloud-data/coverage.xml \
--define sonar.projectKey=jihuayu_kvrocks-test \
--define sonar.organization=jihuayu \
--define sonar.scm.revision=${{ github.event.workflow_run.head_sha }}
- name: Run sonar-scanner(PR)
if: github.event_name == 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONARCLOUD_TOKEN }}
run: |
PR_NUMBER=$(jq -r '.number | select (.!=null)' sonarcloud-data/github-event.json)
HEAD_REF=$(jq -r '.pull_request.head.ref | select (.!=null)' sonarcloud-data/github-event.json)
BASE_REF=$(jq -r '.pull_request.base.ref | select (.!=null)' sonarcloud-data/github-event.json)
REF=$(jq -r '.ref | select (.!=null)' sonarcloud-data/github-event.json)
echo "The PR number is $PR_NUMBER, ref is $REF, head ref is $HEAD_REF, base ref is $BASE_REF"
git fetch upstream
sonar-scanner \
--define sonar.cfamily.build-wrapper-output="sonarcloud-data" \
--define sonar.coverageReportPaths=sonarcloud-data/coverage.xml \
--define sonar.projectKey=jihuayu_kvrocks-test \
--define sonar.organization=jihuayu \
--define sonar.scm.revision=${{ github.event.workflow_run.head_sha }} \
--define sonar.pullrequest.key=$PR_NUMBER \
--define sonar.pullrequest.branch=$HEAD_REF \
--define sonar.pullrequest.base=upstream/unstable
if [ -n "$PR_NUMBER" ]; then
sonar-scanner \
--define sonar.cfamily.build-wrapper-output="sonarcloud-data" \
--define sonar.coverageReportPaths=sonarcloud-data/coverage.xml \
--define sonar.projectKey=jihuayu_kvrocks-test \
--define sonar.organization=jihuayu \
--define sonar.scm.revision="${{ github.event.workflow_run.head_sha }}" \
--define sonar.pullrequest.key="$PR_NUMBER" \
--define sonar.pullrequest.branch="$HEAD_REF" \
--define sonar.pullrequest.base=upstream/unstable
else
sonar-scanner \
--define sonar.cfamily.build-wrapper-output="sonarcloud-data" \
--define sonar.coverageReportPaths=sonarcloud-data/coverage.xml \
--define sonar.projectKey=jihuayu_kvrocks-test \
--define sonar.organization=jihuayu \
--define sonar.scm.revision="${{ github.event.workflow_run.head_sha }}"
fi

0 comments on commit 1c08324

Please sign in to comment.