Fix npm ci with latest node.js version
[poolifier.git] / .github / workflows / ci.yml
... / ...
CommitLineData
1name: CI
2
3on:
4 push:
5 branches:
6 - master
7 pull_request:
8 types: [opened, synchronize, reopened]
9 workflow_dispatch:
10 inputs:
11 withBenchmark:
12 description: 'With Benchmark?'
13 default: false
14
15jobs:
16 build:
17 runs-on: ubuntu-latest
18
19 strategy:
20 matrix:
21 node: ['14.x', '16.x', '18.x']
22
23 steps:
24 - name: Checkout
25 uses: actions/checkout@v3
26 with:
27 fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis. This is needed for better sonar
28
29 - name: Set node version to ${{ matrix.node }}
30 uses: actions/setup-node@v3
31 with:
32 node-version: ${{ matrix.node }}
33
34 - name: Install
35 if: matrix.node == '18.x'
36 run: npm ci --legacy-peer-deps
37 if: matrix.node != '18.x'
38 run: npm ci
39
40 - name: Build
41 run: npm run build --if-present
42
43 - name: Lint
44 run: npm run lint
45
46 - name: Tests & Coverage
47 if: matrix.node-version == '16.x'
48 run: |
49 npm run test
50 npm run coverage
51 env:
52 CI: true
53
54 - name: Sonar Code Analysis
55 if: "github.repository == 'poolifier/poolifier' && matrix.node == '16.x'"
56 uses: sonarsource/sonarcloud-github-action@master
57 env:
58 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
59 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
60
61 - name: Benchmark
62 if: github.event.inputs.withBenchmark
63 run: npm run benchmark