Skip to content

Commit 85be38d

Browse files
committed
CI: Make major changes to the CI code
Refined code, better way to delete files and more
1 parent 0cabe8a commit 85be38d

File tree

5 files changed

+39
-32
lines changed

5 files changed

+39
-32
lines changed

CI/main.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Copyright (C) Dhruv Gera
22
echo -e "AUTOMATER by Dhruv Gera";
3-
export BOT_API_KEY=""
4-
export CHAT_ID=""
5-
export SF_USR=""
6-
export SF_PASS=""
3+
export BOT_API_KEY="your key goes here"
4+
export CHAT_ID="chat it goes here"
75
mv $PWD/scripts/CI/upload.sh $HOME/cygnus/
86
mv $PWD/scripts/CI/replacer.py $HOME/cygnus/
97
mv $PWD/scripts/CI/start.sh $HOME/cygnus/
108
mv $PWD/scripts/CI/rom.py $HOME/cygnus/
119
mv $PWD/scripts/CI/tgt.py $HOME/cygnus/
10+
mv $PWD/scripts/CI/nuker.py $HOME/cygnus/
1211
sed -i "s/device_name_here/$devicename/g" $HOME/cygnus/replacer.py
12+
sed -i "s/device_name_here/$devicename/g" $HOME/cygnus/nuker.py
1313
sed -i "s/sampledevice/$devicename/g" $HOME/cygnus/rom.py
1414
sed -i "s/sampledevice/$devicename/g" $HOME/cygnus/tgt.py
1515
python3 $HOME/cygnus/replacer.py
@@ -32,14 +32,15 @@ if ! globexists Cygnus* ; then
3232
else
3333
python3 $HOME/cygnus/rom.py
3434
wait
35-
python3 $HOME/cygnus/tgt.py
36-
wait
3735
fi
3836
sed -i "s/$devicename/device_name_here/g" $HOME/cygnus/replacer.py
3937
sed -i "s/$devicename/sampledevice/g" $HOME/cygnus/start.sh
4038
sed -i "s/$devicename/sampledevice/g" $HOME/cygnus/rom.py
4139
sed -i "s/$devicename/sampledevice/g" $HOME/cygnus/tgt.py
4240
cd $HOME/cygnus
43-
make clean
41+
. b*/e* && make clean
4442
rm log.txt
4543
rm *md5sum
44+
python3 $HOME/cygnus/nuker.py
45+
sed -i "s/$devicename/device_name_here/g" $HOME/cygnus/nuker.py
46+
rm -rf .repo/local_manifests trimmed.txt

CI/nuker.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import json,glob
2+
3+
device_name = "device_name_here"
4+
5+
path_to_dep = glob.glob(f"device/*/{device_name}/cygnus.dependencies")[0]
6+
7+
def nuke():
8+
with open(path_to_dep) as file:
9+
json_data = json.loads(file.read())
10+
for repos in json_data:
11+
print(f"rm -rf {repos['target_path']}")
12+
13+
nuke()

CI/rom.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,9 @@
22
import subprocess
33
import select
44
import os
5-
import pysftp
65
import sys
76
import glob
87

9-
usr=os.environ["SF_USR"]
10-
passw=os.environ["SF_PASS"]
11-
# Your particulars for accessing the sftp client
12-
myHostname = "frs.sourceforge.net"
13-
myUsername = usr
14-
myPassword = passw
15-
168
# Device name is here for rom builds, as we need it in the out folder's name
179
devicename="sampledevice"
1810

@@ -28,19 +20,5 @@
2820
sofar = size
2921
name = item
3022
os.environ["largest"] = name
31-
# Sourceforge or any other sftp client uploader script
32-
33-
with pysftp.Connection(host=myHostname, username=myUsername, password=myPassword) as sftp:
34-
print("Connection successful")
35-
36-
# Switch to a remote directory
37-
sftp.cwd('/home/pfs/project/cygnus-android/test/') # Add your dir here
38-
# Obtain structure of the remote directory
39-
directory_structure = sftp.listdir_attr()
40-
41-
localFilePath = (name) # The path where your file is stored on your drive
42-
remoteFilePath = (name) # The path where you want to upload
43-
sftp.put(localFilePath, remoteFilePath)
44-
4523
os.system("$PWD/upload.sh")
4624
os.system("rm $largest")

CI/start.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ function SendMsg() {
1010
curl -s -X POST https://api.telegram.org/bot$BOT_API_KEY/sendMessage -d "parse_mode=markdown" -d text="$1" -d chat_id=$CHAT_ID 1> /dev/null
1111
}
1212
SendMsg "Build scheduled for sampledevice started";
13-
mka cygnus | tee log.txt
13+
make cygnus -j32 | tee log.txt
1414

CI/upload.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
#!/bin/bash
12
# Copyright (C) Dhruv Gera
2-
export ZIPNAME="log.txt"
3-
curl -F chat_id="$CHAT_ID" -F document=@"$ZIPNAME" -F caption="Download build at: https://sourceforge.net/projects/cygnus-android/files/test/$largest/download" https://api.telegram.org/bot$BOT_API_KEY/sendDocument
3+
function transfer {
4+
zipname="$(echo $1 | awk -F '/' '{print $NF}')";
5+
url="$(curl -# -T $1 http://transfer.sh -H "Max-Downloads: 1")";
6+
printf '\n';
7+
echo -e "Download ${zipname} at ${url}";
8+
curl -s -X POST https://api.telegram.org/bot$BOT_API_KEY/sendMessage -d text="Download build at: $url" -d chat_id=$CHAT_ID
9+
}
10+
function bashupload {
11+
zipname="$(echo $1 | awk -F '/' '{print $NF}')";
12+
url="$(curl -# -T $1 https://bashupload.com)";
13+
printf '\n';
14+
echo -e "Download ${zipname} at this alternative URL: ${url}";
15+
curl -s -X POST https://api.telegram.org/bot$BOT_API_KEY/sendMessage -d text="Download build at this alternative URL: $url" -d chat_id=$CHAT_ID
16+
}
17+
transfer $largest
18+
# bashupload $largest

0 commit comments

Comments
 (0)