-
Notifications
You must be signed in to change notification settings - Fork 10
289 lines (239 loc) · 10.7 KB
/
main.yml
File metadata and controls
289 lines (239 loc) · 10.7 KB
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# https://infra.apache.org/github-actions-policy.html
# actions:
# - github actions use the latest release within the locked major version
# - third party actions (geekyeggo/delete-artifact, test-summary/action and shivammathur/setup-ph) shall be locked to a hash
# - see https://github.com/apache/infrastructure-gha-allowlist-manager/blob/main/approved_patterns.yml
# - dependabot is active to keep them up to date
#
# this workflow can push the limit of the apache action runner policy, please use CI responsibly
name: NetBeans VSCode
on:
push:
branches:
- 'master'
- 'release*'
pull_request:
# unlocked event is used as super secret restart button
types: [opened, synchronize, unlocked]
# Allows you to run this workflow manually from the Actions tab in GitHub UI
# keep in mind this will have ALL tests enabled
workflow_dispatch:
# cancel other PR workflow run in the same head-base group if it exists (e.g. during PR syncs)
# if this is not a PR run (no github.head_ref and github.base_ref defined), use an UID as group
concurrency:
group: ${{ github.head_ref || github.run_id }}-${{ github.base_ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
env:
# note to self: don't remove the minus again
OPTS: >-
-Dtest-unit-sys-prop.ignore.random.failures=true
# what to build and test, see nbbuild/cluster.properties
CLUSTER_CONFIG: 'full'
# default java distribution used by the setup-java action across jobs
# see https://github.com/actions/setup-java#supported-distributions
# CI requirements:
# - timely GA releases (no delays if possible)
# - EA builds must be available for the upcoming release (note: some vendors skip builds)
# - linux, win, mac (arm)
# - reliable / no extra sauce
DEFAULT_JAVA_DISTRIBUTION: 'temurin'
# labels are mapped to env vars for pipeline customization. If this is not a PR, (almost) everything will run, but with a reduced matrix.
# note: env vars don't work in the job's 'if' field but do work within jobs ( https://github.com/actions/runner/issues/1189 ), the whole expression must be duplicated
# labels for special commands:
# 'ci:all-tests' enables everything
# 'ci:no-build' disables the build job (and test jobs too)
# 'ci:dev-build' produces an artifact containing a runnable NetBeans zip distribution
# 'VSCode Extension' label for building and testing the VSCode Extension
test_vscode_extension: ${{ contains(github.event.pull_request.labels.*.name, 'VSCode Extension') || contains(github.event.pull_request.labels.*.name, 'ci:all-tests') || github.event_name != 'pull_request' }}
jobs:
# primary build job, most other jobs use the artifact produced here
# artifact is only produced once in the matrix
base-build:
name: Build VSCode on JDK ${{ matrix.java }}
if: contains(github.event.pull_request.labels.*.name, 'ci:no-build') == false
runs-on: ubuntu-latest
timeout-minutes: 40
strategy:
matrix:
java: [ '17', '21' ]
exclude:
- java: ${{ github.event_name == 'pull_request' && 'nothing' || '21' }}
fail-fast: false
steps:
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: ${{ env.DEFAULT_JAVA_DISTRIBUTION }}
- name: Checkout ${{ github.ref }} ( ${{ github.sha }} )
uses: actions/checkout@v4
with:
persist-credentials: false
submodules: true
show-progress: false
- name: Caching dependencies
uses: actions/cache@v4
with:
path: ~/.hgexternalcache
key: ${{ runner.os }}-${{ hashFiles('netbeans/*/external/binaries-list', 'netbeans/*/*/external/binaries-list') }}
restore-keys: ${{ runner.os }}-
- name: Build NetBeans
run: ant $OPTS -quiet -Dcluster.config=$CLUSTER_CONFIG build-netbeans
- name: Prepare Artifact
if: ${{ matrix.java == '17' }}
run: tar -I 'zstd -9 -T0' -cf /tmp/build.tar.zst --exclude ".git" .
- name: Upload Workspace
if: ${{ (matrix.java == '17') && success() }}
uses: actions/upload-artifact@v4
with:
name: build
path: /tmp/build.tar.zst
compression-level: 0
retention-days: 2
if-no-files-found: error
- name: Create Dev Build
if: ${{ matrix.java == '17' && contains(github.event.pull_request.labels.*.name, 'ci:dev-build') && success() }}
run: ant $OPTS -quiet -Dcluster.config=$CLUSTER_CONFIG zip-cluster-config
- name: Upload Dev Build
if: ${{ matrix.java == '17' && contains(github.event.pull_request.labels.*.name, 'ci:dev-build') && success() }}
uses: actions/upload-artifact@v4
with:
name: dev-build_${{github.event.pull_request.number || github.run_id}}
path: nbbuild/NetBeans-*.zip
compression-level: 0
retention-days: 7
if-no-files-found: error
build-from-src-zip:
name: Build ${{ matrix.config }} from src.zip on JDK ${{ matrix.java }}
# equals env.test_platform == 'true' || test_vscode_extension == 'true'
if: ${{ contains(github.event.pull_request.labels.*.name, 'Platform') || contains(github.event.pull_request.labels.*.name, 'VSCode Extension') || contains(github.event.pull_request.labels.*.name, 'ci:all-tests') || github.event_name != 'pull_request' }}
needs: base-build
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
matrix:
java: [ '17' ]
config: [ 'release' ]
fail-fast: false
steps:
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: ${{ env.DEFAULT_JAVA_DISTRIBUTION }}
- name: Download Build
uses: actions/download-artifact@v5
with:
name: build
- name: Extract
run: tar --zstd -xf build.tar.zst
- name: Restoring Cache
uses: actions/cache/restore@v4
with:
path: ~/.hgexternalcache
key: ${{ runner.os }}-${{ hashFiles('netbeans/*/external/binaries-list', 'netbeans/*/*/external/binaries-list') }}
restore-keys: ${{ runner.os }}-
- name: Create ${{ matrix.config }}-src zip
run: ant $OPTS -quiet build-source-config -Dcluster.config=${{ matrix.config }} -Dmetabuild.branch=master -Dmetabuild.jsonurl=https://raw.githubusercontent.com/apache/netbeans-jenkins-lib/refs/heads/master/meta/netbeansvscode.json -Dmetabuild.RawVersion=dev
- name: Extract ${{ matrix.config }}-src zip
run: |
mkdir tmpbuild && cd tmpbuild
unzip -qq ../build/${{ matrix.config }}-src*
- name: Build from ${{ matrix.config }}-src zip
run: |
cd tmpbuild
ant $OPTS -quiet build-netbeans -Dcluster.config=${{ matrix.config }}
# extra round for VSCodeExt which is built with 'release' config
- name: Set up node
if: ${{ (matrix.config == 'release') && success() }}
uses: actions/setup-node@v4
with:
node-version: 20.18.1
- name: Build NBVSCodeExt from ${{ matrix.config }}-src zip
if: ${{ (matrix.config == 'release') && success() }}
run: |
cd tmpbuild
ant $OPTS -quiet build-vscode-ext -D3rdparty.modules=none
vscode-extension-test:
name: VSCode Extension Tests on JDK ${{ matrix.java }}
# equals env.test_vscode_extension == 'true'
# if: ${{ contains(github.event.pull_request.labels.*.name, 'VSCode Extension') || contains(github.event.pull_request.labels.*.name, 'ci:all-tests') || github.event_name != 'pull_request' }}
needs: base-build
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
matrix:
java: [ '17' ]
fail-fast: false
steps:
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: ${{ env.DEFAULT_JAVA_DISTRIBUTION }}
- name: Set up node
uses: actions/setup-node@v4
with:
node-version: 20.18.1
- name: Setup Xvfb
run: |
echo "DISPLAY=:99.0" >> $GITHUB_ENV
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
- name: Download Build
uses: actions/download-artifact@v5
with:
name: build
- name: Extract
run: tar --zstd -xf build.tar.zst
- name: build-vscode-ext
run: |
ant $OPTS build-vscode-ext
- name: test-vscode-ext
run: |
env "netbeans.extra.options=-J-Dnetbeans.logger.console=true" ant $OPTS test-vscode-ext
# cleanup job depends on everything so that it is forced to run last even if a long job fails early.
# 'paperwork' is left out intentionally, since it doesn't run unit tests (hopefully doesn't need restarts)
# and shouldn't prevent cleanup on validation failure - which might be common during dev time
cleanup:
name: Cleanup Workflow Artifacts
needs:
- base-build
- build-from-src-zip
- vscode-extension-test
# cleanup if the primary build job succeeded and
# * nothing else failed (allows manual restarts)
# * the workflow got cancelled
if: ${{ always() && needs.base-build.result == 'success' && (!contains(needs.*.result, 'failure') || cancelled()) }}
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Delete Workspace Artifact
uses: geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b # v5.1.0
with:
name: build
useGlob: false
- name: Delete Dev Build Artifact
uses: geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b # v5.1.0
if: ${{ contains(github.event.pull_request.labels.*.name, 'ci:dev-build') && cancelled() }}
with:
name: dev-build_${{github.event.pull_request.number || github.run_id}}
useGlob: false