-
Notifications
You must be signed in to change notification settings - Fork 50
136 lines (127 loc) · 4.37 KB
/
build_pull_request.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle
name: CI Build on PULL Request
on:
pull_request:
branches: [ "master" ]
permissions:
contents: read
jobs:
# JOB to run change detection
changes:
runs-on: ubuntu-latest
# Required permissions
permissions:
pull-requests: read
# Set job outputs to values from the filter step
outputs:
cli: ${{ steps.filter.outputs.cli }}
client: ${{ steps.filter.outputs.client }}
server: ${{ steps.filter.outputs.server }}
steps:
# For pull requests, it's not necessary to check out the code
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
cli:
- 'cli/**'
client:
- 'client/**'
server:
- 'server/**'
cli:
needs: changes
if: ${{ needs.changes.outputs.cli == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up GraalVM for JDK 21
uses: graalvm/setup-graalvm@v1
with:
distribution: 'graalvm-community'
java-version: '21'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
working-directory: cli
run: ../gradlew build jacocoTestReport sonar --stacktrace
client:
needs: changes
if: ${{ needs.changes.outputs.client == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up Node 20
uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
cache-dependency-path: client/package-lock.json
- name: run npm commands
working-directory: client
run: |
npm ci
npm run check
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
projectBaseDir: client/
server:
needs: changes
if: ${{ needs.changes.outputs.server == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up GraalVM for JDK 21
uses: graalvm/setup-graalvm@v1
with:
distribution: 'graalvm-community'
java-version: '21'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_ACTIONS_BUILD: true
working-directory: server
run: ../gradlew check jacocoTestReport sonar --scan --stacktrace