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