Switch forEach loop to for of syntax
[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 workflow_dispatch:
9 inputs:
10 withBenchmark:
11 description: 'With Benchmark?'
12 default: false
13
14 jobs:
15 build:
16 runs-on: ${{ matrix.os }}
17
18 strategy:
19 matrix:
20 os: [windows-latest, macos-latest, ubuntu-latest]
21 node: ['16.x', '18.x', '19.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: Setup node ${{ matrix.node }}
30 uses: actions/setup-node@v3
31 with:
32 node-version: ${{ matrix.node }}
33
34 - name: Install
35 run: npm ci
36
37 - name: Build
38 run: npm run build --if-present
39
40 - name: Lint
41 run: npm run lint
42
43 - name: Tests
44 run: npm run test
45
46 - name: Coverage Report
47 if: "github.repository == 'poolifier/poolifier' && matrix.os == 'ubuntu-latest' && matrix.node == '18.x'"
48 run: npm run coverage
49
50 - name: Sonar Code Analysis
51 if: "github.repository == 'poolifier/poolifier' && matrix.os == 'ubuntu-latest' && matrix.node == '18.x'"
52 uses: sonarsource/sonarcloud-github-action@master
53 env:
54 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
55 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
56
57 - name: Benchmark
58 if: github.event.inputs.withBenchmark
59 run: npm run benchmark