Navigation Menu

Skip to content

Commit

Permalink
8287906: Rewrite of GitHub Actions (GHA) sanity tests
Browse files Browse the repository at this point in the history
8288499: Restore cancel-in-progress in GHA

Reviewed-by: phh, clanger
Backport-of: 881ff36
  • Loading branch information
gdams committed Dec 19, 2022
1 parent 8a4915e commit 674218b
Show file tree
Hide file tree
Showing 18 changed files with 1,807 additions and 2,045 deletions.
46 changes: 46 additions & 0 deletions .github/actions/config/action.yml
@@ -0,0 +1,46 @@
#
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

name: 'Config'
description: 'Read JDK Configuration Variables'
inputs:
var:
description: 'The name of the variable to read'
required: true
outputs:
value:
description: 'The value of the configuration variable'
value: ${{ steps.read-config.outputs.value }}

runs:
using: composite
steps:
- name: 'Read configuration variable from repo'
id: read-config
run: |
# Extract value from configuration file
value="$(grep -h ${{ inputs.var }}= make/conf/github-actions.conf | cut -d '=' -f 2-)"
echo "value=$value" >> $GITHUB_OUTPUT
shell: bash
80 changes: 80 additions & 0 deletions .github/actions/do-build/action.yml
@@ -0,0 +1,80 @@
#
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

name: 'Do build'
description: 'Build the JDK using make'
inputs:
make-target:
description: 'Make target(s)'
required: true
platform:
description: 'Platform name'
required: true
debug-suffix:
description: 'File name suffix denoting debug level, possibly empty'
required: false

runs:
using: composite
steps:
- name: 'Build'
id: build
run: >
make LOG=info ${{ inputs.make-target }}
|| bash ./.github/scripts/gen-build-failure-report.sh "$GITHUB_STEP_SUMMARY"
shell: bash

