-
Notifications
You must be signed in to change notification settings - Fork 16
109 lines (90 loc) · 2.93 KB
/
main.yaml
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop, 'feature/**']
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20.15.1
cache: 'npm'
- name: Install dependency
run: npm install
- name : Run linter
run: npm run lint
tests:
strategy:
matrix:
shardIndex: [1, 2, 3, 4, 5, 6]
shardTotal: [6]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20.15.1
cache: 'npm'
- name: Install dependency
run: npm install
- name : Test
run: npx cross-env CI=true vitest --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --coverage
- run: mkdir -p coverage/lcov
- run: mkdir -p coverage/xml
- name: Move coverage report
run: mv ./tests/coverage/lcov.info coverage/lcov/${{matrix.shardIndex}}.info
- name: Move coverage report
run: mv ./test-report.xml coverage/xml/${{matrix.shardIndex}}.xml
- name: Upload artifact
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v3
with:
name: coverage-artifacts
path: coverage/
# - name: Upload blob report to GitHub Actions Artifacts
# if: ${{ !cancelled() }}
# uses: actions/upload-artifact@v4
# with:
# name: blob-report-${{ matrix.shardIndex }}
# path: .vitest-reports/*
# include-hidden-files: true
# retention-days: 1
merge-reports-and-sonar-scan:
if: ${{ !cancelled() }}
needs: [tests, lint]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download coverage artifacts
uses: actions/download-artifact@v3
with:
name: coverage-artifacts
path: coverage
- name: Run script to merge all the xml files
run: |
echo '<testExecutions version="1">' > test-report.xml
grep -vh testExecutions coverage/xml/*.xml >> test-report.xml
echo '</testExecutions>' >> test-report.xml
- name: Run script to merge all the lcov files
run: |
mkdir ./tests/coverage
cat coverage/lcov/*.info > ./tests/coverage/lcov.info
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
if: success() || failure()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}