1 #
  2 # Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
  3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4 #
  5 # This code is free software; you can redistribute it and/or modify it
  6 # under the terms of the GNU General Public License version 2 only, as
  7 # published by the Free Software Foundation.  Oracle designates this
  8 # particular file as subject to the "Classpath" exception as provided
  9 # by Oracle in the LICENSE file that accompanied this code.
 10 #
 11 # This code is distributed in the hope that it will be useful, but WITHOUT
 12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 14 # version 2 for more details (a copy is included in the LICENSE file that
 15 # accompanied this code).
 16 #
 17 # You should have received a copy of the GNU General Public License version
 18 # 2 along with this work; if not, write to the Free Software Foundation,
 19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 20 #
 21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 22 # or visit www.oracle.com if you need additional information or have any
 23 # questions.
 24 #
 25 
 26 name: 'OpenJDK GHA Sanity Checks'
 27 
 28 on:
 29   push:
 30     branches-ignore:
 31       - pr/*
 32   workflow_dispatch:
 33     inputs:
 34       platforms:
 35         description: 'Platform(s) to execute on (comma separated, e.g. "linux-x64, macos, aarch64")'
 36         required: true
 37         default: 'linux-x64, linux-x64-variants, linux-cross-compile, alpine-linux-x64, macos-x64, macos-aarch64, windows-x64, windows-aarch64, docs'
 38       configure-arguments:
 39         description: 'Additional configure arguments'
 40         required: false
 41       make-arguments:
 42         description: 'Additional make arguments'
 43         required: false
 44       dry-run:
 45         description: 'Dry run: skip actual builds and tests'
 46         required: false
 47 
 48 concurrency:
 49   group: ${{ github.workflow }}-${{ github.ref }}
 50   cancel-in-progress: true
 51 
 52 jobs:
 53 
 54   ###
 55   ### Determine platforms to include
 56   ###
 57 
 58   prepare:
 59     name: 'Prepare the run'
 60     runs-on: ubuntu-22.04
 61     env:
 62       # List of platforms to exclude by default
 63       EXCLUDED_PLATFORMS: 'alpine-linux-x64'
 64     outputs:
 65       linux-x64: ${{ steps.include.outputs.linux-x64 }}
 66       linux-x64-variants: ${{ steps.include.outputs.linux-x64-variants }}
 67       linux-cross-compile: ${{ steps.include.outputs.linux-cross-compile }}
 68       alpine-linux-x64: ${{ steps.include.outputs.alpine-linux-x64 }}
 69       macos-x64: ${{ steps.include.outputs.macos-x64 }}
 70       macos-aarch64: ${{ steps.include.outputs.macos-aarch64 }}
 71       windows-x64: ${{ steps.include.outputs.windows-x64 }}
 72       windows-aarch64: ${{ steps.include.outputs.windows-aarch64 }}
 73       docs: ${{ steps.include.outputs.docs }}
 74       dry-run: ${{ steps.include.outputs.dry-run }}
 75 
 76     steps:
 77       - name: 'Checkout the scripts'
 78         uses: actions/checkout@v4
 79         with:
 80           sparse-checkout: |
 81             .github
 82             make/conf/github-actions.conf
 83 
 84       - name: 'Build JTReg'
 85         id: jtreg
 86         uses: ./.github/actions/build-jtreg
 87 
 88       # TODO: Now that we are checking out the repo scripts, we can put the following code
 89       # into a separate file
 90       - name: 'Check what jobs to run'
 91         id: include
 92         run: |
 93           # Determine which platform jobs to run
 94 
 95           # Returns 'true' if the input platform list matches any of the platform monikers given as argument,
 96           # 'false' otherwise.
 97           # arg $1: platform name or names to look for
 98 
 99           # Convert EXCLUDED_PLATFORMS from a comma-separated string to an array
100           IFS=',' read -r -a excluded_array <<< "$EXCLUDED_PLATFORMS"
101 
102           function check_platform() {
103             if [[ $GITHUB_EVENT_NAME == workflow_dispatch ]]; then
104               input='${{ github.event.inputs.platforms }}'
105             elif [[ $GITHUB_EVENT_NAME == push ]]; then
106               if [[ '${{ !secrets.JDK_SUBMIT_FILTER || startsWith(github.ref, 'refs/heads/submit/') }}' == 'false' ]]; then
107                 # If JDK_SUBMIT_FILTER is set, and this is not a "submit/" branch, don't run anything
108                 >&2 echo 'JDK_SUBMIT_FILTER is set and not a "submit/" branch'
109                 echo 'false'
110                 return
111               else
112                 input='${{ secrets.JDK_SUBMIT_PLATFORMS }}'
113               fi
114             fi
115 
116             normalized_input="$(echo ,$input, | tr -d ' ')"
117             if [[ "$normalized_input" == ",," ]]; then
118               # For an empty input, assume all platforms should run, except those in the EXCLUDED_PLATFORMS list
119               for excluded in "${excluded_array[@]}"; do
120                 if [[ "$1" == "$excluded" ]]; then
121                   echo 'false'
122                   return
123                 fi
124               done
125               echo 'true'
126               return
127             else
128               # Check for all acceptable platform names
129               for part in $* ; do
130                 if echo "$normalized_input" | grep -q -e ",$part," ; then
131                   echo 'true'
132                   return
133                 fi
134               done
135 
136               # If not explicitly included, check against the EXCLUDED_PLATFORMS list
137               for excluded in "${excluded_array[@]}"; do
138                 if [[ "$1" == "$excluded" ]]; then
139                   echo 'false'
140                   return
141                 fi
142               done
143             fi
144 
145             echo 'false'
146           }
147 
148           function check_dry_run() {
149             if [[ $GITHUB_EVENT_NAME == workflow_dispatch ]]; then
150               # Take the user-specified one.
151               echo '${{ github.event.inputs.dry-run }}'
152               return
153             elif [[ $GITHUB_EVENT_NAME == push ]]; then
154               # Cut out the real branch name
155               BRANCH=${GITHUB_REF##*/}
156 
157               # Dry run rebuilds the caches in current branch, so they can be reused
158               # for any child PR branches. Because of this, we want to trigger this
159               # workflow in master branch, so that actual PR branches can use the cache.
160               # This workflow would trigger every time contributors sync their master
161               # branches in their personal forks.
162               if [[ $BRANCH == "master" ]]; then
163                 echo 'true'
164                 return
165               fi
166 
167               # ...same for stabilization branches
168               if [[ $BRANCH =~ "jdk(.*)" ]]; then
169                 echo 'true'
170                 return
171               fi
172             fi
173 
174             echo 'false'
175           }
176 
177           echo "linux-x64=$(check_platform linux-x64 linux x64)" >> $GITHUB_OUTPUT
178           echo "linux-x64-variants=$(check_platform linux-x64-variants variants)" >> $GITHUB_OUTPUT
179           echo "linux-cross-compile=$(check_platform linux-cross-compile cross-compile)" >> $GITHUB_OUTPUT
180           echo "alpine-linux-x64=$(check_platform alpine-linux-x64 alpine-linux x64)" >> $GITHUB_OUTPUT
181           echo "macos-x64=$(check_platform macos-x64 macos x64)" >> $GITHUB_OUTPUT
182           echo "macos-aarch64=$(check_platform macos-aarch64 macos aarch64)" >> $GITHUB_OUTPUT
183           echo "windows-x64=$(check_platform windows-x64 windows x64)" >> $GITHUB_OUTPUT
184           echo "windows-aarch64=$(check_platform windows-aarch64 windows aarch64)" >> $GITHUB_OUTPUT
185           echo "docs=$(check_platform docs)" >> $GITHUB_OUTPUT
186           echo "dry-run=$(check_dry_run)" >> $GITHUB_OUTPUT
187 
188   ###
189   ### Build jobs
190   ###
191 
192   build-linux-x64:
193     name: linux-x64
194     needs: prepare
195     uses: ./.github/workflows/build-linux.yml
196     with:
197       platform: linux-x64
198       gcc-major-version: '10'
199       configure-arguments: ${{ github.event.inputs.configure-arguments }}
200       make-arguments: ${{ github.event.inputs.make-arguments }}
201       dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }}
202     if: needs.prepare.outputs.linux-x64 == 'true'
203 
204   build-linux-x64-hs-nopch:
205     name: linux-x64-hs-nopch
206     needs: prepare
207     uses: ./.github/workflows/build-linux.yml
208     with:
209       platform: linux-x64
210       make-target: 'hotspot'
211       debug-levels: '[ "debug" ]'
212       gcc-major-version: '10'
213       extra-conf-options: '--disable-precompiled-headers'
214       configure-arguments: ${{ github.event.inputs.configure-arguments }}
215       make-arguments: ${{ github.event.inputs.make-arguments }}
216       dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }}
217     if: needs.prepare.outputs.linux-x64-variants == 'true'
218 
219   build-linux-x64-hs-zero:
220     name: linux-x64-hs-zero
221     needs: prepare
222     uses: ./.github/workflows/build-linux.yml
223     with:
224       platform: linux-x64
225       make-target: 'hotspot'
226       debug-levels: '[ "debug" ]'
227       gcc-major-version: '10'
228       extra-conf-options: '--with-jvm-variants=zero --disable-precompiled-headers'
229       configure-arguments: ${{ github.event.inputs.configure-arguments }}
230       make-arguments: ${{ github.event.inputs.make-arguments }}
231       dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }}
232     if: needs.prepare.outputs.linux-x64-variants == 'true'
233 
234   build-linux-x64-hs-minimal:
235     name: linux-x64-hs-minimal
236     needs: prepare
237     uses: ./.github/workflows/build-linux.yml
238     with:
239       platform: linux-x64
240       make-target: 'hotspot'
241       debug-levels: '[ "debug" ]'
242       gcc-major-version: '10'
243       extra-conf-options: '--with-jvm-variants=minimal --disable-precompiled-headers'
244       configure-arguments: ${{ github.event.inputs.configure-arguments }}
245       make-arguments: ${{ github.event.inputs.make-arguments }}
246       dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }}
247     if: needs.prepare.outputs.linux-x64-variants == 'true'
248 
249   build-linux-x64-hs-optimized:
250     name: linux-x64-hs-optimized
251     needs: prepare
252     uses: ./.github/workflows/build-linux.yml
253     with:
254       platform: linux-x64
255       make-target: 'hotspot'
256       # Technically this is not the "debug" level, but we can't inject a new matrix state for just this job
257       debug-levels: '[ "debug" ]'
258       gcc-major-version: '10'
259       extra-conf-options: '--with-debug-level=optimized --disable-precompiled-headers'
260       configure-arguments: ${{ github.event.inputs.configure-arguments }}
261       make-arguments: ${{ github.event.inputs.make-arguments }}
262       dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }}
263     if: needs.prepare.outputs.linux-x64-variants == 'true'
264 
265   build-linux-x64-static:
266     name: linux-x64-static
267     needs: prepare
268     uses: ./.github/workflows/build-linux.yml
269     with:
270       platform: linux-x64
271       make-target: 'static-jdk-bundles'
272       # There are issues with fastdebug static build in GHA due to space limit.
273       # Only do release build for now.
274       debug-levels: '[ "release" ]'
275       gcc-major-version: '10'
276       configure-arguments: ${{ github.event.inputs.configure-arguments }}
277       make-arguments: ${{ github.event.inputs.make-arguments }}
278       dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }}
279       static-suffix: "-static"
280     if: needs.prepare.outputs.linux-x64 == 'true'
281 
282   build-linux-x64-static-libs:
283     name: linux-x64-static-libs
284     needs: prepare
285     uses: ./.github/workflows/build-linux.yml
286     with:
287       platform: linux-x64
288       make-target: 'static-libs-bundles'
289       # Only build static-libs-bundles for release builds.
290       # For debug builds, building static-libs often exceeds disk space.
291       debug-levels: '[ "release" ]'
292       gcc-major-version: '10'
293       configure-arguments: ${{ github.event.inputs.configure-arguments }}
294       make-arguments: ${{ github.event.inputs.make-arguments }}
295       dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }}
296       # Upload static libs bundles separately to avoid interference with normal linux-x64 bundle.
297       # This bundle is not used by testing jobs, but downstreams use it to check that
298       # dependent projects, e.g. libgraal, builds fine.
299       bundle-suffix: "-static-libs"
300     if: needs.prepare.outputs.linux-x64-variants == 'true'
301 
302   build-linux-cross-compile:
303     name: linux-cross-compile
304     needs: prepare
305     uses: ./.github/workflows/build-cross-compile.yml
306     with:
307       gcc-major-version: '10'
308       configure-arguments: ${{ github.event.inputs.configure-arguments }}
309       make-arguments: ${{ github.event.inputs.make-arguments }}
310       dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }}
311     if: needs.prepare.outputs.linux-cross-compile == 'true'
312 
313   build-alpine-linux-x64:
314     name: alpine-linux-x64
315     needs: prepare
316     uses: ./.github/workflows/build-alpine-linux.yml
317     with:
318       platform: alpine-linux-x64
319       configure-arguments: ${{ github.event.inputs.configure-arguments }}
320       make-arguments: ${{ github.event.inputs.make-arguments }}
321       dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }}
322     if: needs.prepare.outputs.alpine-linux-x64 == 'true'
323 
324   build-macos-x64:
325     name: macos-x64
326     needs: prepare
327     uses: ./.github/workflows/build-macos.yml
328     with:
329       platform: macos-x64
330       runs-on: 'macos-15-intel'
331       xcode-toolset-version: '16.4'
332       configure-arguments: ${{ github.event.inputs.configure-arguments }}
333       make-arguments: ${{ github.event.inputs.make-arguments }}
334       dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }}
335     if: needs.prepare.outputs.macos-x64 == 'true'
336 
337   build-macos-aarch64:
338     name: macos-aarch64
339     needs: prepare
340     uses: ./.github/workflows/build-macos.yml
341     with:
342       platform: macos-aarch64
343       runs-on: 'macos-15'
344       xcode-toolset-version: '16.4'
345       configure-arguments: ${{ github.event.inputs.configure-arguments }}
346       make-arguments: ${{ github.event.inputs.make-arguments }}
347       dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }}
348     if: needs.prepare.outputs.macos-aarch64 == 'true'
349 
350   build-windows-x64:
351     name: windows-x64
352     needs: prepare
353     uses: ./.github/workflows/build-windows.yml
354     with:
355       platform: windows-x64
356       msvc-toolset-version: '14.44'
357       msvc-toolset-architecture: 'x86.x64'
358       configure-arguments: ${{ github.event.inputs.configure-arguments }}
359       make-arguments: ${{ github.event.inputs.make-arguments }}
360       dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }}
361     if: needs.prepare.outputs.windows-x64 == 'true'
362 
363   build-windows-aarch64:
364     name: windows-aarch64
365     needs: prepare
366     uses: ./.github/workflows/build-windows.yml
367     with:
368       platform: windows-aarch64
369       msvc-toolset-version: '14.44'
370       msvc-toolset-architecture: 'arm64'
371       make-target: 'hotspot'
372       extra-conf-options: '--openjdk-target=aarch64-unknown-cygwin'
373       configure-arguments: ${{ github.event.inputs.configure-arguments }}
374       make-arguments: ${{ github.event.inputs.make-arguments }}
375       dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }}
376     if: needs.prepare.outputs.windows-aarch64 == 'true'
377 
378   build-docs:
379     name: docs
380     needs: prepare
381     uses: ./.github/workflows/build-linux.yml
382     with:
383       platform: linux-x64
384       debug-levels: '[ "debug" ]'
385       make-target: 'docs-jdk-bundles'
386       # Make sure we never try to make full docs, since that would require a
387       # build JDK, and we do not need the additional testing of the graphs.
388       extra-conf-options: '--disable-full-docs'
389       gcc-major-version: '10'
390       configure-arguments: ${{ github.event.inputs.configure-arguments }}
391       make-arguments: ${{ github.event.inputs.make-arguments }}
392       dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }}
393     if: needs.prepare.outputs.docs == 'true'
394 
395   ###
396   ### Test jobs
397   ###
398 
399   test-linux-x64:
400     name: linux-x64
401     needs:
402       - prepare
403       - build-linux-x64
404     uses: ./.github/workflows/test.yml
405     with:
406       platform: linux-x64
407       bootjdk-platform: linux-x64
408       runs-on: ubuntu-22.04
409       dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }}
410       debug-suffix: -debug
411 
412   test-linux-x64-static:
413     name: linux-x64-static
414     needs:
415       - prepare
416       - build-linux-x64
417       - build-linux-x64-static
418     uses: ./.github/workflows/test.yml
419     with:
420       platform: linux-x64
421       bootjdk-platform: linux-x64
422       runs-on: ubuntu-22.04
423       dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }}
424       static-suffix: "-static"
425 
426   test-macos-aarch64:
427     name: macos-aarch64
428     needs:
429       - prepare
430       - build-macos-aarch64
431     uses: ./.github/workflows/test.yml
432     with:
433       platform: macos-aarch64
434       bootjdk-platform: macos-aarch64
435       runs-on: macos-15
436       dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }}
437       xcode-toolset-version: '16.4'
438       debug-suffix: -debug
439 
440   test-windows-x64:
441     name: windows-x64
442     needs:
443       - prepare
444       - build-windows-x64
445     uses: ./.github/workflows/test.yml
446     with:
447       platform: windows-x64
448       bootjdk-platform: windows-x64
449       runs-on: windows-2025
450       dry-run: ${{ needs.prepare.outputs.dry-run == 'true' }}
451       debug-suffix: -debug