From 0be819aee63519ad7d91cb330d2cce1df5bda521 Mon Sep 17 00:00:00 2001 From: Almond <42428221+almondnguyen@users.noreply.github.com> Date: Wed, 8 Feb 2023 12:25:46 +0700 Subject: [PATCH] CI: deploy Cirrus for a32 --- .cirrus.yml | 24 ++++++++++++++++++++++++ CI_config.sh | 32 ++++++++++++++++++++++++++++++++ CI_scripts/build.sh | 40 ++++++++++++++++++++++++++++++++++++++++ CI_scripts/checks.sh | 8 ++++++++ CI_scripts/sync.sh | 27 +++++++++++++++++++++++++++ CI_scripts/upload.sh | 7 +++++++ 6 files changed, 138 insertions(+) create mode 100644 .cirrus.yml create mode 100644 CI_config.sh create mode 100644 CI_scripts/build.sh create mode 100644 CI_scripts/checks.sh create mode 100644 CI_scripts/sync.sh create mode 100644 CI_scripts/upload.sh diff --git a/.cirrus.yml b/.cirrus.yml new file mode 100644 index 0000000..f5eb0ce --- /dev/null +++ b/.cirrus.yml @@ -0,0 +1,24 @@ +env: + # Config + CONFIG: CI_config.sh + + # Cirrus Specific Vars (Do *NOT* Change) + CIRRUS_SHELL: bash + +task: + name: "TWRP Recovery Build" + timeout_in: 120m + container: + image: ghcr.io/sushrut1101/docker:latest + cpu: 8 + memory: 20G + + Sync_script: + - curl -sL https://raw.githubusercontent.com/almondnguyen/twrp_device_samsung_a32/twrp-12.1/CI_scripts/sync.sh | bash + + Build_script: + - curl -sL https://raw.githubusercontent.com/almondnguyen/twrp_device_samsung_a32/twrp-12.1/CI_scripts/build.sh | bash + + Upload_script: + - export TIMEOUT=43200 # Link timeout (in minutes) + - curl -sL https://raw.githubusercontent.com/almondnguyen/twrp_device_samsung_a32/twrp-12.1/CI_scripts/upload.sh | bash diff --git a/CI_config.sh b/CI_config.sh new file mode 100644 index 0000000..2e49a1b --- /dev/null +++ b/CI_config.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Device +export TWRP_MANIFEST="https://github.com/minimal-manifest-twrp/platform_manifest_twrp_aosp.git" +export TWRP_BRANCH="twrp-12.1" +export DT_LINK="https://github.com/almondnguyen/twrp_device_samsung_a32 -b twrp-12.1" + +export DEVICE="a32" +export OEM="samsung" +export TARGET="recoveryimage" + +export OUTPUT="*.tar" + +# Kernel Source +# Uncomment the next line if you want to clone a kernel source. +#export KERNEL_SOURCE="https://gitlab.com/OrangeFox/kernel/mojito.git" +#export PLATFORM="sm6150" # Leave it commented if you want to clone the kernel to kernel/$OEM/$DEVICE + +# Not Recommended to Change +export SYNC_PATH="$HOME/work" # Full (absolute) path. +export USE_CCACHE=1 +export CCACHE_SIZE="50G" +export CCACHE_DIR="$HOME/work/.ccache" +export J_VAL=16 +mkdir -p $SYNC_PATH + +if [ ! -z "$PLATFORM" ]; then + export KERNEL_PATH="kernel/$OEM/$PLATFORM" +else + export KERNEL_PATH="kernel/$OEM/$DEVICE" +fi +export DT_PATH="device/$OEM/$DEVICE" diff --git a/CI_scripts/build.sh b/CI_scripts/build.sh new file mode 100644 index 0000000..ea4881f --- /dev/null +++ b/CI_scripts/build.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Source Configs +source $CONFIG + +# Change to the Source Directry +cd /root/work + +# Set-up ccache +if [ -z "$CCACHE_SIZE" ]; then + ccache -M 10G +else + ccache -M ${CCACHE_SIZE} +fi + +# Empty the VTS Makefile +# if [ -f frameworks/base/core/xsd/vts/Android.mk ]; then +# rm -rf frameworks/base/core/xsd/vts/Android.mk && touch frameworks/base/core/xsd/vts/Android.mk +# fi + +# Prepare the Build Environment +source build/envsetup.sh + +# export some Basic Vars +export ALLOW_MISSING_DEPENDENCIES=true + +# lunch the target +lunch twrp_${DEVICE}-eng || { echo "ERROR: Failed to lunch the target!" && exit 1; } + +# Build the Code +if [ -z "$J_VAL" ]; then + mka -j$(nproc --all) $TARGET || { echo "ERROR: Failed to Build TWRP!" && exit 1; } +elif [ "$J_VAL"="0" ]; then + mka $TARGET || { echo "ERROR: Failed to Build TWRP!" && exit 1; } +else + mka -j${J_VAL} $TARGET || { echo "ERROR: Failed to Build TWRP!" && exit 1; } +fi + +# Exit +exit 0 diff --git a/CI_scripts/checks.sh b/CI_scripts/checks.sh new file mode 100644 index 0000000..df52dc6 --- /dev/null +++ b/CI_scripts/checks.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Do not allow curl +curl_check=$(grep 'curl ' $CONFIG | wc -l) +if [[ $curl_check -gt 0 ]]; then + echo -e "Please dont use \'curl\' in $CONFIG". + exit 1 +fi diff --git a/CI_scripts/sync.sh b/CI_scripts/sync.sh new file mode 100644 index 0000000..6cbf73d --- /dev/null +++ b/CI_scripts/sync.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Source Vars +source $CONFIG + +# Change to the Home Directory +cd ~ + +# Clone the Sync Repo +cd $SYNC_PATH +pwd +ls + +repo init $TWRP_MANIFEST -b $TWRP_BRANCH --depth=1 -q --no-repo-verify -g default,-device,-mips,-darwin,-notdefault + +repo sync -c --no-clone-bundle --no-tags --optimized-fetch --prune --force-sync || { echo "ERROR: Failed to Sync TWRP Sources!" && exit 1; } +ls + +# Clone Trees +git clone $DT_LINK $DT_PATH || { echo "ERROR: Failed to Clone the Device Trees!" && exit 1; } + +# Clone the Kernel Sources +# only if the Kernel Source is Specified in the Config +[ ! -z "$KERNEL_SOURCE" ] && git clone --depth=1 --single-branch $KERNEL_SOURCE $KERNEL_PATH + +# Exit +exit 0 diff --git a/CI_scripts/upload.sh b/CI_scripts/upload.sh new file mode 100644 index 0000000..5d77082 --- /dev/null +++ b/CI_scripts/upload.sh @@ -0,0 +1,7 @@ +source $CONFIG +cd ~ +cd $SYNC_PATH + +cd out/target/product/${DEVICE} +curl -sL $OUTFILE https://git.io/file-transfer | sh +./transfer wet recovery.tar