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 
 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 
 75     steps:
 76       - name: 'Checkout the scripts'
 77         uses: actions/checkout@v4
 78         with:
 79           sparse-checkout: |
 80             .github
 81             make/conf/github-actions.conf
 82 
 83       - name: 'Build JTReg'
 84         id: jtreg
 85         uses: ./.github/actions/build-jtreg
 86 
 87       # TODO: Now that we are checking out the repo scripts, we can put the following code
 88       # into a separate file
 89       - name: 'Check what jobs to run'
 90         id: include
 91         run: |
 92           # Determine which platform jobs to run
 93 
 94           # Returns 'true' if the input platform list matches any of the platform monikers given as argument,
 95           # 'false' otherwise.
 96           # arg $1: platform name or names to look for
 97 
 98           # Convert EXCLUDED_PLATFORMS from a comma-separated string to an array
 99           IFS=',' read -r -a excluded_array <<< "$EXCLUDED_PLATFORMS"
100 
101           function check_platform() {
102             if [[ $GITHUB_EVENT_NAME == workflow_dispatch ]]; then
103               input='${{ github.event.inputs.platforms }}'
104             elif [[ $GITHUB_EVENT_NAME == push ]]; then
105               if [[ '${{ !secrets.JDK_SUBMIT_FILTER || startsWith(github.ref, 'refs/heads/submit/') }}' == 'false' ]]; then
106                 # If JDK_SUBMIT_FILTER is set, and this is not a "submit/" branch, don't run anything
107                 >&2 echo 'JDK_SUBMIT_FILTER is set and not a "submit/" branch'
108                 echo 'false'
109                 return
110               else
111                 input='${{ secrets.JDK_SUBMIT_PLATFORMS }}'
112               fi
113             fi
114 
115             normalized_input="$(echo ,$input, | tr -d ' ')"
116             if [[ "$normalized_input" == ",," ]]; then
117               # For an empty input, assume all platforms should run, except those in the EXCLUDED_PLATFORMS list
118               for excluded in "${excluded_array[@]}"; do
119                 if [[ "$1" == "$excluded" ]]; then
120                   echo 'false'
121                   return
122                 fi
123               done
124               echo 'true'
125               return
126             else
127               # Check for all acceptable platform names
128               for part in $* ; do
129                 if echo "$normalized_input" | grep -q -e ",$part," ; then
130                   echo 'true'
131                   return
132                 fi
133               done
134 
135               # If not explicitly included, check against the EXCLUDED_PLATFORMS list
136               for excluded in "${excluded_array[@]}"; do
137                 if [[ "$1" == "$excluded" ]]; then
138                   echo 'false'
139                   return
140                 fi
141               done
142             fi
143 
144             echo 'false'
145           }
146 
147           echo "linux-x64=$(check_platform linux-x64 linux x64)" >> $GITHUB_OUTPUT
148           echo "linux-x64-variants=$(check_platform linux-x64-variants variants)" >> $GITHUB_OUTPUT
149           echo "linux-cross-compile=$(check_platform linux-cross-compile cross-compile)" >> $GITHUB_OUTPUT
150           echo "alpine-linux-x64=$(check_platform alpine-linux-x64 alpine-linux x64)" >> $GITHUB_OUTPUT
151           echo "macos-x64=$(check_platform macos-x64 macos x64)" >> $GITHUB_OUTPUT
152           echo "macos-aarch64=$(check_platform macos-aarch64 macos aarch64)" >> $GITHUB_OUTPUT
153           echo "windows-x64=$(check_platform windows-x64 windows x64)" >> $GITHUB_OUTPUT
154           echo "windows-aarch64=$(check_platform windows-aarch64 windows aarch64)" >> $GITHUB_OUTPUT
155           echo "docs=$(check_platform docs)" >> $GITHUB_OUTPUT
156 
157   ###
158   ### Build jobs
159   ###
160 
161   build-linux-x64:
162     name: linux-x64
163     needs: prepare
164     uses: ./.github/workflows/build-linux.yml
165     with:
166       platform: linux-x64
167       gcc-major-version: '10'
168       configure-arguments: ${{ github.event.inputs.configure-arguments }}
169       make-arguments: ${{ github.event.inputs.make-arguments }}
170     if: needs.prepare.outputs.linux-x64 == 'true'
171 
172   build-linux-x64-hs-nopch:
173     name: linux-x64-hs-nopch
174     needs: prepare
175     uses: ./.github/workflows/build-linux.yml
176     with:
177       platform: linux-x64
178       make-target: 'hotspot'
179       debug-levels: '[ "debug" ]'
180       gcc-major-version: '10'
181       extra-conf-options: '--disable-precompiled-headers'
182       configure-arguments: ${{ github.event.inputs.configure-arguments }}
183       make-arguments: ${{ github.event.inputs.make-arguments }}
184     if: needs.prepare.outputs.linux-x64-variants == 'true'
185 
186   build-linux-x64-hs-zero:
187     name: linux-x64-hs-zero
188     needs: prepare
189     uses: ./.github/workflows/build-linux.yml
190     with:
191       platform: linux-x64
192       make-target: 'hotspot'
193       debug-levels: '[ "debug" ]'
194       gcc-major-version: '10'
195       extra-conf-options: '--with-jvm-variants=zero --disable-precompiled-headers'
196       configure-arguments: ${{ github.event.inputs.configure-arguments }}
197       make-arguments: ${{ github.event.inputs.make-arguments }}
198     if: needs.prepare.outputs.linux-x64-variants == 'true'
199 
200   build-linux-x64-hs-minimal:
201     name: linux-x64-hs-minimal
202     needs: prepare
203     uses: ./.github/workflows/build-linux.yml
204     with:
205       platform: linux-x64
206       make-target: 'hotspot'
207       debug-levels: '[ "debug" ]'
208       gcc-major-version: '10'
209       extra-conf-options: '--with-jvm-variants=minimal --disable-precompiled-headers'
210       configure-arguments: ${{ github.event.inputs.configure-arguments }}
211       make-arguments: ${{ github.event.inputs.make-arguments }}
212     if: needs.prepare.outputs.linux-x64-variants == 'true'
213 
214   build-linux-x64-hs-optimized:
215     name: linux-x64-hs-optimized
216     needs: prepare
217     uses: ./.github/workflows/build-linux.yml
218     with:
219       platform: linux-x64
220       make-target: 'hotspot'
221       # Technically this is not the "debug" level, but we can't inject a new matrix state for just this job
222       debug-levels: '[ "debug" ]'
223       gcc-major-version: '10'
224       extra-conf-options: '--with-debug-level=optimized --disable-precompiled-headers'
225       configure-arguments: ${{ github.event.inputs.configure-arguments }}
226       make-arguments: ${{ github.event.inputs.make-arguments }}
227     if: needs.prepare.outputs.linux-x64-variants == 'true'
228 
229   build-linux-x64-static:
230     name: linux-x64-static
231     needs: prepare
232     uses: ./.github/workflows/build-linux.yml
233     with:
234       platform: linux-x64
235       make-target: 'static-jdk-bundles'
236       # There are issues with fastdebug static build in GHA due to space limit.
237       # Only do release build for now.
238       debug-levels: '[ "release" ]'
239       gcc-major-version: '10'
240       configure-arguments: ${{ github.event.inputs.configure-arguments }}
241       make-arguments: ${{ github.event.inputs.make-arguments }}
242       static-suffix: "-static"
243     if: needs.prepare.outputs.linux-x64 == 'true'
244 
245   build-linux-x64-static-libs:
246     name: linux-x64-static-libs
247     needs: prepare
248     uses: ./.github/workflows/build-linux.yml
249     with:
250       platform: linux-x64
251       make-target: 'static-libs-bundles'
252       # Only build static-libs-bundles for release builds.
253       # For debug builds, building static-libs often exceeds disk space.
254       debug-levels: '[ "release" ]'
255       gcc-major-version: '10'
256       configure-arguments: ${{ github.event.inputs.configure-arguments }}
257       make-arguments: ${{ github.event.inputs.make-arguments }}
258       # Upload static libs bundles separately to avoid interference with normal linux-x64 bundle.
259       # This bundle is not used by testing jobs, but downstreams use it to check that
260       # dependent projects, e.g. libgraal, builds fine.
261       bundle-suffix: "-static-libs"
262     if: needs.prepare.outputs.linux-x64-variants == 'true'
263 
264   build-linux-cross-compile:
265     name: linux-cross-compile
266     needs: prepare
267     uses: ./.github/workflows/build-cross-compile.yml
268     with:
269       gcc-major-version: '10'
270       configure-arguments: ${{ github.event.inputs.configure-arguments }}
271       make-arguments: ${{ github.event.inputs.make-arguments }}
272     if: needs.prepare.outputs.linux-cross-compile == 'true'
273 
274   build-alpine-linux-x64:
275     name: alpine-linux-x64
276     needs: prepare
277     uses: ./.github/workflows/build-alpine-linux.yml
278     with:
279       platform: alpine-linux-x64
280       configure-arguments: ${{ github.event.inputs.configure-arguments }}
281       make-arguments: ${{ github.event.inputs.make-arguments }}
282     if: needs.prepare.outputs.alpine-linux-x64 == 'true'
283 
284   build-macos-x64:
285     name: macos-x64
286     needs: prepare
287     uses: ./.github/workflows/build-macos.yml
288     with:
289       platform: macos-x64
290       runs-on: 'macos-13'
291       xcode-toolset-version: '14.3.1'
292       configure-arguments: ${{ github.event.inputs.configure-arguments }}
293       make-arguments: ${{ github.event.inputs.make-arguments }}
294     if: needs.prepare.outputs.macos-x64 == 'true'
295 
296   build-macos-aarch64:
297     name: macos-aarch64
298     needs: prepare
299     uses: ./.github/workflows/build-macos.yml
300     with:
301       platform: macos-aarch64
302       runs-on: 'macos-14'
303       xcode-toolset-version: '15.4'
304       configure-arguments: ${{ github.event.inputs.configure-arguments }}
305       make-arguments: ${{ github.event.inputs.make-arguments }}
306     if: needs.prepare.outputs.macos-aarch64 == 'true'
307 
308   build-windows-x64:
309     name: windows-x64
310     needs: prepare
311     uses: ./.github/workflows/build-windows.yml
312     with:
313       platform: windows-x64
314       msvc-toolset-version: '14.44'
315       msvc-toolset-architecture: 'x86.x64'
316       configure-arguments: ${{ github.event.inputs.configure-arguments }}
317       make-arguments: ${{ github.event.inputs.make-arguments }}
318     if: needs.prepare.outputs.windows-x64 == 'true'
319 
320   build-windows-aarch64:
321     name: windows-aarch64
322     needs: prepare
323     uses: ./.github/workflows/build-windows.yml
324     with:
325       platform: windows-aarch64
326       msvc-toolset-version: '14.44'
327       msvc-toolset-architecture: 'arm64'
328       make-target: 'hotspot'
329       extra-conf-options: '--openjdk-target=aarch64-unknown-cygwin'
330       configure-arguments: ${{ github.event.inputs.configure-arguments }}
331       make-arguments: ${{ github.event.inputs.make-arguments }}
332     if: needs.prepare.outputs.windows-aarch64 == 'true'
333 
334   build-docs:
335     name: docs
336     needs: prepare
337     uses: ./.github/workflows/build-linux.yml
338     with:
339       platform: linux-x64
340       debug-levels: '[ "debug" ]'
341       make-target: 'docs-jdk-bundles'
342       # Make sure we never try to make full docs, since that would require a
343       # build JDK, and we do not need the additional testing of the graphs.
344       extra-conf-options: '--disable-full-docs'
345       gcc-major-version: '10'
346       configure-arguments: ${{ github.event.inputs.configure-arguments }}
347       make-arguments: ${{ github.event.inputs.make-arguments }}
348     if: needs.prepare.outputs.docs == 'true'
349 
350   ###
351   ### Test jobs
352   ###
353 
354   test-linux-x64:
355     name: linux-x64
356     needs:
357       - build-linux-x64
358     uses: ./.github/workflows/test.yml
359     with:
360       platform: linux-x64
361       bootjdk-platform: linux-x64
362       runs-on: ubuntu-22.04
363       debug-suffix: -debug
364 
365   test-linux-x64-static:
366     name: linux-x64-static
367     needs:
368       - build-linux-x64
369       - build-linux-x64-static
370     uses: ./.github/workflows/test.yml
371     with:
372       platform: linux-x64
373       bootjdk-platform: linux-x64
374       runs-on: ubuntu-22.04
375       static-suffix: "-static"
376 
377   test-macos-aarch64:
378     name: macos-aarch64
379     needs:
380       - build-macos-aarch64
381     uses: ./.github/workflows/test.yml
382     with:
383       platform: macos-aarch64
384       bootjdk-platform: macos-aarch64
385       runs-on: macos-14
386       xcode-toolset-version: '15.4'
387       debug-suffix: -debug
388 
389   test-windows-x64:
390     name: windows-x64
391     needs:
392       - build-windows-x64
393     uses: ./.github/workflows/test.yml
394     with:
395       platform: windows-x64
396       bootjdk-platform: windows-x64
397       runs-on: windows-2025
398       debug-suffix: -debug