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