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