-
Notifications
You must be signed in to change notification settings - Fork 23
216 lines (195 loc) · 7.55 KB
/
build.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
name: Build
on:
push:
branches: ['main']
workflow_dispatch:
inputs:
os:
description: 'O/S'
required: true
default: 'Ubuntu'
type: choice
options:
- 'Linux'
- 'Mac'
- 'Windows'
- 'All'
javaVersion:
description: 'JDK compatibility'
required: true
default: '21'
type: choice
options:
- '21'
- '17'
- '11'
- 'All'
jobs:
define-matrix:
name: Define matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-environment-variables.outputs.matrix }}
steps:
- name: Set environment variables
id: set-environment-variables
run: |
requestedJavaVersions=${{ inputs.javaVersion }}
if [[ "$requestedJavaVersions" == "All" ]]; then
jdk21BuildRequested=true
jdk17BuildRequested=true
jdk11BuildRequested=true
elif [[ (-z "$requestedJavaVersions") || ("$requestedJavaVersions" == "21") ]]; then
jdk21BuildRequested=true
jdk17BuildRequested=false
jdk11BuildRequested=false
elif [[ "$requestedJavaVersions" == "17" ]]; then
jdk21BuildRequested=false
jdk17BuildRequested=true
jdk11BuildRequested=false
elif [[ "$requestedJavaVersions" == "11" ]]; then
jdk21BuildRequested=false
jdk17BuildRequested=false
jdk11BuildRequested=true
fi
requestedOs=${{ inputs.os }}
selectedOs=()
if [[ (-z "$requestedOs") || ("$requestedOs" == "All") || ("$requestedOs" == "Linux") ]]; then
selectedOs+=(Linux)
fi
if [[ (-z "$requestedOs") || ("$requestedOs" == "All") || ("$requestedOs" == "Mac") ]]; then
selectedOs+=(Mac)
fi
if [[ (-z "$requestedOs") || ("$requestedOs" == "All") || ("$requestedOs" == "Windows") ]]; then
selectedOs+=(Windows)
fi
echo "Selected OS: ${selectedOs[*]}"
matrix="{\"include\": ["
selectedOsMaxIndex=$((${#selectedOs[@]} - 1))
for (( i=0; i<${#selectedOs[@]}; i++ )); do
case "${selectedOs[$i]}" in
Linux)
os=ubuntu-24.04
name=Ubuntu
codeScanEnabled=$(if [[ "$jdk21BuildRequested" -eq 1 ]]; then echo true; else echo false; fi)
gitFetchDepth=$(if [[ "$codeScanEnabled" == true ]]; then echo 0; else echo 1; fi)
pluginTaskNameJdk21=$(if [[ "$codeScanEnabled" == true ]]; then echo jacocoTestReport; else echo build; fi)
;;
Mac)
os=macos-14
name=Mac
codeScanEnabled=false
gitFetchDepth=1
pluginTaskNameJdk21=build
;;
Windows)
os=windows-2022
name=Windows
codeScanEnabled=false
gitFetchDepth=1
pluginTaskNameJdk21=build
;;
esac
jsonProperties="{ \"os\": \"$os\", "
jsonProperties+="\"name\": \"$name\", "
jsonProperties+="\"codeScanEnabled\": $codeScanEnabled, "
jsonProperties+="\"gitFetchDepth\": $gitFetchDepth, "
jsonProperties+="\"pluginTaskNameJdk21\": \"$pluginTaskNameJdk21\", "
jsonProperties+="\"jdk11BuildRequested\": $jdk11BuildRequested, "
jsonProperties+="\"jdk17BuildRequested\": $jdk17BuildRequested, "
jsonProperties+="\"jdk21BuildRequested\": $jdk21BuildRequested }"
echo "OS: $jsonProperties"
matrix+=$jsonProperties
if [[ $i < $selectedOsMaxIndex ]]; then
matrix+=", "
fi
done
matrix+="]}"
echo "Matrix: $matrix"
echo "JDK build requests: 11=$jdk11BuildRequested" 17=$jdk17BuildRequested 21=$jdk21BuildRequested
echo "matrix=$matrix" >> $GITHUB_OUTPUT
run-matrix:
needs: define-matrix
strategy:
matrix: ${{ fromJSON(needs.define-matrix.outputs.matrix) }}
name: Building on ${{ matrix.name }}
runs-on: ${{ matrix.os }}
steps:
- name: Building parameters
run: |
echo "OS: ${{ matrix.os }}"
echo "Target JDKS: 11=${{ matrix.jdk11BuildRequested }}, 17=${{ matrix.jdk17BuildRequested }}, 21=${{ matrix.jdk21BuildRequested }}"
echo "Git fetch depth: ${{ matrix.gitFetchDepth }}"
echo "[JDK 21] Code scan enabled: ${{ matrix.codeScanEnabled }}"
echo "[JDK 21] Task name: ${{ matrix.pluginTaskNameJdk21 }}"
- name: Init Ubuntu environment
if: matrix.name == 'Ubuntu'
run: sudo rm -f /usr/local/bin/node /usr/local/bin/npm /usr/local/bin/pnpm /usr/local/bin/yarn
- name: Init MacOS environment
if: matrix.name == 'Mac'
run: sudo rm -f /opt/homebrew/bin/node /usr/local/bin/npm /usr/local/bin/pnpm /usr/bin/yarn /Users/runner/.yarn/bin/yarn
- name: Init Windows environment
if: matrix.name == 'Windows'
run: |
Rename-Item "C:\Program Files\nodejs" "nodejs.old" -Force
Rename-Item "C:\npm" "npm.old" -Force
Remove-Item Env:npm_config_prefix
- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: matrix.gitFetchDepth
- name: Set up JDK 11
uses: actions/setup-java@v4
if: matrix.jdk11BuildRequested
with:
distribution: temurin
java-version: '11'
architecture: x64
- name: Set up JDK 17
uses: actions/setup-java@v4
if: matrix.jdk17BuildRequested
with:
distribution: temurin
java-version: '17'
architecture: x64
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
architecture: x64
- name: Cache Gradle's cache and wrapper
uses: actions/cache@v4
with:
path: |
~/.gradle/caches/
~/.gradle/wrapper/
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Cache Sonar's cache
uses: actions/cache@v4
if: matrix.codeScanEnabled
with:
path: |
~/.sonar/cache/
key: ${{ runner.os }}-sonar-${{ hashFiles('**/*.gradle*') }}
- name: Grant executable permission
run: chmod +x gradlew plugins/frontend-jdk*/src/integrationTest/resources/*/bin/*
- name: Build plugin for JDK 11+
if: matrix.jdk11BuildRequested
run: ./gradlew :plugins:frontend-jdk11:build --console=plain
- name: Build plugin for JDK 17+
if: matrix.jdk17BuildRequested
run: ./gradlew :plugins:frontend-jdk17:build --console=plain
- name: Build plugin for JDK 21+
if: matrix.jdk21BuildRequested
run: ./gradlew :plugins:frontend-jdk21:${{ matrix.pluginTaskNameJdk21 }} --console=plain
- name: Scan source code and test results
if: matrix.codeScanEnabled
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: ./gradlew :plugins:frontend-jdk21:sonar --console=plain -Dorg.gradle.jvmargs=-Xmx512m -i
- name: Stop Gradle before caching
run: ./gradlew -stop