build(ci): add missing git head ref to dependency review
[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 9jobs:
17cec4f7 10 build-simulator:
69d993b0
JB
11 strategy:
12 matrix:
c1eafbfc 13 os: [windows-latest, macos-latest, ubuntu-latest]
4fc9b19e 14 node: ['16.x', '18.x', '20.x']
ebb77a4c 15 name: Build simulator with Node ${{ matrix.node }} on ${{ matrix.os }}
916678e9 16 runs-on: ${{ matrix.os }}
69d993b0 17 steps:
49722c24 18 - uses: actions/checkout@v4
e7aeea18
JB
19 with:
20 fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
76ec7220 21 - name: 'Dependency Review'
d533628f 22 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
76ec7220 23 uses: actions/dependency-review-action@v3
b131d478
JB
24 with:
25 base-ref: main
cc92c810 26 head-ref: ${{ github.sha }}
e3874421
JB
27 - uses: pnpm/action-setup@v2
28 with:
29 version: 8
d5d2241e 30 - name: Setup node ${{ matrix.node }}
0642c3d2 31 uses: actions/setup-node@v3
e7aeea18 32 with:
0642c3d2 33 node-version: ${{ matrix.node }}
e3874421 34 cache: 'pnpm'
881f450c 35 - name: pnpm install
916678e9 36 run: pnpm install --ignore-scripts
e3874421 37 - name: pnpm lint
906ba5c5 38 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
e3874421
JB
39 run: pnpm lint
40 - name: pnpm build
41 run: pnpm build
881f450c
JB
42 - name: pnpm test
43 run: pnpm test
e3874421 44 - name: pnpm coverage
ef28112f 45 if: ${{ github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
e3874421 46 run: pnpm coverage
e7aeea18 47 - name: SonarCloud Scan
ef28112f 48 if: ${{ github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
25b607de 49 uses: sonarsource/sonarcloud-github-action@v2.0.1
e7aeea18 50 env:
18b41d7e 51 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
e7aeea18 52 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
32de5a57 53 build-dashboard:
32de5a57
LM
54 strategy:
55 matrix:
56 os: [windows-latest, macos-latest, ubuntu-latest]
4fc9b19e 57 node: ['16.x', '18.x', '20.x']
ebb77a4c 58 name: Build dashboard with Node ${{ matrix.node }} on ${{ matrix.os }}
916678e9
JB
59 runs-on: ${{ matrix.os }}
60 defaults:
61 run:
62 working-directory: ui/web
32de5a57 63 steps:
49722c24 64 - uses: actions/checkout@v4
32de5a57
LM
65 with:
66 fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
76ec7220 67 - name: 'Dependency Review'
d533628f 68 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
76ec7220 69 uses: actions/dependency-review-action@v3
b131d478
JB
70 with:
71 base-ref: main
cc92c810 72 head-ref: ${{ github.sha }}
e3874421
JB
73 - uses: pnpm/action-setup@v2
74 with:
75 version: 8
d5d2241e 76 - name: Setup node ${{ matrix.node }}
32de5a57
LM
77 uses: actions/setup-node@v3
78 with:
79 node-version: ${{ matrix.node }}
e3874421 80 cache: 'pnpm'
603f1011 81 - name: pnpm install
916678e9 82 run: pnpm install --ignore-scripts
e3874421 83 - name: pnpm lint
906ba5c5 84 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
e3874421
JB
85 run: pnpm lint
86 - name: pnpm build
87 run: pnpm build
603f1011
JB
88 - name: pnpm test
89 run: pnpm test
2de63014 90 - name: pnpm coverage
ef28112f 91 if: ${{ github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
2de63014
JB
92 run: pnpm coverage
93 - name: SonarCloud Scan
ef28112f 94 if: ${{ github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
25b607de 95 uses: sonarsource/sonarcloud-github-action@v2.0.1
2de63014
JB
96 with:
97 projectBaseDir: ui/web
98 env:
18b41d7e 99 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2de63014 100 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
17cec4f7 101 build-docker-image:
4bfd22de 102 runs-on: ubuntu-latest
73321f43 103 name: Build docker image
c168e7ad 104 steps:
49722c24 105 - uses: actions/checkout@v4
d5d2241e 106 - name: Setup Docker Buildx
e7aeea18 107 id: buildx
c1eafbfc 108 uses: docker/setup-buildx-action@v2
e7aeea18
JB
109 - name: Build docker image
110 run: |
111 cd docker
112 make SUBMODULES_INIT=false