feat: add multiple test execution

This commit is contained in:
Maciej Sypien 2024-09-21 09:45:50 +02:00
parent 937fa5f529
commit 4944b6ecc0
No known key found for this signature in database
GPG key ID: 10BC01EDA6827DC8
5 changed files with 71 additions and 31 deletions

View file

@ -1,8 +1,8 @@
name: GitHub Actions
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
name: dev-push-check
run-name: ${{ github.actor }} pushed new code to {{ github.ref }} 💻
on: [push] #, pull_request]
jobs:
lint-shellcheck:
lint_shellcheck:
runs-on: ubuntu-latest
steps:
- name: install shellcheck
@ -11,7 +11,7 @@ jobs:
uses: actions/checkout@main
- name: lint files against shellcheck
run: make lint_shellcheck
lint-shfmt:
lint_shfmt:
runs-on: ubuntu-latest
steps:
- name: install shfmt
@ -20,12 +20,15 @@ jobs:
uses: actions/checkout@main
- name: lint files against shfmt
run: make lint_shfmt
test-setup-linux:
test_setup_linux:
runs-on: ubuntu-latest
needs:
- lint_shfmt
- lint_shellcheck
steps:
- name: install soft
run: sudo apt install -y tmux git
- name: checkout repo
uses: actions/checkout@main
- name: test setup
run: ./tests/linux_setup_plugin_and_run.sh
- name: dummy test setup
run: ./tests/run_all_linux_tests.sh

6
tests/linux/README.md Normal file
View file

@ -0,0 +1,6 @@
# Linux tests
Those test is meant to run on linux
- ubuntu 20.04 LTS
- bash

View file

@ -1,25 +1,15 @@
#!/bin/bash
# this test is meant to run on linux
#
# test target is:
# - ubuntu 20.04 LTS
# - bash
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck disable=SC1091
source "${CURRENT_DIR}/../tmux_helpers.sh"
# default value of status-left section from gruvbox theme
readonly STATUS_LEFT_DEFAULT="#[bg=colour241,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]"
main() {
if [[ "$(uname)" != "Linux" ]]; then
echo "NOT LINUX. Failed & exit."
exit 1
fi
sudo apt update -y
sudo apt install -y tmux git
mkdir -p ~/.tmux/plugins/
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
helper_tearup_linux_tmux
cat <<EOF >~/.tmux.conf
# List of plugins
@ -36,8 +26,7 @@ EOF
cat ~/.tmux.conf
# manually install plugins
bash -c "${HOME}/.tmux/plugins/tpm/scripts/install_plugins.sh install_plugins"
helper_install_tpm_plugins
# start new detached session
tmux new -d
@ -45,14 +34,10 @@ EOF
# get status of something from theme
_status_left_current=$(tmux show-option -gqv status-left)
if [[ "$STATUS_LEFT_DEFAULT" != "$_status_left_current" ]]; then
echo "$STATUS_LEFT_DEFAULT"
echo "$_status_left_current"
echo "FAILED"
exit 1
helper_print_fail_and_exit "Status left did not match"
fi
echo "SUCCESS"
exit 0
helper_print_success_and_exit "Status left match"
}
main "$@"

7
tests/run_all_linux_tests.sh Executable file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env bash
main() {
for test in $(compgen -A function | grep "^test_linux_"); do "$test"; done
}
main "$@"

39
tests/tmux_helpers.sh Normal file
View file

@ -0,0 +1,39 @@
#!/bin/bash
helper_teardown_tmux() {
rm -rf ~/.tmux.conf
rm -rf ~/.tmux/
tmux kill-server >/dev/null 2>&1
}
helper_tearup_linux_tmux() {
if [[ "$(uname)" != "Linux" ]]; then
echo "NOT LINUX. Failed & exit."
exit 1
fi
# install software
sudo apt update -y
sudo apt install -y tmux git
# download TPM
mkdir -p ~/.tmux/plugins/
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
}
helper_print_fail_and_exit() {
local _msg="${1:-}"
printf "FAIL. %s\n" "${_msg}"
exit 1
}
helper_print_success_and_exit() {
local _msg="${1:-}"
printf "SUCCESS. %s\n" "${_msg}"
exit 0
}
# install TMP plugins with command
helper_install_tpm_plugins() {
bash -c "${HOME}/.tmux/plugins/tpm/scripts/install_plugins.sh install_plugins"
}