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