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