chore: switch to pnpm 9.x.x
[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-simulator:
25 needs: [check-secrets]
26 strategy:
27 matrix:
28 os: [windows-latest, macos-latest, ubuntu-latest]
29 node: ['20.x', 'latest']
30 name: Build simulator with Node ${{ matrix.node }} on ${{ matrix.os }}
31 runs-on: ${{ matrix.os }}
32 steps:
33 - uses: actions/checkout@v4
34 with:
35 fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
36 - name: Dependency Review
37 if: ${{ github.event_name == 'push' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
38 uses: actions/dependency-review-action@v4
39 with:
40 base-ref: ${{ github.ref_name }}
41 head-ref: ${{ github.sha }}
42 - name: Pull Request Dependency Review
43 if: ${{ github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
44 uses: actions/dependency-review-action@v4
45 - uses: pnpm/action-setup@v3
46 with:
47 version: 9
48 - name: Setup node ${{ matrix.node }}
49 uses: actions/setup-node@v4
50 with:
51 node-version: ${{ matrix.node }}
52 cache: 'pnpm'
53 - name: pnpm install
54 run: pnpm install --ignore-scripts --frozen-lockfile
55 - name: pnpm audit
56 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
57 run: pnpm audit --prod
58 - name: pnpm lint
59 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
60 run: pnpm lint
61 - name: pnpm build
62 run: pnpm build
63 - name: pnpm test
64 run: pnpm test
65 - name: pnpm coverage
66 if: ${{ github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
67 run: pnpm coverage
68 - name: SonarCloud Scan
69 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' }}
70 uses: sonarsource/sonarcloud-github-action@v2.1.1
71 env:
72 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
74 build-dashboard:
75 needs: [check-secrets]
76 strategy:
77 matrix:
78 os: [windows-latest, macos-latest, ubuntu-latest]
79 node: ['18.x', '20.x', 'latest']
80 name: Build dashboard with Node ${{ matrix.node }} on ${{ matrix.os }}
81 runs-on: ${{ matrix.os }}
82 defaults:
83 run:
84 working-directory: ui/web
85 steps:
86 - uses: actions/checkout@v4
87 with:
88 fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
89 - name: Dependency Review
90 if: ${{ github.event_name == 'push' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
91 uses: actions/dependency-review-action@v4
92 with:
93 base-ref: ${{ github.ref_name }}
94 head-ref: ${{ github.sha }}
95 - name: Pull Request Dependency Review
96 if: ${{ github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
97 uses: actions/dependency-review-action@v4
98 - uses: pnpm/action-setup@v3
99 with:
100 version: 9
101 - name: Setup node ${{ matrix.node }}
102 uses: actions/setup-node@v4
103 with:
104 node-version: ${{ matrix.node }}
105 cache: 'pnpm'
106 - name: pnpm install
107 run: pnpm install --ignore-scripts --frozen-lockfile
108 - name: pnpm audit
109 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
110 run: pnpm audit --prod
111 - name: pnpm lint
112 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
113 run: pnpm lint
114 - name: pnpm build
115 run: pnpm build
116 - name: pnpm test
117 run: pnpm test
118 - name: pnpm coverage
119 if: ${{ github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '20.x' }}
120 run: pnpm coverage
121 - name: SonarCloud Scan
122 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' }}
123 uses: sonarsource/sonarcloud-github-action@v2.1.1
124 with:
125 projectBaseDir: ui/web
126 env:
127 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
129 build-docker-image:
130 runs-on: ubuntu-latest
131 name: Build docker image
132 steps:
133 - uses: actions/checkout@v4
134 - name: Setup Docker Buildx
135 id: buildx
136 uses: docker/setup-buildx-action@v3
137 - name: Build docker image
138 run: |
139 cd docker
140 make SUBMODULES_INIT=false