-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding a test to make sure we run pio as pioreactor in update scripts
- Loading branch information
1 parent
d16efef
commit ef7a44b
Showing
7 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import annotations | ||
|
||
import os | ||
|
||
|
||
def find_shell_scripts(directory): | ||
"""Recursively find all shell script files in the specified directory.""" | ||
types = {"update.sh", "pre_update.sh", "post_update.sh"} | ||
for root, dirs, files in os.walk(directory): | ||
for file in files: | ||
if file in types: | ||
yield os.path.join(root, file) | ||
|
||
|
||
def test_pio_commands(): | ||
script_directory = "update_scripts" | ||
scripts = find_shell_scripts(script_directory) | ||
error_msgs = [] | ||
|
||
for script in scripts: | ||
with open(script, "r") as file: | ||
for line_number, line in enumerate(file, start=1): | ||
# Checking for 'pio' not preceded by 'su -u pioreactor' | ||
if " pio " in line and "su -u pioreactor" not in line: | ||
error_msgs.append( | ||
f"Error in {script} at line {line_number}: 'pio' command must be prefixed with 'su -u pioreactor'." | ||
) | ||
|
||
assert not error_msgs, "\n".join(error_msgs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
set -xeu | ||
|
||
|
||
export LC_ALL=C | ||
|
||
|
||
# Lower bound version | ||
min_version="24.4.11" | ||
|
||
# Get the current version of pio | ||
current_version=$(su -u pioreactor pio version) | ||
|
||
# Use sorting to determine if the current version is less than the minimum version | ||
is_valid=$(printf "%s\n%s" "$current_version" "$min_version" | sort -V | head -n1) | ||
|
||
# If the smallest version isn't the minimum version, then current version is too low | ||
if [ "$is_valid" != "$min_version" ]; then | ||
su -u pioreactor pio log -l ERROR -m "Version error: installed version $current_version is lower than the minimum required version $min_version." | ||
exit 1 | ||
fi | ||
|
||
echo "Version check passed: $current_version" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
#!/bin/bash | ||
|
||
# this runs at startup on every boot. | ||
|
||
set -xeu | ||
|
||
|
||
|