Skip to content

Commit

Permalink
feat: add multiple test execution
Browse files Browse the repository at this point in the history
  • Loading branch information
egel committed Sep 21, 2024
1 parent 937fa5f commit 703e65d
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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: cd tests/linux/ && for test in $(compgen -A function | grep "^test_"); do "$test"; done
6 changes: 6 additions & 0 deletions tests/linux/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Linux tests

Those test is meant to run on linux

- ubuntu 20.04 LTS
- bash
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
#!/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)"

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
Expand All @@ -36,23 +25,18 @@ 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

# 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 changes: 7 additions & 0 deletions tests/run_all_linux_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

main() {

}

main "$@"
39 changes: 39 additions & 0 deletions tests/tmux_helpers.sh
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit 703e65d

Please sign in to comment.