-
Notifications
You must be signed in to change notification settings - Fork 51
68 lines (61 loc) · 2.21 KB
/
Copy pathcoverage.yml
File metadata and controls
68 lines (61 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# ⚠️ IMPORTANT: This workflow is a template from diplodoc/lint/scaffolding
# Do not edit this file in other packages - it is automatically copied from here.
# To modify this workflow, edit it in diplodoc/devops/lint/scaffolding/.github/workflows/
# and then run the scaffolding update process.
#
# This workflow is optional: it does not block merging even if it fails (continue-on-error).
name: Coverage
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main
workflow_dispatch:
jobs:
coverage:
name: Test coverage
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Node.js and install dependencies
uses: diplodoc-platform/setup-node-action@v1
with:
node-version: ${{ vars.NODE_VERSION || '24' }}
- name: Run tests with coverage
id: coverage-run
run: |
if node -e "const s=require('./package.json').scripts; process.exit(s && s['test:coverage'] ? 0 : 1)"; then
npm run test:coverage
echo "ran=true" >> "$GITHUB_OUTPUT"
else
echo "test:coverage script not found, skipping."
echo "ran=false" >> "$GITHUB_OUTPUT"
fi
- name: Upload coverage artifact
if: success() && steps.coverage-run.outputs.ran == 'true'
uses: actions/upload-artifact@v6
with:
name: coverage
path: coverage/
retention-days: 7
# Secrets aren't exposed to workflows triggered by pull_request from a fork,
# so SONAR_TOKEN is empty and SonarCloud responds with "Project not found".
# Skip the scan in that case — coverage artifact is still uploaded above.
- name: SonarCloud Scan
if: |
success() &&
steps.coverage-run.outputs.ran == 'true' &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository)
uses: SonarSource/sonarqube-scan-action@v7.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}