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       - master
 32       - pr/*
 33   workflow_dispatch:
 34     inputs:
 35       platforms:
 36         description: 'Platform(s) to execute on (comma separated, e.g. "linux-x64, macos, aarch64")'
 37         required: true
 38         default: 'linux-x64, linux-x86, linux-x64-variants, linux-cross-compile, macos-x64, macos-aarch64, windows-x64, windows-aarch64, docs'
 39       configure-arguments:
 40         description: 'Additional configure arguments'
 41         required: false
 42       make-arguments:
 43         description: 'Additional make arguments'
 44         required: false
 45 
 46 concurrency:
 47   group: ${{ github.workflow }}-${{ github.ref }}
 48   cancel-in-progress: true
 49 
 50 jobs:
 51 
 52   ###
 53   ### Determine platforms to include
 54   ###
 55 
 56   select:
 57     name: 'Select platforms'
 58     runs-on: ubuntu-22.04
 59     outputs:
 60       linux-x64: ${{ steps.include.outputs.linux-x64 }}
 61       linux-x86: ${{ steps.include.outputs.linux-x86 }}
 62       linux-x64-variants: ${{ steps.include.outputs.linux-x64-variants }}
 63       linux-cross-compile: ${{ steps.include.outputs.linux-cross-compile }}
 64       macos-x64: ${{ steps.include.outputs.macos-x64 }}
 65       macos-aarch64: ${{ steps.include.outputs.macos-aarch64 }}
 66       windows-x64: ${{ steps.include.outputs.windows-x64 }}
 67       windows-aarch64: ${{ steps.include.outputs.windows-aarch64 }}
 68       docs: ${{ steps.include.outputs.docs }}
 69 
 70     steps:
 71         # This function must be inlined in main.yml, or we'd be forced to checkout the repo
 72       - name: 'Check what jobs to run'
 73         id: include
 74         run: |
 75           # Determine which platform jobs to run
 76 
 77           # Returns 'true' if the input platform list matches any of the platform monikers given as argument,
 78           # 'false' otherwise.
 79           # arg $1: platform name or names to look for
 80           function check_platform() {
 81             if [[ $GITHUB_EVENT_NAME == workflow_dispatch ]]; then
 82               input='${{ github.event.inputs.platforms }}'
 83             elif [[ $GITHUB_EVENT_NAME == push ]]; then
 84               if [[ '${{ !secrets.JDK_SUBMIT_FILTER || startsWith(github.ref, 'refs/heads/submit/') }}' == 'false' ]]; then
 85                 # If JDK_SUBMIT_FILTER is set, and this is not a "submit/" branch, don't run anything
 86                 >&2 echo 'JDK_SUBMIT_FILTER is set and not a "submit/" branch'
 87                 echo 'false'
 88                 return
 89               else
 90                 input='${{ secrets.JDK_SUBMIT_PLATFORMS }}'
 91               fi
 92             fi
 93 
 94             normalized_input="$(echo ,$input, | tr -d ' ')"
 95             if [[ "$normalized_input" == ",," ]]; then
 96               # For an empty input, assume all platforms should run
 97               echo 'true'
 98               return
 99             else
100               # Check for all acceptable platform names
101               for part in $* ; do
102                 if echo "$normalized_input" | grep -q -e ",$part," ; then
103                   echo 'true'
104                   return
105                 fi
106               done
107             fi
108 
109             echo 'false'
110           }
111 
112           echo "linux-x64=$(check_platform linux-x64 linux x64)" >> $GITHUB_OUTPUT
113           echo "linux-x86=$(check_platform linux-x86 linux x86)" >> $GITHUB_OUTPUT
114           echo "linux-x64-variants=$(check_platform linux-x64-variants variants)" >> $GITHUB_OUTPUT
115           echo "linux-cross-compile=$(check_platform linux-cross-compile cross-compile)" >> $GITHUB_OUTPUT
116           echo "macos-x64=$(check_platform macos-x64 macos x64)" >> $GITHUB_OUTPUT
117           echo "macos-aarch64=$(check_platform macos-aarch64 macos aarch64)" >> $GITHUB_OUTPUT
118           echo "windows-x64=$(check_platform windows-x64 windows x64)" >> $GITHUB_OUTPUT
119           echo "windows-aarch64=$(check_platform windows-aarch64 windows aarch64)" >> $GITHUB_OUTPUT
120           echo "docs=$(check_platform docs)" >> $GITHUB_OUTPUT
121 
122   ###
123   ### Build jobs
124   ###
125 
126   build-linux-x64:
127     name: linux-x64
128     needs: select
129     uses: ./.github/workflows/build-linux.yml
130     with:
131       platform: linux-x64
132       gcc-major-version: '10'
133       configure-arguments: ${{ github.event.inputs.configure-arguments }}
134       make-arguments: ${{ github.event.inputs.make-arguments }}
135     if: needs.select.outputs.linux-x64 == 'true'
136 
137   build-linux-x86:
138     name: linux-x86
139     needs: select
140     uses: ./.github/workflows/build-linux.yml
141     with:
142       platform: linux-x86
143       gcc-major-version: '10'
144       gcc-package-suffix: '-multilib'
145       apt-architecture: 'i386'
146       # Some multilib libraries do not have proper inter-dependencies, so we have to
147       # install their dependencies manually.
148       apt-extra-packages: 'libfreetype-dev:i386 libtiff-dev:i386 libcupsimage2-dev:i386 libc6-i386 libgcc-s1:i386 libstdc++6:i386'
149       extra-conf-options: '--with-target-bits=32'
150       configure-arguments: ${{ github.event.inputs.configure-arguments }}
151       make-arguments: ${{ github.event.inputs.make-arguments }}
152     if: needs.select.outputs.linux-x86 == 'true'
153 
154   build-linux-x64-hs-nopch:
155     name: linux-x64-hs-nopch
156     needs: select
157     uses: ./.github/workflows/build-linux.yml
158     with:
159       platform: linux-x64
160       make-target: 'hotspot'
161       debug-levels: '[ "debug" ]'
162       gcc-major-version: '10'
163       extra-conf-options: '--disable-precompiled-headers'
164       configure-arguments: ${{ github.event.inputs.configure-arguments }}
165       make-arguments: ${{ github.event.inputs.make-arguments }}
166     if: needs.select.outputs.linux-x64-variants == 'true'
167 
168   build-linux-x64-hs-zero:
169     name: linux-x64-hs-zero
170     needs: select
171     uses: ./.github/workflows/build-linux.yml
172     with:
173       platform: linux-x64
174       make-target: 'hotspot'
175       debug-levels: '[ "debug" ]'
176       gcc-major-version: '10'
177       extra-conf-options: '--with-jvm-variants=zero --disable-precompiled-headers'
178       configure-arguments: ${{ github.event.inputs.configure-arguments }}
179       make-arguments: ${{ github.event.inputs.make-arguments }}
180     if: needs.select.outputs.linux-x64-variants == 'true'
181 
182   build-linux-x64-hs-minimal:
183     name: linux-x64-hs-minimal
184     needs: select
185     uses: ./.github/workflows/build-linux.yml
186     with:
187       platform: linux-x64
188       make-target: 'hotspot'
189       debug-levels: '[ "debug" ]'
190       gcc-major-version: '10'
191       extra-conf-options: '--with-jvm-variants=minimal --disable-precompiled-headers'
192       configure-arguments: ${{ github.event.inputs.configure-arguments }}
193       make-arguments: ${{ github.event.inputs.make-arguments }}
194     if: needs.select.outputs.linux-x64-variants == 'true'
195 
196   build-linux-x64-hs-optimized:
197     name: linux-x64-hs-optimized
198     needs: select
199     uses: ./.github/workflows/build-linux.yml
200     with:
201       platform: linux-x64
202       make-target: 'hotspot'
203       # Technically this is not the "debug" level, but we can't inject a new matrix state for just this job
204       debug-levels: '[ "debug" ]'
205       gcc-major-version: '10'
206       extra-conf-options: '--with-debug-level=optimized --disable-precompiled-headers'
207       configure-arguments: ${{ github.event.inputs.configure-arguments }}
208       make-arguments: ${{ github.event.inputs.make-arguments }}
209     if: needs.select.outputs.linux-x64-variants == 'true'
210 
211   build-linux-cross-compile:
212     name: linux-cross-compile
213     needs:
214       - select
215     uses: ./.github/workflows/build-cross-compile.yml
216     with:
217       gcc-major-version: '10'
218       configure-arguments: ${{ github.event.inputs.configure-arguments }}
219       make-arguments: ${{ github.event.inputs.make-arguments }}
220     if: needs.select.outputs.linux-cross-compile == 'true'
221 
222   build-macos-x64:
223     name: macos-x64
224     needs: select
225     uses: ./.github/workflows/build-macos.yml
226     with:
227       platform: macos-x64
228       runs-on: 'macos-13'
229       xcode-toolset-version: '14.3.1'
230       configure-arguments: ${{ github.event.inputs.configure-arguments }}
231       make-arguments: ${{ github.event.inputs.make-arguments }}
232     if: needs.select.outputs.macos-x64 == 'true'
233 
234   build-macos-aarch64:
235     name: macos-aarch64
236     needs: select
237     uses: ./.github/workflows/build-macos.yml
238     with:
239       platform: macos-aarch64
240       runs-on: 'macos-14'
241       xcode-toolset-version: '14.3.1'
242       configure-arguments: ${{ github.event.inputs.configure-arguments }}
243       make-arguments: ${{ github.event.inputs.make-arguments }}
244     if: needs.select.outputs.macos-aarch64 == 'true'
245 
246   build-windows-x64:
247     name: windows-x64
248     needs: select
249     uses: ./.github/workflows/build-windows.yml
250     with:
251       platform: windows-x64
252       msvc-toolset-version: '14.29'
253       msvc-toolset-architecture: 'x86.x64'
254       configure-arguments: ${{ github.event.inputs.configure-arguments }}
255       make-arguments: ${{ github.event.inputs.make-arguments }}
256     if: needs.select.outputs.windows-x64 == 'true'
257 
258   build-windows-aarch64:
259     name: windows-aarch64
260     needs: select
261     uses: ./.github/workflows/build-windows.yml
262     with:
263       platform: windows-aarch64
264       msvc-toolset-version: '14.29'
265       msvc-toolset-architecture: 'arm64'
266       make-target: 'hotspot'
267       extra-conf-options: '--openjdk-target=aarch64-unknown-cygwin'
268       configure-arguments: ${{ github.event.inputs.configure-arguments }}
269       make-arguments: ${{ github.event.inputs.make-arguments }}
270     if: needs.select.outputs.windows-aarch64 == 'true'
271 
272   build-docs:
273     name: docs
274     needs: select
275     uses: ./.github/workflows/build-linux.yml
276     with:
277       platform: linux-x64
278       debug-levels: '[ "debug" ]'
279       make-target: 'docs-jdk-bundles'
280       # Make sure we never try to make full docs, since that would require a
281       # build JDK, and we do not need the additional testing of the graphs.
282       extra-conf-options: '--disable-full-docs'
283       gcc-major-version: '10'
284       configure-arguments: ${{ github.event.inputs.configure-arguments }}
285       make-arguments: ${{ github.event.inputs.make-arguments }}
286     if: needs.select.outputs.docs == 'true'
287 
288   ###
289   ### Test jobs
290   ###
291 
292   test-linux-x64:
293     name: linux-x64
294     needs:
295       - build-linux-x64
296     uses: ./.github/workflows/test.yml
297     with:
298       platform: linux-x64
299       bootjdk-platform: linux-x64
300       runs-on: ubuntu-22.04
301 
302   test-linux-x86:
303     name: linux-x86
304     needs:
305       - build-linux-x86
306     uses: ./.github/workflows/test.yml
307     with:
308       platform: linux-x86
309       bootjdk-platform: linux-x64
310       runs-on: ubuntu-22.04
311 
312   test-macos-x64:
313     name: macos-x64
314     needs:
315       - build-macos-x64
316     uses: ./.github/workflows/test.yml
317     with:
318       platform: macos-x64
319       bootjdk-platform: macos-x64
320       runs-on: macos-13
321 
322   test-macos-aarch64:
323     name: macos-aarch64
324     needs:
325       - build-macos-aarch64
326     uses: ./.github/workflows/test.yml
327     with:
328       platform: macos-aarch64
329       bootjdk-platform: macos-aarch64
330       runs-on: macos-14
331 
332   test-windows-x64:
333     name: windows-x64
334     needs:
335       - build-windows-x64
336     uses: ./.github/workflows/test.yml
337     with:
338       platform: windows-x64
339       bootjdk-platform: windows-x64
340       runs-on: windows-2019
341 
342   # Remove bundles so they are not misconstrued as binary distributions from the JDK project
343   remove-bundles:
344     name: 'Remove bundle artifacts'
345     runs-on: ubuntu-22.04
346     if: always()
347     needs:
348       - build-linux-x64
349       - build-linux-x86
350       - build-linux-x64-hs-nopch
351       - build-linux-x64-hs-zero
352       - build-linux-x64-hs-minimal
353       - build-linux-x64-hs-optimized
354       - build-linux-cross-compile
355       - build-macos-x64
356       - build-macos-aarch64
357       - build-windows-x64
358       - build-windows-aarch64
359       - test-linux-x64
360       - test-linux-x86
361       - test-macos-x64
362       - test-windows-x64
363 
364     steps:
365         # Hack to get hold of the api environment variables that are only defined for actions
366       - name: 'Get API configuration'
367         id: api
368         uses: actions/github-script@v7
369         with:
370           script: 'return { url: process.env["ACTIONS_RUNTIME_URL"], token: process.env["ACTIONS_RUNTIME_TOKEN"] }'
371 
372       - name: 'Remove bundle artifacts'
373         run: |
374           # Find and remove all bundle artifacts
375           ALL_ARTIFACT_URLS="$(curl -s \
376               -H 'Accept: application/json;api-version=6.0-preview' \
377               -H 'Authorization: Bearer ${{ fromJson(steps.api.outputs.result).token }}' \
378               '${{ fromJson(steps.api.outputs.result).url }}_apis/pipelines/workflows/${{ github.run_id }}/artifacts?api-version=6.0-preview')"
379           BUNDLE_ARTIFACT_URLS="$(echo "$ALL_ARTIFACT_URLS" | jq -r -c '.value | map(select(.name|startswith("bundles-"))) | .[].url')"
380           for url in $BUNDLE_ARTIFACT_URLS; do
381             echo "Removing $url"
382             curl -s \
383                 -H 'Accept: application/json;api-version=6.0-preview' \
384                 -H 'Authorization: Bearer ${{ fromJson(steps.api.outputs.result).token }}' \
385                 -X DELETE "$url" \
386             || echo "Failed to remove bundle"
387           done