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

test: change sonarqube configuration to cause job to fail when quality gate fails #1565

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 44 additions & 42 deletions .github/workflows/on-push-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,52 @@ on:
- main

jobs:
sonarqube:
name: SonarQube Trigger
runs-on: ubuntu-latest
steps:
- name: Checkout sources 🔰
uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0

- name: Setup Node.js 🧮
uses: actions/setup-node@v4
with:
node-version: 20

- name: Cache Node.js modules 💾
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-

- name: Install dependencies ⏬
run: npm ci

- name: Test code ✅
run: npm run test
env:
CI: true

- name: Get shogun-gis-client version 🔖
run: |
echo "VERSION=$(node -pe "require('./package.json').version")" >> $GITHUB_ENV

- name: SonarQube Scan 🔬
uses: kitabisa/[email protected]
with:
host: ${{ secrets.SONARQUBE_HOST }}
login: ${{ secrets.SONARQUBE_TOKEN }}
projectVersion: ${{ env.VERSION }}

build:
runs-on: ubuntu-latest
needs: sonarqube
steps:
- name: Checkout sources 🔰
uses: actions/checkout@v4
Expand Down Expand Up @@ -75,45 +119,3 @@ jobs:
run: |
docker push ${{ env.DOCKER_REGISTRY }}/shogun-gis-client-e2e-tests:main

sonarqube:
name: SonarQube Trigger
runs-on: ubuntu-latest
steps:
- name: Checkout sources 🔰
uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0

- name: Setup Node.js 🧮
uses: actions/setup-node@v4
with:
node-version: 20

- name: Cache Node.js modules 💾
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-
${{ runner.OS }}-

- name: Install dependencies ⏬
run: npm ci

- name: Test code ✅
run: npm run test
env:
CI: true

- name: Get shogun-gis-client version 🔖
run: |
echo "VERSION=$(node -pe "require('./package.json').version")" >> $GITHUB_ENV

- name: SonarQube Scan 🔬
uses: kitabisa/[email protected]
with:
host: ${{ secrets.SONARQUBE_HOST }}
login: ${{ secrets.SONARQUBE_TOKEN }}
projectVersion: ${{ env.VERSION }}
3 changes: 3 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ sonar.projectBaseDir=/home/runner/work/shogun-demo-client/shogun-demo-client
sonar.testExecutionReportPaths=./coverage/jest-report.xml
sonar.tests=src
sonar.test.inclusions=**/*.spec.tsx,**/*.spec.ts

# quality gate rules
sonar.qualitygate.wait=true