Add cross OS CI tests
[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:
5082a5a8 17 runs-on: ${{ matrix.node }}
ac0fc89e
S
18
19 strategy:
20 matrix:
5082a5a8 21 os: [windows-latest, macos-latest, ubuntu-latest]
50a18c89 22 node: ['14.x', '16.x', '18.x']
ac0fc89e
S
23
24 steps:
25 - name: Checkout
5080f39d 26 uses: actions/checkout@v3
515e5da7
APA
27 with:
28 fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis. This is needed for better sonar
ac0fc89e 29
5080f39d
JB
30 - name: Set node version to ${{ matrix.node }}
31 uses: actions/setup-node@v3
ac0fc89e 32 with:
5080f39d 33 node-version: ${{ matrix.node }}
ac0fc89e
S
34
35 - name: Install
a357cd2d 36 run: npm ci
ac0fc89e
S
37
38 - name: Build
39 run: npm run build --if-present
40
777b7824
S
41 - name: Lint
42 run: npm run lint
43
515e5da7 44 - name: Tests & Coverage
63f0e1ff 45 if: matrix.node == '16.x'
777b7824 46 run: |
ac0fc89e 47 npm run test
ac0fc89e 48 npm run coverage
7d82d90e 49 npm run lint:report
ac0fc89e
S
50 env:
51 CI: true
253f3064 52
515e5da7 53 - name: Sonar Code Analysis
5080f39d 54 if: "github.repository == 'poolifier/poolifier' && matrix.node == '16.x'"
645d9208 55 uses: sonarsource/sonarcloud-github-action@master
515e5da7 56 env:
2ba4f142 57 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
515e5da7
APA
58 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
59
253f3064
S
60 - name: Benchmark
61 if: github.event.inputs.withBenchmark
62 run: npm run benchmark