From 8357f6837cfd0994a56df554419dea7c976899f2 Mon Sep 17 00:00:00 2001 From: James Fraser Date: Wed, 13 Sep 2023 10:57:00 +1000 Subject: [PATCH] Clean up test files --- test/Dockerfile | 21 ++++++++++++++------- test/test.zsh | 9 +++++---- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/test/Dockerfile b/test/Dockerfile index b44c725..452538a 100644 --- a/test/Dockerfile +++ b/test/Dockerfile @@ -1,21 +1,28 @@ -FROM ubuntu:latest +FROM ubuntu:22.04 # Install system packages -RUN apt-get update && apt-get install -y \ +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + ca-certificates \ curl \ git \ zsh \ gpg \ - ripgrep -# Install oh-my-zsh -RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" + ripgrep \ + && rm -rf /var/lib/apt/lists/* -RUN mkdir -p /root/.oh-my-zsh/plugins/history-sync +# Install oh-my-zsh and history-sync plugin +RUN bash -c 'set -o pipefail' \ + && 'curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh | sh -e' \ + && mkdir -p /root/.oh-my-zsh/plugins/history-sync COPY history-sync.plugin.zsh /root/.oh-my-zsh/plugins/history-sync/ +# Install a basic `zshrc` COPY test/zshrc /root/.zshrc +# Install the test script COPY test/test.zsh /root RUN chmod +x /root/test.zsh ARG ACCESS_KEY ENV ACCESS_KEY=${ACCESS_KEY} -ENTRYPOINT /usr/bin/zsh -i /root/test.zsh $ACCESS_KEY +ENTRYPOINT ["/usr/bin/zsh"] +CMD ["-i", "-c", "source /root/test.zsh ${ACCESS_KEY}"] diff --git a/test/test.zsh b/test/test.zsh index 836ca5d..d9f51df 100755 --- a/test/test.zsh +++ b/test/test.zsh @@ -15,6 +15,7 @@ function success() { function failure() { echo $fg[red]"$1"$reset_color + exit 1 } function info() { @@ -23,22 +24,22 @@ function info() { function check_fn_exists() { typeset -f "$1" >/dev/null - [[ $? -eq 0 ]] || {failure "FAILURE: Function '$1' missing"; exit $?} + [[ $? -eq 0 ]] || {failure "FAILURE: Function '$1' missing"} } function check_alias_exists() { alias "$1" >/dev/null - [[ $? -eq 0 ]] || {failure "FAILURE: Alias '$1' missing"; exit $?} + [[ $? -eq 0 ]] || {failure "FAILURE: Alias '$1' missing"} } function check_env_exists() { [[ -v $1 ]] - [[ $? -eq 0 ]] || {failure "FAILURE: Environment variable '$1' missing"; exit $?} + [[ $? -eq 0 ]] || {failure "FAILURE: Environment variable '$1' missing"} } function check_history() { rg -U "$1" ~/.zsh_history >/dev/null - [[ $? -eq 0 ]] || {failure "FAILURE: History did not match '$1'"; exit $?} + [[ $? -eq 0 ]] || {failure "FAILURE: History did not match '$1'"} } function setup() {