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