1+ name : Manual SonarCloud Analysis
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ pr_id :
7+ description : ' Pull Request ID to analyze'
8+ required : true
9+ type : string
10+
11+ jobs :
12+ sonar-analysis :
13+ name : SonarCloud Analysis for PR
14+ runs-on : ubuntu-latest
15+
16+ steps :
17+ - name : Get PR details
18+ id : pr
19+ uses : actions/github-script@v7
20+ with :
21+ script : |
22+ const pr = await github.rest.pulls.get({
23+ owner: context.repo.owner,
24+ repo: context.repo.repo,
25+ pull_number: ${{ inputs.pr_id }}
26+ });
27+ core.setOutput('head_ref', pr.data.head.ref);
28+ core.setOutput('base_ref', pr.data.base.ref);
29+ core.setOutput('head_sha', pr.data.head.sha);
30+
31+ - uses : actions/checkout@v4
32+ with :
33+ ref : ${{ steps.pr.outputs.head_sha }}
34+ fetch-depth : 0
35+
36+ - name : Use Node.js 22.x
37+ uses : actions/setup-node@v4
38+ with :
39+ node-version : 22.x
40+
41+ - name : Install dependencies
42+ run : npm ci
43+
44+ - name : Start MongoDB
45+ uses :
supercharge/[email protected] 46+ with :
47+ mongodb-version : 8.0
48+
49+ - name : Lint
50+ run : npm run lint
51+
52+ - name : Run tests
53+ run : npm test
54+ env :
55+ NODE_OPTIONS : " --experimental-vm-modules"
56+ MONGODB_URI : mongodb://127.0.0.1:27017/switcher-api-test
57+ JWT_CLIENT_TOKEN_EXP_TIME : 5m
58+ JWT_SECRET : ${{ secrets.JWT_SECRET }}
59+ RELAY_BYPASS_HTTPS : true
60+ RELAY_BYPASS_VERIFICATION : true
61+ METRICS_ACTIVATED : true
62+ MAX_REQUEST_PER_MINUTE : 0
63+ SWITCHER_API_ENABLE : false
64+ SWITCHER_API_LOGGER : false
65+
66+ - name : SonarCloud Scan
67+ uses :
sonarsource/[email protected] 68+ env :
69+ SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
70+ if : env.SONAR_TOKEN != ''
71+ with :
72+ args : >
73+ -Dsonar.pullrequest.key=${{ inputs.pr_id }}
74+ -Dsonar.pullrequest.branch=${{ steps.pr.outputs.head_ref }}
75+ -Dsonar.pullrequest.base=${{ steps.pr.outputs.base_ref }}
0 commit comments