mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-12-18 13:41:56 +00:00
test-in-docker: Support for multiple ZSH versions
-z --zsh can specify one of the versions of ZSH we can get from centos and ubuntu
This commit is contained in:
parent
df318488c9
commit
2f808f8a4e
17 changed files with 266 additions and 68 deletions
14
TESTS.md
14
TESTS.md
|
@ -26,8 +26,22 @@ This is the easiest to use _if_ you have Docker already installed and running.
|
||||||
The command `./test-in-docker` should make it fairly easy to get into a running
|
The command `./test-in-docker` should make it fairly easy to get into a running
|
||||||
container with the framework of your choice.
|
container with the framework of your choice.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
``` zsh
|
||||||
|
# Test Antigen with the oldest version of ZSH
|
||||||
|
$ ./test-in-docker antigen
|
||||||
|
```
|
||||||
|
|
||||||
|
``` zsh
|
||||||
|
# Test Prezto with ZSH version 5.2
|
||||||
|
$ ./test-in-docker --zsh 5.2 prezto
|
||||||
|
```
|
||||||
|
|
||||||
You can get Docker at <https://www.docker.com/community-edition>.
|
You can get Docker at <https://www.docker.com/community-edition>.
|
||||||
|
|
||||||
|
**Note:** Not all frameworks work with all versions of ZSH (or the underlying OS).
|
||||||
|
|
||||||
## Vagrant
|
## Vagrant
|
||||||
|
|
||||||
Currently there are two test VMs. `test-vm` is an Ubuntu machine with several
|
Currently there are two test VMs. `test-vm` is an Ubuntu machine with several
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
FROM p9k:base
|
ARG base
|
||||||
|
FROM p9k:${base}
|
||||||
|
|
||||||
COPY docker/antibody/install.zsh /tmp/
|
COPY docker/antibody/install.zsh /tmp/
|
||||||
RUN zsh /tmp/install.zsh
|
RUN zsh /tmp/install.zsh
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
FROM p9k:base
|
ARG base
|
||||||
|
FROM p9k:${base}
|
||||||
|
|
||||||
COPY docker/antigen/install.zsh /tmp/
|
COPY docker/antigen/install.zsh /tmp/
|
||||||
RUN zsh /tmp/install.zsh
|
RUN zsh /tmp/install.zsh
|
||||||
|
|
31
docker/base-4.3.11/Dockerfile
Normal file
31
docker/base-4.3.11/Dockerfile
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
FROM centos:6
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
yum install -y \
|
||||||
|
curl \
|
||||||
|
git \
|
||||||
|
zsh \
|
||||||
|
mercurial \
|
||||||
|
subversion \
|
||||||
|
golang \
|
||||||
|
jq \
|
||||||
|
node \
|
||||||
|
ruby \
|
||||||
|
python \
|
||||||
|
python-virtualenv \
|
||||||
|
sudo
|
||||||
|
|
||||||
|
RUN adduser --shell /bin/zsh --comment 'fred' --user-group fred
|
||||||
|
|
||||||
|
COPY docker/fred-sudoers /etc/sudoers.d/fred
|
||||||
|
|
||||||
|
USER fred
|
||||||
|
WORKDIR /home/fred
|
||||||
|
ENV LANG=en_US.UTF-8
|
||||||
|
ENV TERM=xterm-256color
|
||||||
|
ENV DEFAULT_USER=fred
|
||||||
|
ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
|
||||||
|
|
||||||
|
RUN touch .zshrc
|
||||||
|
|
||||||
|
CMD ["/bin/zsh", "-l"]
|
|
@ -1,4 +1,4 @@
|
||||||
FROM ubuntu:trusty
|
FROM ubuntu:14.04
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
apt-get update && \
|
apt-get update && \
|
35
docker/base-5.1.1/Dockerfile
Normal file
35
docker/base-5.1.1/Dockerfile
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
FROM ubuntu:16.04
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
apt-get update && \
|
||||||
|
echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||||
|
curl \
|
||||||
|
git \
|
||||||
|
zsh \
|
||||||
|
mercurial \
|
||||||
|
subversion \
|
||||||
|
golang \
|
||||||
|
jq \
|
||||||
|
nodejs \
|
||||||
|
ruby \
|
||||||
|
python \
|
||||||
|
python-virtualenv \
|
||||||
|
sudo \
|
||||||
|
locales
|
||||||
|
|
||||||
|
RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred
|
||||||
|
RUN locale-gen "en_US.UTF-8"
|
||||||
|
|
||||||
|
COPY docker/fred-sudoers /etc/sudoers.d/fred
|
||||||
|
|
||||||
|
USER fred
|
||||||
|
WORKDIR /home/fred
|
||||||
|
ENV LANG=en_US.UTF-8
|
||||||
|
ENV TERM=xterm-256color
|
||||||
|
ENV DEFAULT_USER=fred
|
||||||
|
ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
|
||||||
|
|
||||||
|
RUN touch .zshrc
|
||||||
|
|
||||||
|
CMD ["/bin/zsh", "-l"]
|
35
docker/base-5.2/Dockerfile
Normal file
35
docker/base-5.2/Dockerfile
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
FROM ubuntu:17.04
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
apt-get update && \
|
||||||
|
echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||||
|
curl \
|
||||||
|
git \
|
||||||
|
zsh \
|
||||||
|
mercurial \
|
||||||
|
subversion \
|
||||||
|
golang \
|
||||||
|
jq \
|
||||||
|
nodejs \
|
||||||
|
ruby \
|
||||||
|
python \
|
||||||
|
python-virtualenv \
|
||||||
|
sudo \
|
||||||
|
locales
|
||||||
|
|
||||||
|
RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred
|
||||||
|
RUN locale-gen "en_US.UTF-8"
|
||||||
|
|
||||||
|
COPY docker/fred-sudoers /etc/sudoers.d/fred
|
||||||
|
|
||||||
|
USER fred
|
||||||
|
WORKDIR /home/fred
|
||||||
|
ENV LANG=en_US.UTF-8
|
||||||
|
ENV TERM=xterm-256color
|
||||||
|
ENV DEFAULT_USER=fred
|
||||||
|
ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
|
||||||
|
|
||||||
|
RUN touch .zshrc
|
||||||
|
|
||||||
|
CMD ["/bin/zsh", "-l"]
|
|
@ -1,4 +1,5 @@
|
||||||
FROM p9k:base
|
ARG base
|
||||||
|
FROM p9k:${base}
|
||||||
|
|
||||||
COPY ./ p9k/
|
COPY ./ p9k/
|
||||||
COPY docker/dotfile/zshrc .zshrc
|
COPY docker/dotfile/zshrc .zshrc
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
FROM p9k:base
|
ARG base
|
||||||
|
FROM p9k:${base}
|
||||||
|
|
||||||
COPY docker/omz/install.zsh /tmp/
|
COPY docker/omz/install.zsh /tmp/
|
||||||
RUN zsh /tmp/install.zsh
|
RUN zsh /tmp/install.zsh
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
FROM p9k:base
|
ARG base
|
||||||
|
FROM p9k:${base}
|
||||||
|
|
||||||
COPY docker/prezto/install.zsh /tmp/
|
COPY docker/prezto/install.zsh /tmp/
|
||||||
RUN zsh /tmp/install.zsh
|
RUN zsh /tmp/install.zsh
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
FROM p9k:base
|
ARG base
|
||||||
|
FROM p9k:${base}
|
||||||
|
|
||||||
COPY docker/zgen/install.zsh /tmp/
|
COPY docker/zgen/install.zsh /tmp/
|
||||||
RUN zsh /tmp/install.zsh
|
RUN zsh /tmp/install.zsh
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
FROM p9k:base
|
ARG base
|
||||||
|
FROM p9k:${base}
|
||||||
|
|
||||||
COPY docker/zim/install.zsh /tmp/
|
COPY docker/zim/install.zsh /tmp/
|
||||||
RUN zsh /tmp/install.zsh
|
RUN zsh /tmp/install.zsh
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
FROM p9k:base
|
ARG base
|
||||||
|
FROM p9k:${base}
|
||||||
|
|
||||||
COPY docker/zplug/install.zsh /tmp/
|
COPY docker/zplug/install.zsh /tmp/
|
||||||
RUN zsh /tmp/install.zsh
|
RUN zsh /tmp/install.zsh
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
FROM p9k:base
|
ARG base
|
||||||
|
FROM p9k:${base}
|
||||||
|
|
||||||
COPY docker/zplugin/install.zsh /tmp/
|
COPY docker/zplugin/install.zsh /tmp/
|
||||||
RUN zsh /tmp/install.zsh
|
RUN zsh /tmp/install.zsh
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
FROM p9k:base
|
ARG base
|
||||||
|
FROM p9k:${base}
|
||||||
|
|
||||||
COPY docker/zpm/install.zsh /tmp/
|
COPY docker/zpm/install.zsh /tmp/
|
||||||
RUN zsh /tmp/install.zsh
|
RUN zsh /tmp/install.zsh
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
FROM p9k:base
|
ARG base
|
||||||
|
FROM p9k:${base}
|
||||||
|
|
||||||
COPY docker/zulu/install.zsh /tmp/
|
COPY docker/zulu/install.zsh /tmp/
|
||||||
RUN zsh /tmp/install.zsh
|
RUN zsh /tmp/install.zsh
|
||||||
|
|
184
test-in-docker
184
test-in-docker
|
@ -2,84 +2,156 @@
|
||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
setopt extendedglob
|
# The default ZSH to use.
|
||||||
|
default_version='4.3.11'
|
||||||
|
|
||||||
|
setopt extended_glob glob_subst numeric_glob_sort
|
||||||
cd "${${(%):-%x}:A:h}"
|
cd "${${(%):-%x}:A:h}"
|
||||||
|
|
||||||
# TODO: Crazy Logic to munge TERM to something supported in Ubuntu 14.04
|
# TODO: Crazy Logic to munge TERM to something supported in Ubuntu 14.04
|
||||||
term=screen-256color
|
term=screen-256color
|
||||||
|
|
||||||
frameworks()
|
# Note: If versions and frameworks looks complicated, it isn't that bad...
|
||||||
|
# ...see Modifiers in zshexpn(1) for details.
|
||||||
|
|
||||||
|
# List of ZSH versions
|
||||||
|
typeset -a versions
|
||||||
|
versions=( docker/base-*/Dockerfile(N.on:h:t:s/base-//) )
|
||||||
|
|
||||||
|
# List of frameworks
|
||||||
|
typeset -a frameworks
|
||||||
|
frameworks=( docker/*/Dockerfile(N.on:h:t) )
|
||||||
|
frameworks=${(@)frameworks:#base-*}
|
||||||
|
|
||||||
|
err()
|
||||||
{
|
{
|
||||||
for path in docker/*/Dockerfile(N.); do
|
print -P "%F{red}Error:%f $*"
|
||||||
framework=${path:h:t}
|
exit 2
|
||||||
if [[ "$framework" == base ]]; then continue; fi
|
|
||||||
echo "$framework"
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
show-help()
|
resolve_framework() {
|
||||||
{
|
local f=$1 found
|
||||||
echo "Usage: ${(%):-%x} <framework>|--list"
|
found=${frameworks[(In:-1:)$f*]}
|
||||||
echo
|
if (( found <= $#frameworks )); then
|
||||||
echo "Loads up a docker image with powershell9k configured in <framework>"
|
echo "${frameworks[$found]}"
|
||||||
echo
|
|
||||||
echo " --list Lists all available framework containers."
|
|
||||||
echo
|
|
||||||
echo "Framework containers:"
|
|
||||||
for f in $(frameworks); do
|
|
||||||
echo " - $f"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
build-and-run()
|
|
||||||
{
|
|
||||||
local framework="$1" ; shift
|
|
||||||
|
|
||||||
print -P "%F{green}Preparing ${framework} container...%f"
|
|
||||||
|
|
||||||
if [[ "$framework" != "base" ]]; then
|
|
||||||
echo -n "p9k:base: "
|
|
||||||
docker build \
|
|
||||||
--quiet \
|
|
||||||
--tag p9k:base \
|
|
||||||
--file docker/base/Dockerfile \
|
|
||||||
.
|
|
||||||
fi
|
fi
|
||||||
echo -n "p9k:${framework}: "
|
}
|
||||||
|
|
||||||
|
resolve_version() {
|
||||||
|
local v=$1 found
|
||||||
|
found=${versions[(In:-1:)$v*]}
|
||||||
|
if (( found <= $#versions )); then
|
||||||
|
echo "${versions[$found]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
build_and_run() {
|
||||||
|
local version="$1"
|
||||||
|
local framework="$2"
|
||||||
|
local name="${version}-${framework}"
|
||||||
|
|
||||||
|
print -P "%F{green}Preparing containers...%f"
|
||||||
|
|
||||||
|
echo -n "p9k:base-${version}: "
|
||||||
docker build \
|
docker build \
|
||||||
--quiet \
|
--quiet \
|
||||||
--tag "p9k:${framework}" \
|
--tag "p9k:base-${version}" \
|
||||||
|
--file "docker/base-${version}/Dockerfile" \
|
||||||
|
.
|
||||||
|
|
||||||
|
echo -n "p9k:${version}-${framework}: "
|
||||||
|
docker build \
|
||||||
|
--quiet \
|
||||||
|
--build-arg="base=base-${version}" \
|
||||||
|
--tag "p9k:${version}-${framework}" \
|
||||||
--file "docker/${framework}/Dockerfile" \
|
--file "docker/${framework}/Dockerfile" \
|
||||||
.
|
.
|
||||||
|
|
||||||
|
print -P "%F{green}Starting ${name} container...%f"
|
||||||
print -P "%F{green}Starting ${framework} container...%f"
|
|
||||||
exec docker run \
|
exec docker run \
|
||||||
--rm \
|
--rm \
|
||||||
--interactive \
|
--interactive \
|
||||||
--tty \
|
--tty \
|
||||||
--hostname="${framework}" \
|
--hostname="${name//./_}" \
|
||||||
--env="TERM=${term}" \
|
--env="TERM=${term}" \
|
||||||
"$@" \
|
"p9k:${version}-${framework}"
|
||||||
"p9k:${framework}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
arg1="${1:-}"; if (( $# > 0 )); then shift; fi
|
show_help() {
|
||||||
|
local f v
|
||||||
|
echo "Usage: ${(%):-%x} <framework>|--list"
|
||||||
|
echo
|
||||||
|
echo "Loads up a docker image with powershell9k configured in <framework>"
|
||||||
|
echo
|
||||||
|
echo " --frameworks Lists all available frameworks, newline separated."
|
||||||
|
echo " --versions Lists all available ZSH versions, newline separated."
|
||||||
|
echo " --zsh VER Uses ZSH with version VER."
|
||||||
|
echo " --help You're soaking in it."
|
||||||
|
echo
|
||||||
|
echo "ZSH versions:"
|
||||||
|
for v in "${(@)versions}"; do
|
||||||
|
echo " $v"
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
echo "Framework containers:"
|
||||||
|
for f in "${(@)frameworks}"; do
|
||||||
|
echo " $f"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
if [[ -z "$arg1" ]] || [[ "$arg1" == "help" ]]; then
|
# No arguments
|
||||||
show-help
|
if (( $# == 0 )); then
|
||||||
exit 0
|
show_help
|
||||||
elif [[ "$arg1" == '--list' ]]; then
|
exit
|
||||||
frameworks
|
|
||||||
exit 0
|
|
||||||
elif [[ -d "docker/${arg1}" ]]; then
|
|
||||||
build-and-run "$arg1"
|
|
||||||
elif [[ -n "docker/${arg1}"*/Dockerfile(#qN) ]]; then
|
|
||||||
# Allow globbing
|
|
||||||
build-and-run "docker/${arg1}"*(Y1:t)
|
|
||||||
else
|
|
||||||
show-help
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Parse flags and such.
|
||||||
|
use_version=$default_version
|
||||||
|
use_framework=
|
||||||
|
while (( $# > 0 )); do
|
||||||
|
case "$1" in
|
||||||
|
-f | --frameworks )
|
||||||
|
print -l "${(@)frameworks}"
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
-v | --versions )
|
||||||
|
print -l "${(@)versions}"
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
-z | --zsh )
|
||||||
|
shift
|
||||||
|
local v="$(resolve_version "$1")"
|
||||||
|
if [[ -n "$v" ]]; then
|
||||||
|
use_version=$v
|
||||||
|
else
|
||||||
|
err "No such ZSH version '${1}'"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
-h | --help )
|
||||||
|
show_help
|
||||||
|
exit
|
||||||
|
;;;
|
||||||
|
-* )
|
||||||
|
err "Unknown option ${1}"
|
||||||
|
show_help
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
if [[ -z "$use_framework" ]]; then
|
||||||
|
local f="$(resolve_framework "$1")"
|
||||||
|
if [[ -n "$f" ]]; then
|
||||||
|
use_framework=$f
|
||||||
|
else
|
||||||
|
err "No such framework '${1}'"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
err "You can only specify one framework at a time; you already specified '${use_framework}'"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
build_and_run "$use_version" "$use_framework"
|
||||||
|
|
||||||
# EOF
|
# EOF
|
||||||
|
|
Loading…
Reference in a new issue