Run PR CI on all branches
[poolifier.git] / .github / workflows / ci.yml
CommitLineData
ac0fc89e
S
1name: CI
2
3on:
4 push:
5 branches:
6 - master
4efc9472
JB
7 pull_request_target:
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:
022955bc 21 node-version: [12.x, 14.x, 16.x]
ac0fc89e
S
22
23 steps:
24 - name: Checkout
25 uses: actions/checkout@v2
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
S
28
29 - name: Set node version to ${{ matrix.node-version }}
022a17cd 30 uses: actions/setup-node@v2
ac0fc89e
S
31 with:
32 node-version: ${{ matrix.node-version }}
33
34 - name: Install
35 run: npm ci
36
37 - name: Build
38 run: npm run build --if-present
39
777b7824
S
40 - name: Lint
41 run: npm run lint
42
515e5da7 43 - name: Tests & Coverage
777b7824 44 run: |
ac0fc89e 45 npm run test
ac0fc89e
S
46 npm run coverage
47 env:
48 CI: true
253f3064 49
515e5da7 50 - name: Sonar Code Analysis
9b2fdd9f
JB
51 if: "github.repository == 'poolifier/poolifier' && matrix.node-version == '14.x'"
52 uses: SonarSource/sonarcloud-github-action@master
515e5da7 53 env:
2ba4f142 54 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
515e5da7
APA
55 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
56
253f3064
S
57 - name: Benchmark
58 if: github.event.inputs.withBenchmark
59 run: npm run benchmark