- name: 'Check for failure'
id: check
run: |
# Check for failure marker file
build_dir="$(ls -d build/*)"
if [[ -e $build_dir/build-failure ]]; then
# Collect relevant log files
mkdir failure-logs
cp \
$build_dir/spec.gmk \
$build_dir/build.log \
$build_dir/configure.log \
$build_dir/make-support/failure-summary.log \
$build_dir/make-support/failure-logs/* \
failure-logs/ 2> /dev/null || true
echo 'failure=true' >> $GITHUB_OUTPUT
fi
shell: bash

- name: 'Upload build logs'
uses: actions/upload-artifact@v3
with:
name: failure-logs-${{ inputs.platform }}${{ inputs.debug-suffix }}
path: failure-logs
if: steps.check.outputs.failure == 'true'

# This is the best way I found to abort the job with an error message
- name: 'Notify about build failures'
uses: actions/github-script@v6
with:
script: core.setFailed('Build failed. See summary for details.')
if: steps.check.outputs.failure == 'true'
109 changes: 109 additions & 0 deletions .github/actions/get-bootjdk/action.yml
@@ -0,0 +1,109 @@
#
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

name: 'Get BootJDK'
description: 'Download the BootJDK from cache or source location'
inputs:
platform:
description: 'Platform'
required: true
outputs:
path:
description: 'Path to the installed BootJDK'
value: ${{ steps.path-name.outputs.path }}

runs:
using: composite
steps:
- name: 'Determine platform prefix'
id: platform-prefix
run: |
# Convert platform name to upper case
platform_prefix="$(echo ${{ inputs.platform }} | tr [a-z-] [A-Z_])"
echo "value=$platform_prefix" >> $GITHUB_OUTPUT
shell: bash

- name: 'Get URL configuration'
id: url
uses: ./.github/actions/config
with:
var: ${{ steps.platform-prefix.outputs.value}}_BOOT_JDK_URL

- name: 'Get SHA256 configuration'
id: sha256
uses: ./.github/actions/config
with:
var: ${{ steps.platform-prefix.outputs.value}}_BOOT_JDK_SHA256

- name: 'Get file extension configuration'
id: ext
uses: ./.github/actions/config
with:
var: ${{ steps.platform-prefix.outputs.value}}_BOOT_JDK_EXT

- name: 'Check cache for BootJDK'
id: get-cached-bootjdk
uses: actions/cache@v3
with:
path: bootjdk/jdk
key: boot-jdk-${{ inputs.platform }}-${{ steps.sha256.outputs.value }}

# macOS is missing sha256sum
- name: 'Install sha256sum'
run: |
# Run Homebrew installation
brew install coreutils
shell: bash
if: steps.get-cached-bootjdk.outputs.cache-hit != 'true' && runner.os == 'macOS'

- name: 'Download BootJDK'
run: |
# Download BootJDK and verify checksum
mkdir -p bootjdk/jdk
mkdir -p bootjdk/unpacked
wget --progress=dot:mega -O bootjdk/jdk.${{ steps.ext.outputs.value }} '${{ steps.url.outputs.value }}'
echo '${{ steps.sha256.outputs.value }} bootjdk/jdk.${{ steps.ext.outputs.value }}' | sha256sum -c >/dev/null -
shell: bash
if: steps.get-cached-bootjdk.outputs.cache-hit != 'true'

- name: 'Unpack BootJDK'
run: |
# Unpack the BootJDK and move files to a common location
if [[ '${{ steps.ext.outputs.value }}' == 'tar.gz' ]]; then
tar -xf bootjdk/jdk.${{ steps.ext.outputs.value }} -C bootjdk/unpacked
else
unzip -q bootjdk/jdk.${{ steps.ext.outputs.value }} -d bootjdk/unpacked
fi
jdk_root="$(dirname $(find bootjdk/unpacked -name bin -type d))"
mv "$jdk_root"/* bootjdk/jdk/
shell: bash
if: steps.get-cached-bootjdk.outputs.cache-hit != 'true'

- name: 'Export path to where BootJDK is installed'
id: path-name
run: |
# Export the path
echo 'path=bootjdk/jdk' >> $GITHUB_OUTPUT
shell: bash
109 changes: 109 additions & 0 deletions .github/actions/get-bundles/action.yml
@@ -0,0 +1,109 @@
#
# Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

name: 'Get bundles'
description: 'Download resulting JDK bundles'
inputs:
platform:
description: 'Platform name'
required: true
debug-suffix:
description: 'File name suffix denoting debug level, possibly empty'
required: false
outputs:
jdk-path:
description: 'Path to the installed JDK bundle'
value: ${{ steps.path-name.outputs.jdk }}
symbols-path:
description: 'Path to the installed symbols bundle'
value: ${{ steps.path-name.outputs.symbols }}
tests-path:
description: 'Path to the installed tests bundle'
value: ${{ steps.path-name.outputs.tests }}

runs:
using: composite
steps:
- name: 'Download bundles artifact'
id: download-bundles
uses: actions/download-artifact@v3
with:
name: bundles-${{ inputs.platform }}${{ inputs.debug-suffix }}
path: bundles
continue-on-error: true

- name: 'Download bundles artifact (retry)'
uses: actions/download-artifact@v3
with:
name: bundles-${{ inputs.platform }}${{ inputs.debug-suffix }}
path: bundles
if: steps.download-bundles.outcome == 'failure'

- name: 'Unpack bundles'
run: |
if [[ -e bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.zip ]]; then
echo 'Unpacking jdk bundle...'
mkdir -p bundles/jdk
unzip -q bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.zip -d bundles/jdk
fi
if [[ -e bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then
echo 'Unpacking jdk bundle...'
mkdir -p bundles/jdk
tar -xf bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C bundles/jdk
fi
if [[ -e bundles/symbols-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then
echo 'Unpacking symbols bundle...'
mkdir -p bundles/symbols
tar -xf bundles/symbols-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C bundles/symbols
fi
if [[ -e bundles/tests-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then
echo 'Unpacking tests bundle...'
mkdir -p bundles/tests
tar -xf bundles/tests-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C bundles/tests
fi
shell: bash

- name: 'Export paths to where bundles are installed'
id: path-name
run: |
# Export the paths
jdk_dir="$GITHUB_WORKSPACE/$(dirname $(find bundles/jdk -name bin -type d))"
symbols_dir="$GITHUB_WORKSPACE/$(dirname $(find bundles/symbols -name bin -type d))"
tests_dir="$GITHUB_WORKSPACE/bundles/tests"
if [[ '${{ runner.os }}' == 'Windows' ]]; then
jdk_dir="$(cygpath $jdk_dir)"
symbols_dir="$(cygpath $symbols_dir)"
tests_dir="$(cygpath $tests_dir)"
fi
echo "jdk=$jdk_dir" >> $GITHUB_OUTPUT
echo "symbols=$symbols_dir" >> $GITHUB_OUTPUT
echo "tests=$tests_dir" >> $GITHUB_OUTPUT
shell: bash

1 comment on commit 674218b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.