Skip to content

Commit

Permalink
Fix log uploads in GitHub Actions (#124)
Browse files Browse the repository at this point in the history
* Fix log uploads in GitHub Actions

* Ensure sync before shutdown in tests

Signed-off-by: Ethan Dye <[email protected]>
  • Loading branch information
ecdye authored Dec 5, 2024
1 parent 3325c13 commit 7a0460a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ on:
push:
paths:
- 'zram-config'
- 'ztab'
- '**.bash'
- 'tests/**'
- '.github/workflows/test-action.yml'
pull_request:
paths:
- 'zram-config'
- 'ztab'
- '**.bash'
- 'tests/**'
- '.github/workflows/test-action.yml'
Expand Down Expand Up @@ -52,4 +54,5 @@ jobs:
if: always()
uses: actions/upload-artifact@v4
with:
name: logs.tar.gz
path: logs.tar.gz
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ Once finished, start zram using `sudo systemctl start zram-config.service` or `s
# swap alg mem_limit disk_size swap_priority page-cluster swappiness
swap lzo-rle 250M 750M 75 0 150
# dir alg mem_limit disk_size target_dir bind_dir
#dir lzo-rle 50M 150M /home/pi /opt/zram/pi.bind
# dir alg mem_limit disk_size target_dir bind_dir
#dir lzo-rle 50M 150M /home/pi /pi.bind
# log alg mem_limit disk_size target_dir bind_dir oldlog_dir
log lzo-rle 50M 150M /var/log /opt/zram/log.bind /opt/zram/oldlog
# log alg mem_limit disk_size target_dir bind_dir oldlog_dir
log lzo-rle 50M 150M /var/log /log.bind /opt/zram/oldlog
```

### Is it working?
Expand Down
7 changes: 4 additions & 3 deletions tests/image.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ imageFile() {
mkdir -p tests/{fs,kernel,dtb}
mount -o rw -t ext4 "/dev/mapper/${loopPrefix}p2" "tests/fs"
mount -o rw -t vfat "/dev/mapper/${loopPrefix}p1" "tests/fs/boot"
sync
elif [[ $1 == "umount" ]]; then
sync
umount tests/fs/boot
Expand All @@ -29,8 +30,8 @@ if [[ $1 == "setup" ]]; then
echo ", +" | sfdisk -N 2 "$3"
imageFile "mount" "$3"
sed -i -e "s|DATESED|$(date)|" tests/run.exp
rsync -avr --exclude="*.img" --exclude="*.sig" --exclude="tests/fs" --exclude="tests/dtb" --exclude="tests/kernel" ./ tests/fs/opt/zram
systemd-nspawn --directory="tests/fs" /opt/zram/tests/install-packages.bash
rsync -avr --exclude="*.img" --exclude="*.sig" --exclude="tests/fs" --exclude="tests/dtb" --exclude="tests/kernel" ./ tests/fs/opt/zram-config
systemd-nspawn --directory="tests/fs" /opt/zram-config/tests/install-packages.bash
echo "set enable-bracketed-paste off" >> tests/fs/etc/inputrc # Prevents weird character output
cp tests/fs/boot/kernel* tests/kernel
# Compile a customized DTB
Expand All @@ -42,7 +43,7 @@ if [[ $1 == "setup" ]]; then
imageFile "umount" "$3"
elif [[ $1 == "copy-logs" ]]; then
imageFile "mount" "$2"
cp tests/fs/opt/zram/logs.tar.gz .
cp tests/fs/opt/zram-config/logs.tar.gz logs.tar.gz
imageFile "umount" "$2"
fi

Expand Down
14 changes: 9 additions & 5 deletions tests/run.exp
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,32 @@ expect {

# Run tests
expect "pi@raspberrypi:~$ "
send "sudo /opt/zram/install.bash\r"
send "sudo /opt/zram-config/install.bash\r"
expect "pi@raspberrypi:~$ "
send "/opt/zram/tests/test-zram-devices.bash\r"
send "/opt/zram-config/tests/test-zram-devices.bash\r"
expect {
-re "Test failed:.*$" {
set retval 1
exp_continue
}
"pi@raspberrypi:~$ " {
send "sudo /opt/zram/uninstall.bash\r"
send "sudo touch /var/log/test.txt\r"
}
}
expect "pi@raspberrypi:~$ "
send "/opt/zram/tests/test-zram-devices.bash removal\r"
send "sudo /opt/zram-config/uninstall.bash\r"
expect "pi@raspberrypi:~$ "
send "/opt/zram-config/tests/test-zram-devices.bash removal\r"
expect {
-re "Test failed:.*$" {
set retval 1
exp_continue
}
"pi@raspberrypi:~$ " {
send "sudo shutdown -h now\r"
send "sync\r"
}
}
expect "pi@raspberrypi:~$ "
send "sudo shutdown -h 5s\r"

exit $retval
2 changes: 1 addition & 1 deletion uninstall.bash
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if ! [[ -f /usr/local/sbin/zram-config || -f /usr/sbin/zram-config ]]; then
fi

zram-config "stop"
tar -czvf "${BASEDIR}/logs.tar.gz" -C /usr/local/share/zram-config/log .
tar -czf "${BASEDIR}/logs.tar.gz" -C /usr/local/share/zram-config/log .
if [[ $OS == "alpine" ]]; then
rc-service zram-config stop
rc-update del zram-config boot
Expand Down
8 changes: 4 additions & 4 deletions ztab
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
# swap alg mem_limit disk_size swap_priority page-cluster swappiness
swap lzo-rle 250M 750M 75 0 150

# dir alg mem_limit disk_size target_dir bind_dir
#dir lzo-rle 50M 150M /home/pi /opt/zram/pi.bind
# dir alg mem_limit disk_size target_dir bind_dir
#dir lzo-rle 50M 150M /home/pi /pi.bind

# log alg mem_limit disk_size target_dir bind_dir oldlog_dir
log lzo-rle 50M 150M /var/log /opt/zram/log.bind /opt/zram/oldlog
# log alg mem_limit disk_size target_dir bind_dir oldlog_dir
log lzo-rle 50M 150M /var/log /log.bind /opt/zram/oldlog

0 comments on commit 7a0460a

Please sign in to comment.