build(deps): bump sonarsource/sonarcloud-github-action
[e-mobility-charging-stations-simulator.git] / .github / workflows / ci.yml
1 name: CI
2 on:
3 push:
4 branches: [main]
5 pull_request:
6 types: [opened, synchronize, reopened]
7 merge_group:
8 branches: [main]
9 jobs:
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
24 build-ocpp-server:
25 strategy:
26 matrix:
27 python:
28 - 3.12
29 name: Build OCPP mock server with Python ${{ matrix.python }}
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 }}
37 uses: actions/setup-python@v5
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
45 run: poetry install --no-root
46 - name: Lint
47 run: poetry run task lint
48 build-simulator:
49 needs: [check-secrets]
50 strategy:
51 matrix:
52 os: [windows-latest, macos-latest, ubuntu-latest]
53 node: ['20.x', 'latest']
54 name: Build simulator with Node ${{ matrix.node }} on ${{ matrix.os }}
55 runs-on: ${{ matrix.os }}
56 steps:
57 - uses: actions/checkout@v4
58 with:
59 fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
60 - name: Dependency Review
61 if: ${{ github.event_name == 'push' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
62 uses: actions/dependency-review-action@v4
63 with:
64 base-ref: ${{ github.ref_name }}
65 head-ref: ${{ github.sha }}
66 - name: Pull Request Dependency Review
67 if: ${{ github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
68 uses: actions/dependency-review-action@v4
69 - uses: pnpm/action-setup@v4
70 - name: Setup node ${{ matrix.node }}
71 uses: actions/setup-node@v4
72 with:
73 node-version: ${{ matrix.node }}
74 cache: 'pnpm'
75 - name: pnpm install
76 run: pnpm install --ignore-scripts --frozen-lockfile
77 - name: pnpm audit
78 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
79 run: pnpm audit --prod
80 - name: pnpm lint
81 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
82 run: pnpm lint
83 - name: pnpm build
84 run: pnpm build
85 - name: pnpm test
86 run: pnpm test
87 - name: pnpm coverage
88 if: ${{ github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
89 run: pnpm coverage
90 - name: SonarCloud Scan
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' }}
92 uses: sonarsource/sonarcloud-github-action@v2.3.0
93 env:
94 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
95 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
96 build-dashboard:
97 needs: [check-secrets]
98 strategy:
99 matrix:
100 os: [windows-latest, macos-latest, ubuntu-latest]
101 node: ['18.x', '20.x', 'latest']
102 name: Build dashboard with Node ${{ matrix.node }} on ${{ matrix.os }}
103 runs-on: ${{ matrix.os }}
104 defaults:
105 run:
106 working-directory: ui/web
107 steps:
108 - uses: actions/checkout@v4
109 with:
110 fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
111 - name: Dependency Review
112 if: ${{ github.event_name == 'push' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
113 uses: actions/dependency-review-action@v4
114 with:
115 base-ref: ${{ github.ref_name }}
116 head-ref: ${{ github.sha }}
117 - name: Pull Request Dependency Review
118 if: ${{ github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
119 uses: actions/dependency-review-action@v4
120 - uses: pnpm/action-setup@v4
121 - name: Setup node ${{ matrix.node }}
122 uses: actions/setup-node@v4
123 with:
124 node-version: ${{ matrix.node }}
125 cache: 'pnpm'
126 - name: pnpm install
127 run: pnpm install --ignore-scripts --frozen-lockfile
128 - name: pnpm audit
129 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
130 run: pnpm audit --prod
131 - name: pnpm lint
132 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
133 run: pnpm lint
134 - name: pnpm build
135 run: pnpm build
136 - name: pnpm test
137 run: pnpm test
138 - name: pnpm coverage
139 if: ${{ github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
140 run: pnpm coverage
141 - name: SonarCloud Scan
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' }}
143 uses: sonarsource/sonarcloud-github-action@v2.3.0
144 with:
145 projectBaseDir: ui/web
146 env:
147 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
148 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
149 build-docker-image:
150 runs-on: ubuntu-latest
151 name: Build docker image
152 steps:
153 - uses: actions/checkout@v4
154 - name: Setup Docker Buildx
155 id: buildx
156 uses: docker/setup-buildx-action@v3
157 - name: Build docker image
158 run: |
159 cd docker
160 make SUBMODULES_INIT=false