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