Skip to content

Commit

Permalink
feat: add syncbot and pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
ponces committed May 27, 2024
1 parent f732a41 commit e5f6b30
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 11 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Sync

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'

jobs:
setup:
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build Docker image
run: |
cd build
docker build -t td .
docker run --name td -it --detach --privileged --env GITHUB_API_TOKEN=${{ secrets.GH_TOKEN }} td /bin/bash
docker exec td /bin/sh -c "git clone https://${{ secrets.GH_TOKEN }}@github.com/ponces/treble_aosp"
sync:
needs: setup
runs-on: self-hosted
steps:
- name: Sync with TrebleDroid
run: docker exec td /bin/sh -c "bash treble_aosp/sync.sh"

cleanup:
needs: sync
runs-on: self-hosted
if: ${{ always() }}
steps:
- name: Cleanup
run: |
docker stop td || true
docker system prune -f
20 changes: 9 additions & 11 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ BL=$PWD/treble_aosp
BD=$HOME/builds

initRepos() {
if [ ! -d .repo ]; then
echo "--> Initializing workspace"
repo init -u https://android.googlesource.com/platform/manifest -b android-14.0.0_r37 --git-lfs
echo

echo "--> Preparing local manifest"
mkdir -p .repo/local_manifests
cp $BL/build/default.xml .repo/local_manifests/default.xml
cp $BL/build/remove.xml .repo/local_manifests/remove.xml
echo
fi
echo "--> Initializing workspace"
repo init -u https://android.googlesource.com/platform/manifest -b android-14.0.0_r37 --git-lfs
echo

echo "--> Preparing local manifest"
mkdir -p .repo/local_manifests
cp $BL/build/default.xml .repo/local_manifests/default.xml
cp $BL/build/remove.xml .repo/local_manifests/remove.xml
echo
}

syncRepos() {
Expand Down
78 changes: 78 additions & 0 deletions sync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/bash

echo
echo "--------------------------------------"
echo " AOSP 14.0 Syncbot "
echo " by "
echo " ponces "
echo "--------------------------------------"
echo

set -e

BL=$PWD/treble_aosp
TD="android-14.0"

initRepos() {
echo "--> Getting latest upstream version"
aosp=$(curl -sL https://github.com/TrebleDroid/treble_manifest/raw/android-14.0/replace.xml | grep -oP "android-14.0.0_r\d+" | head -1)

echo "--> Initializing workspace"
repo init -u https://android.googlesource.com/platform/manifest -b "$aosp"
echo

echo "--> Preparing local manifest"
if [ -d .repo/local_manifests ]; then
(cd .repo/local_manifests; git fetch; git reset --hard; git checkout origin/$TD)
else
git clone https://github.com/TrebleDroid/treble_manifest .repo/local_manifests -b $TD
fi
echo
}

syncRepos() {
echo "--> Syncing repos"
repo sync -c --force-sync --no-clone-bundle --no-tags -j$(nproc --all) || repo sync -c --force-sync --no-clone-bundle --no-tags -j$(nproc --all)
echo
}

generatePatches() {
echo "--> Generating patches"
rm -rf patchestd patchestd.zip
wget -q https://github.com/TrebleDroid/treble_experimentations/raw/master/list-patches.sh -O list-patches.sh
sed -i "s/patches/patchestd/g" list-patches.sh
bash list-patches.sh
echo
}

updatePatches() {
echo "--> Updating patches"
rm -rf $BL/patches/trebledroid
unzip -q patchestd.zip
mv patchestd $BL/patches/trebledroid
echo
}

commitPatches() {
echo "--> Committing patches"
pushd $BL &>/dev/null
git add patches/trebledroid
git commit -m "feat: sync with latest sources of TrebleDroid"
git push
popd &>/dev/null
}

START=$(date +%s)

initRepos
syncRepos
generatePatches
updatePatches
commitPatches

END=$(date +%s)
ELAPSEDM=$(($(($END-$START))/60))
ELAPSEDS=$(($(($END-$START))-$ELAPSEDM*60))

echo "--> Syncbot completed in $ELAPSEDM minutes and $ELAPSEDS seconds"
echo

0 comments on commit e5f6b30

Please sign in to comment.