build(ci): lint the code only once
[e-mobility-charging-stations-simulator.git] / .github / workflows / ci.yml
CommitLineData
a9c0de45 1name: CI
69d993b0
JB
2on:
3 push:
a1deee04 4 branches: [main]
c4f11906 5 pull_request:
613dc1b7 6 types: [opened, synchronize, reopened]
b58224be
JB
7 merge_group:
8 branches: [main]
69d993b0
JB
9jobs:
10 build:
c1eafbfc 11 runs-on: ${{ matrix.os }}
69d993b0
JB
12 strategy:
13 matrix:
c1eafbfc 14 os: [windows-latest, macos-latest, ubuntu-latest]
4fc9b19e 15 node: ['16.x', '18.x', '20.x']
69d993b0 16 steps:
0642c3d2 17 - uses: actions/checkout@v3
e7aeea18
JB
18 with:
19 fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
e3874421
JB
20 - uses: pnpm/action-setup@v2
21 with:
22 version: 8
d5d2241e 23 - name: Setup node ${{ matrix.node }}
0642c3d2 24 uses: actions/setup-node@v3
e7aeea18 25 with:
0642c3d2 26 node-version: ${{ matrix.node }}
e3874421 27 cache: 'pnpm'
881f450c 28 - name: pnpm install
e3874421
JB
29 run: pnpm install
30 - name: pnpm lint
906ba5c5 31 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
e3874421
JB
32 run: pnpm lint
33 - name: pnpm build
34 run: pnpm build
881f450c
JB
35 - name: pnpm test
36 run: pnpm test
e3874421 37 - name: pnpm coverage
ef28112f 38 if: ${{ github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
e3874421 39 run: pnpm coverage
e7aeea18 40 - name: SonarCloud Scan
ef28112f 41 if: ${{ github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
c4afbdd5 42 uses: sonarsource/sonarcloud-github-action@v1.9.1
e7aeea18
JB
43 env:
44 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
45 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
32de5a57
LM
46 build-dashboard:
47 runs-on: ${{ matrix.os }}
48 defaults:
49 run:
ebbfbf1c 50 working-directory: ui/web
32de5a57
LM
51 strategy:
52 matrix:
53 os: [windows-latest, macos-latest, ubuntu-latest]
4fc9b19e 54 node: ['16.x', '18.x', '20.x']
32de5a57
LM
55 steps:
56 - uses: actions/checkout@v3
57 with:
58 fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
e3874421
JB
59 - uses: pnpm/action-setup@v2
60 with:
61 version: 8
d5d2241e 62 - name: Setup node ${{ matrix.node }}
32de5a57
LM
63 uses: actions/setup-node@v3
64 with:
65 node-version: ${{ matrix.node }}
e3874421 66 cache: 'pnpm'
603f1011 67 - name: pnpm install
e3874421
JB
68 run: pnpm install
69 - name: pnpm lint
906ba5c5 70 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
e3874421
JB
71 run: pnpm lint
72 - name: pnpm build
73 run: pnpm build
603f1011
JB
74 - name: pnpm test
75 run: pnpm test
2de63014 76 - name: pnpm coverage
ef28112f 77 if: ${{ github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
2de63014
JB
78 run: pnpm coverage
79 - name: SonarCloud Scan
ef28112f 80 if: ${{ github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
2de63014
JB
81 uses: sonarsource/sonarcloud-github-action@v1.9.1
82 with:
83 projectBaseDir: ui/web
84 env:
85 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
86 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
a9c0de45 87 build-docker:
4bfd22de 88 runs-on: ubuntu-latest
c168e7ad 89 steps:
0642c3d2 90 - uses: actions/checkout@v3
d5d2241e 91 - name: Setup Docker Buildx
e7aeea18 92 id: buildx
c1eafbfc 93 uses: docker/setup-buildx-action@v2
e7aeea18
JB
94 - name: Build docker image
95 run: |
96 cd docker
97 make SUBMODULES_INIT=false