1 #
  2 # Copyright (c) 2022, 2023, 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: 'Run tests'
 27 
 28 on:
 29   workflow_call:
 30     inputs:
 31       platform:
 32         required: true
 33         type: string
 34       bootjdk-platform:
 35         required: true
 36         type: string
 37       runs-on:
 38         required: true
 39         type: string
 40       xcode-toolset-version:
 41         required: false
 42         type: string
 43 
 44 env:
 45   # These are needed to make the MSYS2 bash work properly
 46   MSYS2_PATH_TYPE: minimal
 47   CHERE_INVOKING: 1
 48 
 49 jobs:
 50   test:
 51     name: test
 52     runs-on: ${{ inputs.runs-on }}
 53     defaults:
 54       run:
 55         shell: bash
 56 
 57     strategy:
 58       fail-fast: false
 59       matrix:
 60         test-name:
 61           - 'jdk/tier1 part 1'
 62           - 'jdk/tier1 part 2'
 63           - 'jdk/tier1 part 3'
 64           - 'langtools/tier1'
 65           - 'hs/tier1 common'
 66           - 'hs/tier1 compiler part 1'
 67           - 'hs/tier1 compiler part 2'
 68           - 'hs/tier1 compiler part 3'
 69           - 'hs/tier1 compiler not-xcomp'
 70           - 'hs/tier1 gc'
 71           - 'hs/tier2_gc_shenandoah shenandoah tier2'
 72           - 'hs/tier3_gc_shenandoah shenandoah tier3'
 73           - 'hs/tier1 runtime'
 74           - 'hs/tier1 serviceability'
 75           - 'lib-test/tier1'
 76 
 77         include:
 78           - test-name: 'jdk/tier1 part 1'
 79             test-suite: 'test/jdk/:tier1_part1'
 80 
 81           - test-name: 'jdk/tier1 part 2'
 82             test-suite: 'test/jdk/:tier1_part2'
 83 
 84           - test-name: 'jdk/tier1 part 3'
 85             test-suite: 'test/jdk/:tier1_part3'
 86 
 87           - test-name: 'langtools/tier1'
 88             test-suite: 'test/langtools/:tier1'
 89 
 90           - test-name: 'hs/tier1 common'
 91             test-suite: 'test/hotspot/jtreg/:tier1_common'
 92             debug-suffix: -debug
 93 
 94           - test-name: 'hs/tier1 compiler part 1'
 95             test-suite: 'test/hotspot/jtreg/:tier1_compiler_1'
 96             debug-suffix: -debug
 97 
 98           - test-name: 'hs/tier1 compiler part 2'
 99             test-suite: 'test/hotspot/jtreg/:tier1_compiler_2'
