diff --git a/.github/workflows/github-actions.yml b/.github/workflows/dev-push-check.yml similarity index 69% rename from .github/workflows/github-actions.yml rename to .github/workflows/dev-push-check.yml index 5455322..6fc17a8 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/dev-push-check.yml @@ -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 diff --git a/tests/linux/README.md b/tests/linux/README.md new file mode 100644 index 0000000..65361ef --- /dev/null +++ b/tests/linux/README.md @@ -0,0 +1,6 @@ +# Linux tests + +Those test is meant to run on linux + +- ubuntu 20.04 LTS +- bash diff --git a/tests/linux_setup_plugin_and_run.sh b/tests/linux/test_linux_default_startup.sh similarity index 58% rename from tests/linux_setup_plugin_and_run.sh rename to tests/linux/test_linux_default_startup.sh index 5d3ffa1..81cc2b5 100755 --- a/tests/linux_setup_plugin_and_run.sh +++ b/tests/linux/test_linux_default_startup.sh @@ -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 <~/.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 "$@" diff --git a/tests/run_all_linux_tests.sh b/tests/run_all_linux_tests.sh new file mode 100755 index 0000000..56f8a6f --- /dev/null +++ b/tests/run_all_linux_tests.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +main() { + for test in $(compgen -A function | grep "^test_linux_"); do "$test"; done +} + +main "$@" diff --git a/tests/tmux_helpers.sh b/tests/tmux_helpers.sh new file mode 100644 index 0000000..d9d826f --- /dev/null +++ b/tests/tmux_helpers.sh @@ -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" +}