Skip to content

Commit

Permalink
[Misc] Add criu in built jdk
Browse files Browse the repository at this point in the history
Summary: as title

Testing: CICD

Reviewers: denghui.ddh,lingjun.cg

Issue: #870
  • Loading branch information
Accelerator1996 committed Oct 17, 2024
1 parent abd83af commit 21edf21
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 0 deletions.
121 changes: 121 additions & 0 deletions .github/actions/get-criu/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#
# Copyright (c) 2024 Alibaba Group Holding Limited. 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. Alibaba 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.
#

name: 'Get criu'
description: 'Get criu assets from dragonwell-project/criu latest release'
inputs:
platform:
description: 'Platform name'
required: true
debug-suffix:
description: 'File name suffix denoting debug level, possibly empty'
required: false

runs:
using: composite
steps:
- name: 'Found bundle'
id: bundle_found
run: |
# Only support linux now.
jdk_bundle_tar_gz="$(ls build/*/bundles/jdk-*_bin${{ inputs.debug-suffix }}.tar.gz 2> /dev/null || true)"
if [[ "$jdk_bundle_tar_gz" != "" ]]; then
jdk_bundle_name=${jdk_bundle_tar_gz##*/}
echo "jdk_pkg=$jdk_bundle_tar_gz" >> $GITHUB_OUTPUT
echo "jdk_pkg_name=$jdk_bundle_name" >> $GITHUB_OUTPUT
echo "decompress_cmd=tar zxf" >> $GITHUB_OUTPUT
echo "decompress_redirect_flag=-C" >> $GITHUB_OUTPUT
echo "decompress_extra_cmd=--strip-components=1" >> $GITHUB_OUTPUT
echo "compress_cmd=tar zcf" >> $GITHUB_OUTPUT
else
echo "jdk_pkg=" >> $GITHUB_OUTPUT
echo "jdk_pkg_name=" >> $GITHUB_OUTPUT
echo "decompress_cmd=" >> $GITHUB_OUTPUT
echo "decompress_redirect_flag=" >> $GITHUB_OUTPUT
echo "decompress_extra_cmd=" >> $GITHUB_OUTPUT
echo "compress_cmd=" >> $GITHUB_OUTPUT
fi
shell: bash

- name: 'Bundle decompression'
id: bundle_decompress
run: |
mkdir -p bundle_workdir
${{ steps.bundle_found.outputs.decompress_cmd }} ${{ steps.bundle_found.outputs.jdk_pkg }} ${{ steps.bundle_found.outputs.decompress_redirect_flag }} bundle_workdir ${{ steps.bundle_found.outputs.decompress_extra_cmd }}
bin_path=$(find bundle_workdir -name bin)
pwd=$(pwd)
java_home_path=${bin_path%%'/bin'*}
echo "bundle_home=$pwd/bundle_workdir" >> $GITHUB_OUTPUT
echo "java_home=$pwd/$java_home_path" >> $GITHUB_OUTPUT
shell: bash
if: steps.bundle_found.outputs.jdk_pkg != '' && steps.bundle_found.outputs.decompress_cmd != ''

- name: 'Get latest release'
id: get_criu_release
uses: actions/github-script@v6
with:
script: |
const repoOwner = 'dragonwell-project';
const repoName = 'criu';
const { data: release } = await github.repos.getLatestRelease({
owner: repoOwner,
repo: repoName,
});
return release;
- name: 'Download asset and copy into jdk'
run: |
if [ "${{ inputs.platform }}" = "linux-aarch64" ];then
keyword=arm64
elif [ "${{ inputs.platform }}" = "linux-x64" ];then
keyword=x64
else
echo "unsupport platform ${{ inputs.platform }}"
exit 1
fi
url=""
echo "${{ steps.get_criu_release.outputs.assets }}" | jq -c '.[]' | while read asset; do
name="$(echo ${asset} | jq -r '.name')"
if [ -n "$(echo ${name} | grep ${keyword})" ];then
url="$(echo ${asset} | jq -r '.url')"
break
fi
done
if [ -n "${url}" ];then
curl -OLSk -C - --retry 5 ${url} -o criu.tar.gz
tar zxvf criu.tar.gz
chmod +x criu
mv criu ${{ steps.bundle_decompress.outputs.java_home }}/lib/
fi
shell: bash

- name: 'Regenerate bundle'
run: |
cd ${{ steps.bundle_decompress.outputs.bundle_home }}
if [[ -f "${{ steps.bundle_found.outputs.jdk_pkg_name }}" ]]; then
rm -rf ${{ steps.bundle_found.outputs.jdk_pkg_name }}
fi
${{ steps.bundle_found.outputs.compress_cmd }} ${{ steps.bundle_found.outputs.jdk_pkg_name }} *
cd -
mv -f ${{ steps.bundle_decompress.outputs.bundle_home }}/${{ steps.bundle_found.outputs.jdk_pkg_name }} ${{ steps.bundle_found.outputs.jdk_pkg }}
shell: bash
7 changes: 7 additions & 0 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ jobs:
platform: ${{ inputs.platform }}
debug-suffix: '${{ matrix.suffix }}'

- name: 'Get criu'
id: get-criu
uses: ./.github/actions/get-criu
with:
platform: ${{ inputs.platform }}
debug-suffix: '${{ matrix.suffix }}'

- name: 'Upload bundles'
uses: ./.github/actions/upload-bundles
with:
Expand Down

0 comments on commit 21edf21

Please sign in to comment.