Skip to content

Commit 067bebb

Browse files
committed
Add bash scripts to simplify testing and rebase operations
Bash scripts: * check.sh - Perform a set of builds, commenting out various defines * check_branches.sh - For each branch call check_named_branch.sh, file check_named_branch.dat contains the branch names * check_commits.sh - For each commit call check_named_branch.sh, the end (defaults to HEAD) and start (defaults to release_candidate) commits are provided as parameters * check_named_branch.sh - Display the branch, call check.sh, the commit or branch is provided as a parameter * rebase.sh - Rebase a number of branches on top of one another, the branch names are in the file rebase.dat
1 parent 9387823 commit 067bebb

File tree

5 files changed

+360
-0
lines changed

5 files changed

+360
-0
lines changed

Firmware/RTK_Everywhere/check.sh

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/bin/bash
2+
#
3+
# check.sh
4+
# Script to modify RTK_Everywhere.ino to comment out various defines
5+
# and verify that the code still builds successfully. This script
6+
# stops execution upon error due to the following command.
7+
########################################################################
8+
set -e
9+
#set -o verbose
10+
#set -o xtrace
11+
12+
# Start fresh
13+
git reset --hard --quiet HEAD
14+
make
15+
16+
# Bluetooth
17+
sed -i 's|#define COMPILE_BT|//#define COMPILE_BT|' RTK_Everywhere.ino
18+
make
19+
git reset --hard --quiet HEAD
20+
21+
# Network
22+
sed -i 's|#define COMPILE_WIFI|//#define COMPILE_WIFI|' RTK_Everywhere.ino
23+
sed -i 's|#define COMPILE_ETHERNET|//#define COMPILE_ETHERNET|' RTK_Everywhere.ino
24+
sed -i 's|#define COMPILE_CELLULAR|//#define COMPILE_CELLULAR|' RTK_Everywhere.ino
25+
make
26+
git reset --hard --quiet HEAD
27+
28+
# Cellular
29+
sed -i 's|#define COMPILE_CELLULAR|//#define COMPILE_CELLULAR|' RTK_Everywhere.ino
30+
make
31+
git reset --hard --quiet HEAD
32+
33+
# Ethernet
34+
sed -i 's|#define COMPILE_ETHERNET|//#define COMPILE_ETHERNET|' RTK_Everywhere.ino
35+
make
36+
git reset --hard --quiet HEAD
37+
38+
# WiFi
39+
sed -i 's|#define COMPILE_WIFI|//#define COMPILE_WIFI|' RTK_Everywhere.ino
40+
make
41+
git reset --hard --quiet HEAD
42+
43+
# Soft AP
44+
sed -i 's|#define COMPILE_AP|//#define COMPILE_AP|' RTK_Everywhere.ino
45+
make
46+
git reset --hard --quiet HEAD
47+
48+
# ESPNOW
49+
sed -i 's|#define COMPILE_ESPNOW|//#define COMPILE_ESPNOW|' RTK_Everywhere.ino
50+
make
51+
git reset --hard --quiet HEAD
52+
53+
# WiFi, SOFT AP, ESPNOW
54+
sed -i 's|#define COMPILE_WIFI|//#define COMPILE_WIFI|' RTK_Everywhere.ino
55+
sed -i 's|#define COMPILE_AP|//#define COMPILE_AP|' RTK_Everywhere.ino
56+
sed -i 's|#define COMPILE_ESPNOW|//#define COMPILE_ESPNOW|' RTK_Everywhere.ino
57+
make
58+
git reset --hard --quiet HEAD
59+
60+
# LG290P
61+
sed -i 's|#define COMPILE_LG290P|//#define COMPILE_LG290P|' RTK_Everywhere.ino
62+
make
63+
git reset --hard --quiet HEAD
64+
65+
# MOSAIC X5
66+
sed -i 's|#define COMPILE_MOSAICX5|//#define COMPILE_MOSAICX5|' RTK_Everywhere.ino
67+
make
68+
git reset --hard --quiet HEAD
69+
70+
# UM980
71+
sed -i 's|#define COMPILE_UM980|//#define COMPILE_UM980|' RTK_Everywhere.ino
72+
make
73+
git reset --hard --quiet HEAD
74+
75+
# ZED F9P
76+
sed -i 's|#define COMPILE_ZED|//#define COMPILE_ZED|' RTK_Everywhere.ino
77+
make
78+
git reset --hard --quiet HEAD
79+
80+
# GNSS None
81+
sed -i 's|#define COMPILE_LG290P|//#define COMPILE_LG290P|' RTK_Everywhere.ino
82+
sed -i 's|#define COMPILE_MOSAICX5|//#define COMPILE_MOSAICX5|' RTK_Everywhere.ino
83+
sed -i 's|#define COMPILE_UM980|//#define COMPILE_UM980|' RTK_Everywhere.ino
84+
sed -i 's|#define COMPILE_ZED|//#define COMPILE_ZED|' RTK_Everywhere.ino
85+
make
86+
git reset --hard --quiet HEAD
87+
88+
# L-Band
89+
sed -i 's|#define COMPILE_L_BAND|//#define COMPILE_L_BAND|' RTK_Everywhere.ino
90+
make
91+
git reset --hard --quiet HEAD
92+
93+
# IM19_IMU
94+
sed -i 's|#define COMPILE_IM19_IMU|//#define COMPILE_IM19_IMU|' RTK_Everywhere.ino
95+
make
96+
git reset --hard --quiet HEAD
97+
98+
# PointPerfect Library
99+
sed -i 's|#define COMPILE_POINTPERFECT_LIBRARY|//#define COMPILE_POINTPERFECT_LIBRARY|' RTK_Everywhere.ino
100+
make
101+
git reset --hard --quiet HEAD
102+
103+
# BQ40Z50
104+
sed -i 's|#define COMPILE_BQ40Z50|//#define COMPILE_BQ40Z50|' RTK_Everywhere.ino
105+
make
106+
git reset --hard --quiet HEAD
107+
108+
# MQTT Client
109+
sed -i 's|#define COMPILE_MQTT_CLIENT|//#define COMPILE_MQTT_CLIENT|' RTK_Everywhere.ino
110+
make
111+
git reset --hard --quiet HEAD
112+
113+
# OTA Auto
114+
sed -i 's|#define COMPILE_OTA_AUTO|//#define COMPILE_OTA_AUTO|' RTK_Everywhere.ino
115+
make
116+
git reset --hard --quiet HEAD
117+
118+
# HTTP Client
119+
sed -i 's|#define COMPILE_HTTP_CLIENT|//#define COMPILE_HTTP_CLIENT|' RTK_Everywhere.ino
120+
make
121+
git reset --hard --quiet HEAD
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
#
3+
# check_branches.sh
4+
# Script to check various branches work with #defines compiled out.
5+
# Branches are listed in the file: check-branches.dat
6+
########################################################################
7+
#set -e
8+
#set -o verbose
9+
#set -o xtrace
10+
set -o pipefail
11+
12+
# Files
13+
data_file=check_branches.dat
14+
log_file=check_branches.log
15+
16+
# Remove the log file
17+
if [ -f "$log_file" ] ; then
18+
rm "$log_file"
19+
fi
20+
21+
# Get the starting and ending branches
22+
while read branch_name
23+
do
24+
if [[ -n "$start_branch" ]]
25+
then
26+
clear
27+
break;
28+
else
29+
start_branch=$branch_name
30+
fi
31+
end_branch=$branch_name
32+
done < $data_file
33+
34+
# Display the branches being checked
35+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
36+
echo " Checking branches: $start_branch --> $end_branch" 2>&1 | tee -a $log_file
37+
date 2>&1 | tee -a $log_file
38+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
39+
40+
# Walk the list of branches, log the output
41+
previous_branch=$start_branch
42+
while read branch_name
43+
do
44+
./check_named_branch.sh $branch_name 2>&1 | tee -a $log_file
45+
exit_status=$?
46+
if [ $exit_status -ne 0 ]; then
47+
if [ "$previous_branch" != "$branch_name" ]; then
48+
# Display the verified commits
49+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
50+
echo " Verified branches: $start_branch --> $previous_branch" 2>&1 | tee -a $log_file
51+
date 2>&1 | tee -a $log_file
52+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
53+
while read branch
54+
do
55+
if [ "$branch" == "$branch_name" ]; then
56+
break;
57+
fi
58+
echo $branch 2>&1 | tee -a $log_file
59+
done < $data_file
60+
fi
61+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
62+
echo "Error: Branch $branch_name failed!" 2>&1 | tee -a $log_file
63+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
64+
echo "check_branches exiting with status: $exit_status" 2>&1 | tee -a $log_file
65+
exit $exit_status
66+
fi
67+
previous_branch=$branch_name
68+
done < $data_file
69+
70+
# Display the verified branches
71+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
72+
echo " Verified branches" 2>&1 | tee -a $log_file
73+
date 2>&1 | tee -a $log_file
74+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
75+
while read branch
76+
do
77+
echo $branch 2>&1 | tee -a $log_file
78+
done < $data_file
79+
80+
# Display the success message
81+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
82+
echo " Successfully verified all branches $start_branch --> $end_branch" 2>&1 | tee -a $log_file
83+
date 2>&1 | tee -a $log_file
84+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/bin/bash
2+
#
3+
# check_commits.sh
4+
# Script to walk the list of commits and verify that each builds
5+
# successfully with the various defines commented out
6+
#
7+
# Parameters:
8+
# $1 - Ending revision (defaults to HEAD)
9+
# $2 - Starting revision (defaults to release_candidate)
10+
########################################################################
11+
#set -e
12+
#set -o verbose
13+
#set -o xtrace
14+
set -o pipefail
15+
16+
# Set the default values
17+
end_revision=${1:-HEAD}
18+
start_revision=${2:-release_candidate}
19+
20+
# Files
21+
data_file=check_commits.dat
22+
log_file=check_commits.log
23+
24+
# Remove the log file
25+
if [ -f "$log_file" ] ; then
26+
rm "$log_file"
27+
fi
28+
29+
# Create the data file
30+
git cherry $start_revision $end_revision > $data_file
31+
32+
# Get the starting and ending commits
33+
while read operation_type commit_id
34+
do
35+
if [[ -n "$start_commit" ]]
36+
then
37+
clear
38+
break;
39+
else
40+
start_commit=$commit_id
41+
fi
42+
end_commit=$commit_id
43+
done < $data_file
44+
45+
# Display the commits being checked
46+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
47+
echo " Checking commits: $start_revision --> $end_revision" 2>&1 | tee -a $log_file
48+
date 2>&1 | tee -a $log_file
49+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
50+
51+
# Walk the list of commits, separating the type from the ID
52+
previous_commit=$start_commit
53+
while read operation_type commit_id
54+
do
55+
./check_named_branch.sh $commit_id 2>&1 | tee -a $log_file
56+
exit_status=$?
57+
if [ $exit_status -ne 0 ]; then
58+
if [ "$previous_commit" != "$commit_id" ]; then
59+
# Display the verified commits
60+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
61+
echo " Verified commits" 2>&1 | tee -a $log_file
62+
date 2>&1 | tee -a $log_file
63+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
64+
while read operation_type commit
65+
do
66+
echo $commit 2>&1 | tee -a $log_file
67+
if [ "$commit" == "$previous_commit" ]; then
68+
break;
69+
fi
70+
done < $data_file
71+
fi
72+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
73+
echo "Error: Commit $commit_id failed!" 2>&1 | tee -a $log_file
74+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
75+
echo "check_commits exiting with status: $exit_status" 2>&1 | tee -a $log_file
76+
exit $exit_status
77+
fi
78+
previous_commit=$commit_id
79+
done < $data_file
80+
81+
# Display the verified commits
82+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
83+
echo " Verified commits" 2>&1 | tee -a $log_file
84+
date 2>&1 | tee -a $log_file
85+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
86+
while read operation_type commit_id
87+
do
88+
echo $commit_id 2>&1 | tee -a $log_file
89+
done < $data_file
90+
91+
# Display the success message
92+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
93+
echo " Successfully verified all commits: $start_revision --> $end_revision" 2>&1 | tee -a $log_file
94+
date 2>&1 | tee -a $log_file
95+
echo "--------------------------------------------------------------------------------" 2>&1 | tee -a $log_file
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
#
3+
# check_named_branch.sh
4+
# Script to check various branches work with #defines compiled out.
5+
#
6+
# Parameters:
7+
# $1 - Branch name (defaults to release-candidate)
8+
########################################################################
9+
#set -e
10+
#set -o verbose
11+
#set -o xtrace
12+
13+
# Set the default values
14+
branch_name=${1:-release_candidate}
15+
16+
# Get the branch
17+
git checkout --quiet $branch_name
18+
19+
# Display the branch
20+
echo "--------------------------------------------------------------------------------"
21+
git log --max-count=1 --format=oneline HEAD
22+
date
23+
echo "--------------------------------------------------------------------------------"
24+
25+
# Verify that the branch builds successfully with defines commented out
26+
./check.sh
27+
exit_status=$?
28+
#echo "check_named_branch exiting with status: $exit_status"
29+
exit $exit_status

Firmware/RTK_Everywhere/rebase.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
#
3+
# rebase.sh
4+
# Script to rebase branches on top of one another
5+
# Branches are listed in the file: rebase.dat
6+
########################################################################
7+
#set -e
8+
#set -o verbose
9+
#set -o xtrace
10+
#set -o pipefail
11+
12+
# Files
13+
data_file=rebase.dat
14+
15+
# Rebase the branches on top of one another
16+
while read branch_name
17+
do
18+
if [[ -n "$base_branch" ]]
19+
then
20+
# Rebase the branch
21+
git checkout $branch_name
22+
git rebase -i $base_branch < /dev/tty
23+
else
24+
# Start with everything clean
25+
clear
26+
git reset --hard HEAD
27+
fi
28+
29+
# Set the new base branch
30+
base_branch=$branch_name
31+
done < $data_file

0 commit comments

Comments
 (0)