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

feat: ASC-18278 - Implement Sonar Scan #40

Open
wants to merge 3 commits into
base: develop
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
52 changes: 52 additions & 0 deletions .github/actions/sonar-scan/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: SonarCloud Scan
description: SonarCloud Scan action.

inputs:
SONAR_SCANNER_VERSION:
description: SonarCloud Scanner version
default: 5.0.1.3006
SONAR_HOST:
description: SonarCloud Scanner version
default: https://sonarcloud.io
SONAR_TOKEN:
description: SonarCloud user token
required: true
SONAR_ScanningDirectory:
description: Base Directory for Scanner
SONAR_QualityGate_Wait:
description: SonarCloud Scanner wait for QualityGate
default: 'false'
SONAR_QualityGate_Timeout:
description: SonarCloud Scanner QualityGate polling timeout
default: '3000'
NODE_VERSION:
description: Node version
default: '18'

runs:
using: composite
steps:
# Install SonarCloud Scanner
- name: Install SonarCloud Scanner
shell: bash
run: |
export SONAR_SCANNER_VERSION=${{ inputs.SONAR_SCANNER_VERSION }}
export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
export PATH=$SONAR_SCANNER_HOME/bin:$PATH
export SONAR_SCANNER_OPTS="-server"

# Run the SonarCloud scan
- name: SonarCloud Scan
working-directory: ${{ inputs.SONAR_ScanningDirectory }}
shell: bash
run: |
export SONAR_SCANNER_VERSION=${{ inputs.SONAR_SCANNER_VERSION }}
export SONAR_SCANNER_BIN=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux/bin
$SONAR_SCANNER_BIN/sonar-scanner \
-Dsonar.host.url=${{ inputs.SONAR_HOST }} \
-Dsonar.token=${{ inputs.SONAR_TOKEN }} \
-Dsonar.projectBaseDir=${{ inputs.SONAR_ScanningDirectory }} \
-Dsonar.qualitygate.wait=${{ inputs.SONAR_QualityGate_Wait }} \
-Dsonar.qualitygate.timeout=${{ inputs.SONAR_QualityGate_Timeout }}
25 changes: 25 additions & 0 deletions .github/workflows/testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,28 @@ jobs:

- name: eslint checks
run: pnpm run lint

- name: cache test results
uses: actions/cache@v3
with:
path: ./*
key: ${{ github.sha }}

sonar-scan:
runs-on: ubuntu-latest
name: Sonar scan

needs: [unit_tests]

steps:
- name: checkout repository
uses: actions/cache@v3
id: repo
with:
path: ./*
key: ${{ github.sha }}

- name: Sonar scan
uses: ./.github/actions/sonar-scan
with:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/
build/
dist/
storybook-build/
.idea/

Expand All @@ -8,4 +9,8 @@ storybook-build/
.DS_Store
.eslintcache

dist/
# Test Coverage Results
coverage/

# Sonar-Scanner
.scannerwork/
8 changes: 8 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sonar.projectKey=amity-social-cloud-UIKit-web-opensource
sonar.organization=amityco
sonar.projectName=Amity Social Cloud: UIKit Web Opensource
sonar.sources=./src
sonar.test=./tests
sonar.exclusions = **/*.java,**/node_modules/**,**/*.spec.ts,**/*.spec.tsx,**/*.spec.js,**/*.spec.jsx,**/*.stories.tsx,**/*.stories.ts,**/*.stories.js,**/*.stories.js,scripst/**,coverage/**
sonar.test.inclusions=**/*.spec.ts
sonar.javascript.lcov.reportPaths=**/lcov.info
3 changes: 3 additions & 0 deletions tests/000-always-pass.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test('Always Pass', () => {
expect(true).toBe(true);
});
Loading