diff --git a/.github/workflows/sonar-analysis.yml b/.github/workflows/sonar-analysis.yml new file mode 100644 index 00000000..c54798f0 --- /dev/null +++ b/.github/workflows/sonar-analysis.yml @@ -0,0 +1,47 @@ +name: SonarCloud code analysis + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + runs-on: windows-latest + + env: + BUILD_WRAPPER_OUT_DIR: build_wrapper_output_directory + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + + - name: Install node-gyp + run: npm install -g node-gyp + + - name: Install Build Wrapper + uses: SonarSource/sonarqube-scan-action/install-build-wrapper@v5 + + - name: Run Build Wrapper + run: build-wrapper-win-x86-64.exe --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} node-gyp configure build + + - run: ls ${{ env.BUILD_WRAPPER_OUT_DIR }} + - run: cat ${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json + - run: cat ${{ env.BUILD_WRAPPER_OUT_DIR }}/build-wrapper.log + - run: cat ${{ env.BUILD_WRAPPER_OUT_DIR }}/build-wrapper-dump.json + + - name: SonarQube Scan + uses: SonarSource/sonarqube-scan-action@v5 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + with: + args: > + --define sonar.cfamily.compile-commands="${{ env.BUILD_WRAPPER_OUT_DIR }}/compile_commands.json" + + diff --git a/.gitignore b/.gitignore index bc299f21..f866b1f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /.env /.vscode /addon.node +/bin /build /dist /examples/tmp diff --git a/package.json b/package.json index 7ef35f1e..8e2ee658 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,10 @@ "========== Build ==========": "", "clean": "node-gyp clean", "build:gyp": "node-gyp configure build", - "build:ts": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json", "config:gyp": "python gyp.config.py", - "build": "python gyp.config.py && node-gyp clean && node-gyp configure build && yarn build:ts", + "build:addon": "python gyp.config.py && node-gyp clean && node-gyp configure build", + "build:ts": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json", + "build": "npm run build:addon && npm run build:ts", "========== Linter ==========": "", "format": "prettier . --write", "========== Examples ==========": "", diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..5add1165 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,2 @@ +sonar.projectKey=internxt_node-win +sonar.organization=internxt