Skip to content
Merged
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
3 changes: 1 addition & 2 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:
jobs:
build-scan:
name: SonarCloud Scan
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
runs-on: ubuntu-latest

steps:
Expand All @@ -32,6 +31,7 @@ jobs:
uses: sonarsource/sonarqube-scan-action@v5.2.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
if: env.SONAR_TOKEN != ''

build-test:
name: Build & Test - Node ${{ matrix.node-version }} on ${{ matrix.os }}
Expand All @@ -41,7 +41,6 @@ jobs:
node-version: [16.x, 18.x, 20.x, 22.x]
os: [ ubuntu-latest, windows-latest ]
runs-on: ${{ matrix.os }}
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"

steps:
- name: Git checkout
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Manual SonarCloud Analysis

on:
workflow_dispatch:
inputs:
pr_id:
description: 'Pull Request ID to analyze'
required: true
type: string

jobs:
sonar-analysis:
name: SonarCloud Analysis for PR
runs-on: ubuntu-latest

steps:
- name: Get PR details
id: pr
uses: actions/github-script@v7
with:
script: |
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{ inputs.pr_id }}
});
core.setOutput('head_ref', pr.data.head.ref);
core.setOutput('base_ref', pr.data.base.ref);
core.setOutput('head_sha', pr.data.head.sha);

- uses: actions/checkout@v4
with:
ref: ${{ steps.pr.outputs.head_sha }}
fetch-depth: 0

- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
- run: npm install
- run: npm run lint
- run: npm test
env:
SWITCHER_API_KEY: ${{ secrets.SWITCHER_API_KEY }}

- name: SonarCloud Scan
uses: sonarsource/sonarqube-scan-action@v5.2.0
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
if: env.SONAR_TOKEN != ''
with:
args: >
-Dsonar.pullrequest.key=${{ inputs.pr_id }} \
-Dsonar.pullrequest.branch=${{ steps.pr.outputs.head_ref }} \
-Dsonar.pullrequest.base=${{ steps.pr.outputs.base_ref }}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "switcher-client",
"version": "4.4.1",
"version": "4.4.2",
"description": "Client JS SDK for working with Switcher-API",
"main": "./switcher-client.js",
"type": "module",
Expand Down Expand Up @@ -37,7 +37,7 @@
"c8": "^10.1.3",
"chai": "^5.2.1",
"env-cmd": "^10.1.0",
"eslint": "^9.30.1",
"eslint": "^9.31.0",
"mocha": "^11.7.1",
"mocha-sonarqube-reporter": "^1.0.2",
"sinon": "^21.0.0"
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sonar.projectKey=switcherapi_switcher-client-master
sonar.projectName=switcher-client-js
sonar.organization=switcherapi
sonar.projectVersion=4.4.1
sonar.projectVersion=4.4.2
sonar.links.homepage=https://github.com/switcherapi/switcher-client-js

sonar.javascript.lcov.reportPaths=coverage/lcov.info
Expand Down
4 changes: 4 additions & 0 deletions tests/switcher-integrated.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ describe('Switcher integrated test', () => {
it('should hit remote API and return Switcher response', async function () {
this.timeout(3000);

if (!process.env.SWITCHER_API_KEY) {
this.skip();
}

// given context build
Client.buildContext({
url: 'https://api.switcherapi.com',
Expand Down