3b4c832979a963628a6094102c67b33cb20bfce9
[poolifier.git] / .github / workflows / ci.yml
1 name: CI
2
3 on:
4 push:
5 branches: [master]
6 pull_request:
7 types: [opened, synchronize, reopened]
8 merge_group:
9 branches: [master]
10
11 permissions:
12 contents: read
13 checks: read
14
15 jobs:
16 build:
17 strategy:
18 matrix:
19 os: [windows-latest, macos-latest, ubuntu-latest]
20 node: ['18.x', '20.x', '21.x']
21
22 name: Node.js ${{ matrix.node }} on ${{ matrix.os }}
23
24 runs-on: ${{ matrix.os }}
25
26 steps:
27 - name: Checkout
28 uses: actions/checkout@v4
29 with:
30 fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis. This is needed for better sonar
31
32 - name: Setup pnpm
33 uses: pnpm/action-setup@v2
34 with:
35 version: 8
36
37 - name: Setup Node.js ${{ matrix.node }}
38 uses: actions/setup-node@v4
39 with:
40 node-version: ${{ matrix.node }}
41 cache: 'pnpm'
42
43 - name: Install Dependencies
44 run: pnpm install --ignore-scripts --frozen-lockfile
45
46 - name: Build
47 run: pnpm build
48
49 - name: Lint
50 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
51 run: pnpm lint
52
53 - name: Tests
54 run: pnpm test
55
56 - name: Coverage Report
57 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
58 run: pnpm coverage
59
60 - name: Fix Coverage Report Paths
61 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
62 working-directory: ./coverage
63 run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' lcov.info
64
65 - name: Check for SonarCloud Token Availability
66 id: sonar-token
67 shell: bash
68 run: |
69 if [ "${{ secrets.SONAR_TOKEN }}" != '' ]; then
70 echo "available=true" >> $GITHUB_OUTPUT;
71 else
72 echo "available=false" >> $GITHUB_OUTPUT;
73 fi
74
75 - name: SonarCloud Code Analysis
76 if: ${{ steps.sonar-token.outputs.available == 'true' && github.repository == 'poolifier/poolifier' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
77 uses: sonarsource/sonarcloud-github-action@v2.1.1
78 env:
79 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}