build(deps-dev): apply updates
[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:
61a54e7b
JB
10 check-secrets:
11 runs-on: ubuntu-latest
12 outputs:
13 sonar-token-exists: ${{ steps.sonar-token.outputs.defined }}
14 steps:
15 - name: Check for SonarCloud Token Availability
16 id: sonar-token
17 shell: bash
18 run: |
19 if [ "${{ secrets.SONAR_TOKEN }}" != '' ]; then
20 echo "defined=true" >> $GITHUB_OUTPUT;
21 else
22 echo "defined=false" >> $GITHUB_OUTPUT;
23 fi
ffccbf22
JB
24 build-ocpp-server:
25 strategy:
26 matrix:
27 python:
28 - 3.12
40f37d8e 29 name: Build OCPP mock server with Python ${{ matrix.python }}
ffccbf22
JB
30 runs-on: ubuntu-latest
31 defaults:
32 run:
33 working-directory: tests/ocpp-server
34 steps:
35 - uses: actions/checkout@v4
36 - name: Setup Python ${{ matrix.python }}
67782acd 37 uses: actions/setup-python@v5
ffccbf22
JB
38 with:
39 python-version: ${{ matrix.python }}
40 - name: Install Poetry
41 run: |
42 python -m pip install --upgrade pip
43 pip install poetry
44 - name: Install Dependencies
40f37d8e 45 run: poetry install --no-root
ffccbf22
JB
46 - name: Lint
47 run: poetry run task lint
17cec4f7 48 build-simulator:
61a54e7b 49 needs: [check-secrets]
69d993b0
JB
50 strategy:
51 matrix:
c1eafbfc 52 os: [windows-latest, macos-latest, ubuntu-latest]
6dd374b2 53 node: ['20.x', 'latest']
ebb77a4c 54 name: Build simulator with Node ${{ matrix.node }} on ${{ matrix.os }}
916678e9 55 runs-on: ${{ matrix.os }}
69d993b0 56 steps:
49722c24 57 - uses: actions/checkout@v4
e7aeea18
JB
58 with:
59 fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
b36a0f94 60 - name: Dependency Review
cd49faeb 61 if: ${{ github.event_name == 'push' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
f3bf03c7 62 uses: actions/dependency-review-action@v4
b131d478 63 with:
3a389887 64 base-ref: ${{ github.ref_name }}
cc92c810 65 head-ref: ${{ github.sha }}
b36a0f94 66 - name: Pull Request Dependency Review
cd49faeb 67 if: ${{ github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
f3bf03c7 68 uses: actions/dependency-review-action@v4
e6453293 69 - uses: pnpm/action-setup@v4
d5d2241e 70 - name: Setup node ${{ matrix.node }}
f70b733f 71 uses: actions/setup-node@v4
e7aeea18 72 with:
0642c3d2 73 node-version: ${{ matrix.node }}
e3874421 74 cache: 'pnpm'
881f450c 75 - name: pnpm install
d9d8bb32 76 run: pnpm install --ignore-scripts --frozen-lockfile
52cdd8a1
JB
77 - name: pnpm audit
78 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
9c6af3b0 79 run: pnpm audit --prod
e3874421 80 - name: pnpm lint
cd49faeb 81 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
e3874421
JB
82 run: pnpm lint
83 - name: pnpm build
84 run: pnpm build
881f450c
JB
85 - name: pnpm test
86 run: pnpm test
e3874421 87 - name: pnpm coverage
cd49faeb 88 if: ${{ github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
e3874421 89 run: pnpm coverage
e7aeea18 90 - name: SonarCloud Scan
cd49faeb 91 if: ${{ needs.check-secrets.outputs.sonar-token-exists == 'true' && github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
e48376ce 92 uses: sonarsource/sonarcloud-github-action@v2.2.0
e7aeea18 93 env:
18b41d7e 94 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
e7aeea18 95 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
32de5a57 96 build-dashboard:
61a54e7b 97 needs: [check-secrets]
32de5a57
LM
98 strategy:
99 matrix:
100 os: [windows-latest, macos-latest, ubuntu-latest]
6dd374b2 101 node: ['18.x', '20.x', 'latest']
ebb77a4c 102 name: Build dashboard with Node ${{ matrix.node }} on ${{ matrix.os }}
916678e9
JB
103 runs-on: ${{ matrix.os }}
104 defaults:
105 run:
106 working-directory: ui/web
32de5a57 107 steps:
49722c24 108 - uses: actions/checkout@v4
32de5a57
LM
109 with:
110 fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
b36a0f94 111 - name: Dependency Review
cd49faeb 112 if: ${{ github.event_name == 'push' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
f3bf03c7 113 uses: actions/dependency-review-action@v4
b131d478 114 with:
3a389887 115 base-ref: ${{ github.ref_name }}
cc92c810 116 head-ref: ${{ github.sha }}
b36a0f94 117 - name: Pull Request Dependency Review
cd49faeb 118 if: ${{ github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
f3bf03c7 119 uses: actions/dependency-review-action@v4
e6453293 120 - uses: pnpm/action-setup@v4
d5d2241e 121 - name: Setup node ${{ matrix.node }}
f70b733f 122 uses: actions/setup-node@v4
32de5a57
LM
123 with:
124 node-version: ${{ matrix.node }}
e3874421 125 cache: 'pnpm'
603f1011 126 - name: pnpm install
d9d8bb32 127 run: pnpm install --ignore-scripts --frozen-lockfile
52cdd8a1
JB
128 - name: pnpm audit
129 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
9c6af3b0 130 run: pnpm audit --prod
e3874421 131 - name: pnpm lint
cd49faeb 132 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
e3874421
JB
133 run: pnpm lint
134 - name: pnpm build
9d76f5ec 135 run: pnpm build
603f1011
JB
136 - name: pnpm test
137 run: pnpm test
2de63014 138 - name: pnpm coverage
cd49faeb 139 if: ${{ github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
2de63014
JB
140 run: pnpm coverage
141 - name: SonarCloud Scan
cd49faeb 142 if: ${{ needs.check-secrets.outputs.sonar-token-exists == 'true' && github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
e48376ce 143 uses: sonarsource/sonarcloud-github-action@v2.2.0
2de63014
JB
144 with:
145 projectBaseDir: ui/web
146 env:
18b41d7e 147 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2de63014 148 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
17cec4f7 149 build-docker-image:
4bfd22de 150 runs-on: ubuntu-latest
73321f43 151 name: Build docker image
c168e7ad 152 steps:
49722c24 153 - uses: actions/checkout@v4
d5d2241e 154 - name: Setup Docker Buildx
e7aeea18 155 id: buildx
5c555092 156 uses: docker/setup-buildx-action@v3
e7aeea18
JB
157 - name: Build docker image
158 run: |
159 cd docker
160 make SUBMODULES_INIT=false