github-ci: run CI pipeline on oniro-runner and CI optimizations #28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Pull Sources from Manifest and build | |
on: | |
push: | |
branches: | |
- '*' | |
pull_request: | |
branches: | |
- '*' | |
env: | |
CI_MANIFEST_NAME: default.xml | |
jobs: | |
pull_sources: | |
runs-on: oniro-runner | |
container: | |
image: swr.cn-south-1.myhuaweicloud.com/openharmony-docker/docker_oh_standard:3.2 | |
steps: | |
- uses: actions/checkout@v4 | |
- run: apt update | |
- name: Set up manifest workspace | |
run: | | |
# Tell git this repository is safe even if cloned with a different uid | |
git config --global --add safe.directory $GITHUB_WORKSPACE | |
# The repo tool seems to insist on having a branch checked out or | |
# something like that... Without this we get errors like | |
# fatal: couldn't find remote ref refs/heads/master | |
cd $GITHUB_WORKSPACE | |
git checkout -b master | |
# The repo command does not like shallow repos | |
if [ "$(git rev-parse --is-shallow-repository)" = "true" ] ; then | |
git fetch --unshallow ; | |
fi | |
- name: Cache restore gitee repositories | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
/bin/repo | |
/__w/repo-mirrors/developtools_smartperf_host.git | |
/__w/repo-mirrors/developtools_profiler.git | |
/__w/repo-mirrors/docs.git | |
/__w/repo-mirrors/global_i18n.git | |
/__w/repo-mirrors/multimedia_av_codec.git | |
/__w/repo-mirrors/update_updater.git | |
/__w/repo-mirrors/xts_acts.git | |
/__w/repo-mirrors/third_party_mindspore.git | |
/__w/repo-mirrors/third_party_vk-gl-cts.git | |
/__w/repo-mirrors/device_board_hihope.git | |
/__w/repo-mirrors/device_soc_rockchip.git | |
key: | |
cache-repos-${{ hashFiles('**/*.xml') }} | |
restore-keys: | |
cache-repos- | |
- name: Set up git-repo | |
run: | | |
if [ ! -f /bin/repo ]; then | |
curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o /bin/repo | |
chmod a+x /bin/repo | |
fi | |
- name: Sync mirror | |
run: | | |
# Create/maintain a mirror of all manifest repositories in runner | |
# persistent storage, and use that as reference when initializing the | |
# build repo, effectively reducing the time spent fetching git repos to | |
# almost nothing. | |
# | |
# If for some reason, the repo mirror becomes corrupted, a pipeline with | |
# $REBUILD_REPO_MIRROR set to a non-empty value will remove the entire | |
# mirror, and rebuild it from scratch. | |
# | |
# Note the use of fd 9 to hold a lock while accessing the $REPO_MIRROR | |
# path, so we can handle parallel jobs. First we open the lock file on fd | |
# 9, then we lock it, and close/unlock it after repo sync. | |
REPO_MIRROR="/__w/repo-mirrors" ; | |
mkdir -p $(dirname $REPO_MIRROR) ; | |
exec 9>$REPO_MIRROR.lock ; flock 9 ; | |
if [ -n "$REBUILD_REPO_MIRROR" ] ; then | |
rm -rf "$REPO_MIRROR" ; | |
fi ; | |
if [ ! -e "$REPO_MIRROR" ] ; then | |
echo "Creating new repo mirror @ $REPO_MIRROR" ; | |
mkdir -p "$REPO_MIRROR" ; | |
pushd "$REPO_MIRROR" ; | |
repo init -u "$GITHUB_WORKSPACE" -m "$CI_MANIFEST_NAME" --mirror ; | |
else | |
echo "Reusing repo mirror @ $REPO_MIRROR" ; | |
pushd "$REPO_MIRROR" ; | |
repo init -u "$GITHUB_WORKSPACE" -m "$CI_MANIFEST_NAME"; | |
fi ; | |
repo sync -c --no-repo-verify --force-sync -v; | |
popd ; | |
- name: Cache save gitee repositories | |
uses: actions/cache/save@v4 | |
with: | |
path: | | |
/bin/repo | |
/__w/repo-mirrors/developtools_smartperf_host.git | |
/__w/repo-mirrors/developtools_profiler.git | |
/__w/repo-mirrors/docs.git | |
/__w/repo-mirrors/global_i18n.git | |
/__w/repo-mirrors/multimedia_av_codec.git | |
/__w/repo-mirrors/update_updater.git | |
/__w/repo-mirrors/xts_acts.git | |
/__w/repo-mirrors/third_party_mindspore.git | |
/__w/repo-mirrors/third_party_vk-gl-cts.git | |
/__w/repo-mirrors/device_board_hihope.git | |
/__w/repo-mirrors/device_soc_rockchip.git | |
key: | |
cache-repos-${{ hashFiles('**/*.xml') }} | |
- name: Fetch sources | |
run: | | |
# Create the build environment in a repo subdir | |
mkdir repo && cd repo | |
repo init \ | |
--reference /__w/repo-mirrors \ | |
--manifest-url "$GITHUB_WORKSPACE" \ | |
--manifest-name "$CI_MANIFEST_NAME" | |
repo sync -c --no-repo-verify --force-sync -v | |
repo forall -c 'git lfs pull' | |
# Release repo mirror lock if held | |
if [ -n "$REPO_MIRROR_ARG" ] ; then exec 9>&- ; fi | |
- name: Cache restore OpenHarmony prebuilts | |
uses: actions/cache/restore@v4 | |
with: | |
path: | | |
/__w/manifest/manifest/openharmony_prebuilts | |
key: | |
cache-openharmony-prebuilts-${{ hashFiles('**/*.xml') }} | |
restore-keys: | |
cache-openharmony-prebuilts- | |
- name: Download prebuilts | |
run: | | |
cd repo && ./build/prebuilts_download.sh | |
- name: Cache save OpenHarmony prebuilts | |
uses: actions/cache/save@v4 | |
with: | |
path: | | |
/__w/manifest/manifest/openharmony_prebuilts | |
key: | |
cache-openharmony-prebuilts-${{ hashFiles('**/*.xml') }} | |
- name: ccache | |
uses: hendrikmuhs/[email protected] | |
- name: Build | |
run: | | |
# a shared ccache is used to speed up the build | |
ln -sf $GITHUB_WORKSPACE/.ccache /root/.ccache | |
cd repo | |
CCACHE_BASE="" CCACHE_DIR=$GITHUB_WORKSPACE/.ccache | |
./build.sh --ccache --product-name rk3568 | |
echo "ccache size: " | |
du -sh $GITHUB_WORKSPACE/.ccache | |
echo "/root/.ccache size: " | |
du -sh /root/.ccache | |
- name: Archive board image artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: rk3568 | |
path: /__w/manifest/manifest/repo/out/rk3568/packages/phone/images/* |