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