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