Skip to content

Commit

Permalink
ADD: CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alealexpro100 committed Nov 19, 2022
1 parent 8f4619f commit ad37608
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 4 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "Test directory default and by-profile install"

on:
pull_request:
push:
workflow_dispatch:

jobs:
test_default:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Test default install to directory
run: |
sudo ./tests/to_dir_test.sh $(echo $(find ./lib/distr/ -maxdepth 1 -type d | sort | sed "s|./lib/distr/||g;/^$/d"))
test_profiles:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Test all included profiles
run: |
sudo ./tests/profile_test.sh $(echo $(find ./auto_configs/ -name '*.sh' | sed -e 's|\n| |g'))
18 changes: 16 additions & 2 deletions tests/profile_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,33 @@ source ./lib/common/lib_connect.sh

[[ -z "$*" ]] && return_err "No options!"

err_count=$((0)) succ_count=$((0)) iter_count=$((0))
test_name="install distro with given profile"

msg_print note "Started test: $test_name."

for profile in "$@"; do
[[ ! -f $profile ]] && return_err "Profile $profile not found!"
: $((iter_count++))
msg_print msg "Started on $(date -u)."
msg_print msg "Testing $distr_install..."
msg_print msg "==\nTesting $distr_install...\n=="
create_tmp_dir tmp_distr_install
cp "$profile" "$tmp_distr_install/used_config"
msg_print warn "Start of profile file."
cat "$tmp_distr_install/used_config"
msg_print warn "End of profile file."
mkdir "$tmp_distr_install/rootfs"
mount -t tmpfs tmpfs "$tmp_distr_install/rootfs"
default_dir="$tmp_distr_install/rootfs" ./install_sys.sh "$tmp_distr_install/used_config" || msg_print error "Something went wrong!"
if default_dir="$tmp_distr_install/rootfs" ./install_sys.sh "$tmp_distr_install/used_config"; then
: $((succ_count++))
else
msg_print error "Something went wrong!"
: $((err_count++))
fi
umount -l "$tmp_distr_install/rootfs"
rm -rf "$tmp_distr_install"
msg_print msg "Ended on $(date -u)."
done

msg_print note "Completed test: $test_name."
msg_print msg "Results: success: $succ_count, error: $err_count, iterations: $iter_count."
18 changes: 16 additions & 2 deletions tests/to_dir_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,33 @@ source ./lib/common/lib_connect.sh

[[ -z "$*" ]] && return_err "No options!"

err_count=$((0)) succ_count=$((0)) iter_count=$((0))
test_name="install distro with default profile to directory"

msg_print note "Started test: $test_name."

for distr_install in "$@"; do
[[ ! -d ./lib/distr/$distr_install ]] && return_err "Directory $distr_install not found!"
: $((iter_count++))
msg_print msg "Started on $(date -u)."
msg_print msg "Testing $distr_install..."
msg_print msg "==\nTesting $distr_install...\n=="
create_tmp_dir tmp_distr_install
DEFAULT_DISTR=$distr_install DEFAULT_DIR="${tmp_distr_install:?}/rootfs" ECHO_MODE=auto bash ./profile_gen.sh "$tmp_distr_install/used_config"
msg_print warn "Start of profile file."
cat "$tmp_distr_install/used_config"
msg_print warn "End of profile file."
mkdir "$tmp_distr_install/rootfs"
mount -t tmpfs tmpfs "$tmp_distr_install/rootfs"
./install_sys.sh "$tmp_distr_install/used_config" || msg_print error "Something went wrong!"
if ./install_sys.sh "$tmp_distr_install/used_config"; then
: $((succ_count++))
else
msg_print error "Something went wrong!"
: $((err_count++))
fi
umount -l "$tmp_distr_install/rootfs"
rm -rf "$tmp_distr_install"
msg_print msg "Ended on $(date -u)."
done

msg_print note "Completed test: $test_name."
msg_print msg "Results: success: $succ_count, error: $err_count, iterations: $iter_count."

0 comments on commit ad37608

Please sign in to comment.