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