CI: deploy Cirrus for a32

This commit is contained in:
Almond 2023-02-08 12:25:46 +07:00
commit 0be819aee6
6 changed files with 138 additions and 0 deletions

24
.cirrus.yml Normal file
View file

@ -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

32
CI_config.sh Normal file
View file

@ -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"

40
CI_scripts/build.sh Normal file
View file

@ -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

8
CI_scripts/checks.sh Normal file
View file

@ -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

27
CI_scripts/sync.sh Normal file
View file

@ -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

7
CI_scripts/upload.sh Normal file
View file

@ -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