Only run GitHub CI code coverage when needed
[e-mobility-charging-stations-simulator.git] / .github / workflows / ci.yml
1 name: CI
2 on:
3 push:
4 branches:
5 - main
6 pull_request:
7 types: [opened, synchronize, reopened]
8 jobs:
9 build:
10 runs-on: ${{ matrix.os }}
11 strategy:
12 matrix:
13 os: [windows-latest, macos-latest, ubuntu-latest]
14 node: ['14.x', '16.x', '18.x']
15 steps:
16 - uses: actions/checkout@v3
17 with:
18 fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
19 - name: Use Node.js ${{ matrix.node }}
20 uses: actions/setup-node@v3
21 with:
22 node-version: ${{ matrix.node }}
23 - name: npm install
24 run: npm ci
25 - name: npm run lint
26 run: npm run lint
27 continue-on-error: true
28 - name: npm run build
29 run: npm run build
30 - name: npm test
31 run: npm test
32 - name: npm run coverage
33 if: "github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '16.x'"
34 run: npm run coverage
35 - name: SonarCloud Scan
36 if: "github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '16.x'"
37 uses: sonarsource/sonarcloud-github-action@master
38 env:
39 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
40 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
41 build-docker:
42 runs-on: ubuntu-latest
43 steps:
44 - uses: actions/checkout@v3
45 - name: Set up Docker Buildx
46 id: buildx
47 uses: docker/setup-buildx-action@v2
48 - name: Build docker image
49 run: |
50 cd docker
51 make SUBMODULES_INIT=false