9ec012252124ee46a028c88024581cefde3a815d
[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 build-simulator:
11 strategy:
12 matrix:
13 os: [windows-latest, macos-latest, ubuntu-latest]
14 node: ['16.x', '18.x', '20.x']
15 name: Build simulator with Node ${{ matrix.node }} on ${{ matrix.os }}
16 runs-on: ${{ matrix.os }}
17 steps:
18 - uses: actions/checkout@v4
19 with:
20 fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
21 - name: 'Dependency Review'
22 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
23 uses: actions/dependency-review-action@v3
24 with:
25 base-ref: main
26 head-ref: ${{ github.sha }}
27 - uses: pnpm/action-setup@v2
28 with:
29 version: 8
30 - name: Setup node ${{ matrix.node }}
31 uses: actions/setup-node@v3
32 with:
33 node-version: ${{ matrix.node }}
34 cache: 'pnpm'
35 - name: pnpm install
36 run: pnpm install --ignore-scripts
37 - name: pnpm lint
38 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
39 run: pnpm lint
40 - name: pnpm build
41 run: pnpm build
42 - name: pnpm test
43 run: pnpm test
44 - name: pnpm coverage
45 if: ${{ github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
46 run: pnpm coverage
47 - name: SonarCloud Scan
48 if: ${{ github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
49 uses: sonarsource/sonarcloud-github-action@v2.0.1
50 env:
51 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
53 build-dashboard:
54 strategy:
55 matrix:
56 os: [windows-latest, macos-latest, ubuntu-latest]
57 node: ['16.x', '18.x', '20.x']
58 name: Build dashboard with Node ${{ matrix.node }} on ${{ matrix.os }}
59 runs-on: ${{ matrix.os }}
60 defaults:
61 run:
62 working-directory: ui/web
63 steps:
64 - uses: actions/checkout@v4
65 with:
66 fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
67 - name: 'Dependency Review'
68 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
69 uses: actions/dependency-review-action@v3
70 with:
71 base-ref: main
72 head-ref: ${{ github.sha }}
73 - uses: pnpm/action-setup@v2
74 with:
75 version: 8
76 - name: Setup node ${{ matrix.node }}
77 uses: actions/setup-node@v3
78 with:
79 node-version: ${{ matrix.node }}
80 cache: 'pnpm'
81 - name: pnpm install
82 run: pnpm install --ignore-scripts
83 - name: pnpm lint
84 if: ${{ matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
85 run: pnpm lint
86 - name: pnpm build
87 run: pnpm build
88 - name: pnpm test
89 run: pnpm test
90 - name: pnpm coverage
91 if: ${{ github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
92 run: pnpm coverage
93 - name: SonarCloud Scan
94 if: ${{ github.repository == 'sap/e-mobility-charging-stations-simulator' && matrix.os == 'ubuntu-latest' && matrix.node == '18.x' }}
95 uses: sonarsource/sonarcloud-github-action@v2.0.1
96 with:
97 projectBaseDir: ui/web
98 env:
99 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100 SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
101 build-docker-image:
102 runs-on: ubuntu-latest
103 name: Build docker image
104 steps:
105 - uses: actions/checkout@v4
106 - name: Setup Docker Buildx
107 id: buildx
108 uses: docker/setup-buildx-action@v2
109 - name: Build docker image
110 run: |
111 cd docker
112 make SUBMODULES_INIT=false