build(deps-dev): apply updates
[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', 'latest']
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@v4
34
35 - name: Setup Node.js ${{ matrix.node }}
36 uses: actions/setup-node@v4
37 with:
38 node-version: ${{ matrix.node }}
39 cache: 'pnpm'
40
41 - name: Install Dependencies
42 run: pnpm install --ignore-scripts --frozen-lockfile
43
44 - name: Build
45 run: pnpm build
46
47 - name: Lint
48 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
49 run: pnpm lint
50
51 - name: Tests
52 run: pnpm test
53
54 - name: Coverage Report
55 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
56 run: pnpm coverage
57
58 - name: Check for SonarCloud Token Availability
59 id: sonar-token
60 shell: bash
61 run: |
62 if [ "${{ secrets.SONAR_TOKEN }}" != '' ]; then
63 echo "available=true" >> $GITHUB_OUTPUT;
64 else
65 echo "available=false" >> $GITHUB_OUTPUT;
66 fi
67
68 - name: SonarCloud Code Analysis
69 if: ${{ steps.sonar-token.outputs.available == 'true' && github.repository == 'poolifier/poolifier' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
70 uses: sonarsource/sonarcloud-github-action@v2.2.0
71 env:
72 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}