100             debug-suffix: -debug
101 
102           - test-name: 'hs/tier1 compiler part 3'
103             test-suite: 'test/hotspot/jtreg/:tier1_compiler_3'
104             debug-suffix: -debug
105 
106           - test-name: 'hs/tier1 compiler not-xcomp'
107             test-suite: 'test/hotspot/jtreg/:tier1_compiler_not_xcomp'
108             debug-suffix: -debug
109 
110           - test-name: 'hs/tier1 gc'
111             test-suite: 'test/hotspot/jtreg/:tier1_gc'
112             debug-suffix: -debug
113 
114           - test-name: 'hs/tier2_gc_shenandoah shenandoah tier2'
115             test-suite: 'test/hotspot/jtreg/:tier2_gc_shenandoah'
116             debug-suffix: -debug
117 
118           - test-name: 'hs/tier3_gc_shenandoah shenandoah tier3'
119             test-suite: 'test/hotspot/jtreg/:tier3_gc_shenandoah'
120             debug-suffix: -debug
121 
122           - test-name: 'hs/tier1 runtime'
123             test-suite: 'test/hotspot/jtreg/:tier1_runtime'
124             debug-suffix: -debug
125 
126           - test-name: 'hs/tier1 serviceability'
127             test-suite: 'test/hotspot/jtreg/:tier1_serviceability'
128             debug-suffix: -debug
129 
130           - test-name: 'lib-test/tier1'
131             test-suite: 'test/lib-test/:tier1'
132             debug-suffix: -debug
133 
134     steps:
135       - name: 'Checkout the JDK source'
136         uses: actions/checkout@v4
137 
138       - name: 'Get MSYS2'
139         uses: ./.github/actions/get-msys2
140         if: runner.os == 'Windows'
141 
142       - name: 'Get the BootJDK'
143         id: bootjdk
144         uses: ./.github/actions/get-bootjdk
145         with:
146           platform: ${{ inputs.bootjdk-platform }}
147 
148       - name: 'Get JTReg'
149         id: jtreg
150         uses: ./.github/actions/get-jtreg
151 
152       - name: 'Get bundles'
153         id: bundles
154         uses: ./.github/actions/get-bundles
155         with:
156           platform: ${{ inputs.platform }}
157           debug-suffix: ${{ matrix.debug-suffix }}
158 
159       - name: 'Install dependencies'
160         run: |
161           # On macOS we need to install some dependencies for testing
162           brew install make
163           sudo xcode-select --switch /Applications/Xcode_${{ inputs.xcode-toolset-version }}.app/Contents/Developer
164           # This will make GNU make available as 'make' and not only as 'gmake'
165           echo '/usr/local/opt/make/libexec/gnubin' >> $GITHUB_PATH
166         if: runner.os == 'macOS'
167 
168       - name: 'Set PATH'
169         id: path
170         run: |
171           # We need a minimal PATH on Windows
172           # Set PATH to "", so just GITHUB_PATH is included
173           if [[ '${{ runner.os }}' == 'Windows' ]]; then
174             echo "value=" >> $GITHUB_OUTPUT
175           else
176             echo "value=$PATH" >> $GITHUB_OUTPUT
177           fi
178 
179       - name: 'Run tests'
180         id: run-tests
181         run: >
182           make test-prebuilt
183           TEST='${{ matrix.test-suite }}'
184           BOOT_JDK=${{ steps.bootjdk.outputs.path }}
185           JT_HOME=${{ steps.jtreg.outputs.path }}
186           JDK_IMAGE_DIR=${{ steps.bundles.outputs.jdk-path }}
187           SYMBOLS_IMAGE_DIR=${{ steps.bundles.outputs.symbols-path }}
188           TEST_IMAGE_DIR=${{ steps.bundles.outputs.tests-path }}
189           JTREG='JAVA_OPTIONS=-XX:-CreateCoredumpOnCrash;VERBOSE=fail,error,time;KEYWORDS=!headful'
190           && bash ./.github/scripts/gen-test-summary.sh "$GITHUB_STEP_SUMMARY" "$GITHUB_OUTPUT"
191         env:
192           PATH: ${{ steps.path.outputs.value }}
193 
194         # This is a separate step, since if the markdown from a step gets bigger than
195         # 1024 kB it is skipped, but then the short summary above is still generated
196       - name: 'Generate test report'
197         run: bash ./.github/scripts/gen-test-results.sh "$GITHUB_STEP_SUMMARY"
198         if: always()
199 
200       - name: 'Package test results'
201         id: package
202         run: |
203           # Package test-results and relevant parts of test-support
204           mkdir results
205 
206           if [[ -d build/run-test-prebuilt/test-results ]]; then
207             cd build/run-test-prebuilt/test-results/
208             zip -r -9 "$GITHUB_WORKSPACE/results/test-results.zip" .
209             cd $GITHUB_WORKSPACE
210           else
211             echo '::warning ::Missing test-results directory'
212           fi
213 
214           if [[ -d build/run-test-prebuilt/test-support ]]; then
215             cd build/run-test-prebuilt/test-support/
216             zip -r -9 "$GITHUB_WORKSPACE/results/test-support.zip" . -i *.jtr -i */hs_err*.log -i */replay*.log
217             cd $GITHUB_WORKSPACE
218           else
219             echo '::warning ::Missing test-support directory'
220           fi
221 
222           artifact_name="results-${{ inputs.platform }}-$(echo ${{ matrix.test-name }} | tr '/ ' '__')"
223           echo "artifact-name=$artifact_name" >> $GITHUB_OUTPUT
224         if: always()
225 
226       - name: 'Upload test results'
227         uses: actions/upload-artifact@v4
228         with:
229           path: results
230           name: ${{ steps.package.outputs.artifact-name }}
231         if: always()
232 
233         # This is the best way I found to abort the job with an error message
234       - name: 'Notify about test failures'
235         uses: actions/github-script@v7
236         with:
237           script: core.setFailed('${{ steps.run-tests.outputs.error-message }}')
238         if: steps.run-tests.outputs.failure == 'true'