mirror of https://github.com/kdabir/has.git
Verify version for each command (#43)
Thanks to contributions by @sdolenc * docker files * list tools for testing * test packages * github actions * documentation * ensure expected command count * output count of individual tools tested * test: eb rg podman subl brunch grunt gulp heroku netlify sls java brew gor, heroku, mvn, netlify, netlifyctl, php5, gcloud, hub, coreutils, brunch, code, kotlin, sbt, go, ant, gem, rake, autojump, groovy, aws, perl6, sbt, scala, lein
This commit is contained in:
parent
31828ec6bf
commit
4ccd0177d4
|
@ -0,0 +1,52 @@
|
|||
name: CI
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
shellcheck:
|
||||
name: shellcheck
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Clone Repo
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Run Shellcheck
|
||||
uses: ludeeus/action-shellcheck@0.1.0
|
||||
|
||||
test:
|
||||
name: test
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
container:
|
||||
- debian # uses debian:buster-20200327-slim which is debian 10.3
|
||||
- ubuntu16 # uses ubuntu:xenial-20200212 which is ubuntu 16.04
|
||||
|
||||
container: sdolenc/testing-has:${{ matrix.container }}
|
||||
|
||||
steps:
|
||||
- name: Clone Repo
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: test
|
||||
run: make test
|
||||
shell: bash
|
||||
|
||||
test_all:
|
||||
name: test_all
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
container:
|
||||
- ubuntu # uses ubuntu:bionic-20200311 which is ubuntu 18.04
|
||||
- alpine # uses bash:5.0.16 which is alpine 3.11
|
||||
|
||||
container: sdolenc/testing-has:${{ matrix.container }}
|
||||
|
||||
steps:
|
||||
- name: Clone Repo
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: test_all
|
||||
run: bats -t ./tests/test_all_packages.bats
|
||||
shell: bash
|
|
@ -46,6 +46,12 @@ teardown() {
|
|||
}
|
||||
|
||||
@test "..even if 'has' is missing from directory" {
|
||||
if [[ -n $GITHUB_ACTION ]] || [[ -n $GITHUB_ACTIONS ]]; then
|
||||
if grep -iq "ubuntu" /etc/issue; then
|
||||
skip "todo: this test fails on ubuntu in CI"
|
||||
fi
|
||||
fi
|
||||
|
||||
INSTALL_DIR="${HAS_TMPDIR}/system_local"
|
||||
cd "${BATS_TEST_DIRNAME}"
|
||||
mv has has-been
|
||||
|
@ -58,11 +64,16 @@ teardown() {
|
|||
|
||||
@test "make update runs git fetch" {
|
||||
cd "${BATS_TEST_DIRNAME}"
|
||||
skip "make update overwrites my git working tree"
|
||||
if [[ -z $GITHUB_ACTION ]] && [[ -z $GITHUB_ACTIONS ]]; then
|
||||
skip "make update overwrites my git working tree"
|
||||
elif grep -iq "ubuntu" /etc/issue; then
|
||||
skip "todo: this test fails on ubuntu in CI"
|
||||
fi
|
||||
|
||||
run make update
|
||||
|
||||
[ "$status" -eq 0 ]
|
||||
[ "${lines[*]}" =~ "git fetch --verbose" ]
|
||||
[ "$(echo "${output}" | grep "git fetch --verbose")" ]
|
||||
}
|
||||
|
||||
@test "works with single command check" {
|
||||
|
@ -167,7 +178,7 @@ teardown() {
|
|||
|
||||
@test "testing hub version is different to git version" {
|
||||
if ! command -v hub; then
|
||||
skip "'hub' command not found. This passes for @virgilwashere locally."
|
||||
skip "'hub' command not found. Installation command can be found at the bottom of ./tests/containers/debian.Dockerfile"
|
||||
fi
|
||||
run $has hub git
|
||||
|
||||
|
|
|
@ -182,11 +182,16 @@ On machines that don't even have `has` installed, your project's `.hasrc` is hon
|
|||
|
||||
## Adding more tools
|
||||
|
||||
The current list of supported packages can be viewed with `bash tests/packages_all.sh`
|
||||
|
||||
If the command you wish to include supports any of `-v`, `--version`, `-version`, `version`, `-V` then you can find
|
||||
corresponding function which can be called to check presence and extract version. However, for many tools version
|
||||
extraction may not work and you will need to add custom parsing of command's output. The `has` script is commented
|
||||
to guide developers about what needs to be done to add more tools.
|
||||
|
||||
`/tests/test_all_packages.bats` will test every package has supports. This includes newly added commands so please add new packages to
|
||||
- `alpine.Dockerfile` and `ubuntu.Dockerfile` to install the tool OR
|
||||
- `packages_alpine_skip.txt` and `packages_ubuntu_skip.txt` to exclude the package from the tests
|
||||
|
||||
## Adding Features
|
||||
|
||||
|
|
23
has
23
has
|
@ -10,16 +10,19 @@ readonly BINARY_NAME="has"
|
|||
readonly VERSION="v1.4.0"
|
||||
|
||||
## constants - symbols for success failure
|
||||
readonly txtreset="$(tput sgr0)"
|
||||
readonly txtbold="$(tput bold)"
|
||||
readonly txtblack="$(tput setaf 0)"
|
||||
readonly txtred="$(tput setaf 1)"
|
||||
readonly txtgreen="$(tput setaf 2)"
|
||||
readonly txtyellow="$(tput setaf 3)"
|
||||
readonly txtblue="$(tput setaf 4)"
|
||||
readonly txtpurple="$(tput setaf 5)"
|
||||
readonly txtcyan="$(tput setaf 6)"
|
||||
readonly txtwhite="$(tput setaf 7)"
|
||||
if [[ -z $TERM ]]; then
|
||||
$TERM="xterm"
|
||||
fi
|
||||
readonly txtreset="$(tput -T $TERM sgr0)"
|
||||
readonly txtbold="$(tput -T $TERM bold)"
|
||||
readonly txtblack="$(tput -T $TERM setaf 0)"
|
||||
readonly txtred="$(tput -T $TERM setaf 1)"
|
||||
readonly txtgreen="$(tput -T $TERM setaf 2)"
|
||||
readonly txtyellow="$(tput -T $TERM setaf 3)"
|
||||
readonly txtblue="$(tput -T $TERM setaf 4)"
|
||||
readonly txtpurple="$(tput -T $TERM setaf 5)"
|
||||
readonly txtcyan="$(tput -T $TERM setaf 6)"
|
||||
readonly txtwhite="$(tput -T $TERM setaf 7)"
|
||||
# unicode "✗"
|
||||
readonly fancyx='\342\234\227'
|
||||
# unicode "✓"
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
# has containers
|
||||
|
||||
Custom containers used for testing https://github.com/kdabir/has
|
||||
|
||||
| container image | status |
|
||||
|------------------------------|--------|
|
||||
| sdolenc/testing-has:alpine | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/sdolenc/testing-has/alpine) |
|
||||
| sdolenc/testing-has:ubuntu | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/sdolenc/testing-has/ubuntu) |
|
||||
| sdolenc/testing-has:debian | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/sdolenc/testing-has/debian) |
|
||||
| sdolenc/testing-has:ubuntu16 | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/sdolenc/testing-has/ubuntu16) |
|
|
@ -0,0 +1,141 @@
|
|||
FROM bash:5.0.16
|
||||
|
||||
# already contains
|
||||
# awk
|
||||
# bash=5.0.16
|
||||
# bzip2
|
||||
# grep
|
||||
# gzip=1.31.1
|
||||
# sed=4.0
|
||||
# tar=1.31.1
|
||||
# unzip=6.00
|
||||
# wget
|
||||
# xz
|
||||
RUN apk add --no-cache \
|
||||
ack=3.2.0-r0 \
|
||||
apache2-utils~=2.4 `# ab=2.3` \
|
||||
apache-ant=1.10.7-r0 `# ant=1.10.7` \
|
||||
build-base libffi-dev openssl-dev `# required for eb` \
|
||||
curl=7.67.0-r0 \
|
||||
bzr=2.7.0-r1 \
|
||||
docker=19.03.5-r0 \
|
||||
emacs=26.3-r2 \
|
||||
file=5.37-r1 \
|
||||
gcc=9.2.0-r4 \
|
||||
git~=2.24.3 \
|
||||
go=1.13.4-r1 \
|
||||
gradle=5.6.4-r0 \
|
||||
hugo=0.61.0-r0 \
|
||||
jq=1.6-r0 \
|
||||
make=4.2.1-r2 \
|
||||
maven=3.6.3-r0 `# mvn=3.6.3` \
|
||||
mercurial=5.3.2-r0 `# hg=5.3.2` \
|
||||
nano=4.6-r0 \
|
||||
ncurses=6.1_p20200118-r3 `#tput:todo` \
|
||||
npm=12.15.0-r1 `# npm=6.13.4 # node=12.15.0` \
|
||||
openjdk11=11.0.5_p10-r0 `# java=11.0.5` \
|
||||
perl=5.30.1-r0 ` # perl=30` \
|
||||
php7=7.3.17-r0 `# php=7.3.17 ` \
|
||||
postgresql=12.2-r0 `# psql=12.2` \
|
||||
pv=1.6.6-r1 \
|
||||
python=2.7.16-r3 \
|
||||
python3-dev=3.8.2-r0 `#python3=3.8.2` \
|
||||
R=3.6.2-r0 \
|
||||
ruby=2.6.6-r2 `# gem=3.0.3` \
|
||||
ruby-bundler=2.0.2-r1 `# bundle=2.0.2` \
|
||||
ruby-bigdecimal ruby-json `# required for brew` \
|
||||
ruby-rake=2.6.6-r2 `# rake=12.3.3` \
|
||||
subversion=1.12.2-r1 `# svn=1.12.2` \
|
||||
sudo=1.8.31-r0 \
|
||||
tree=1.8.0-r0 \
|
||||
vim~=8.2 \
|
||||
yarn=1.19.2-r0 \
|
||||
zip=3.0-r7 \
|
||||
zsh=5.7.1-r0 && \
|
||||
\
|
||||
# required for brew and lein
|
||||
ln -s $(which bash) /bin/bash && \
|
||||
\
|
||||
npm install --global \
|
||||
brunch@"=3.0.0" \
|
||||
grunt-cli@"=1.3.2" \
|
||||
gulp-cli@"=2.2.0" \
|
||||
heroku@"=7.39.3" \
|
||||
netlify-cli@"=2.46.0" \
|
||||
serverless@"=1.67.3" `# sls=1.67.3` && \
|
||||
\
|
||||
autojump=22.5.3 && \
|
||||
curl -L "https://github.com/wting/autojump/archive/release-v${autojump}.tar.gz" | tar xz && \
|
||||
cd "autojump-release-v${autojump}" && \
|
||||
SHELL=bash ./install.py && \
|
||||
cd / && \
|
||||
ln -s ~/.autojump/bin/autojump /usr/local/bin/autojump && \
|
||||
\
|
||||
commit="87b16eb" `# bats=1.2.0` && \
|
||||
curl -L "https://github.com/bats-core/bats-core/tarball/${commit}" | tar xz && \
|
||||
"bats-core-bats-core-${commit}/install.sh" /usr/local && \
|
||||
\
|
||||
brew=2.2.13 && \
|
||||
git clone --branch ${brew} https://github.com/Homebrew/brew && \
|
||||
eval $(brew/bin/brew shellenv) && \
|
||||
ln -s /brew/bin/brew /usr/local/bin/brew && \
|
||||
brew --version && \
|
||||
\
|
||||
eb=3.18.0-1 && \
|
||||
curl -L "https://github.com/sdolenc/aws-elastic-beanstalk-cli/archive/${eb}.tar.gz" | tar xz && \
|
||||
pip3 install ./aws-elastic-beanstalk-cli-${eb} && \
|
||||
\
|
||||
gcloud=289.0.0 && \
|
||||
curl -L "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${gcloud}-linux-x86_64.tar.gz" | tar xz && \
|
||||
ln -s /google-cloud-sdk/bin/gcloud /usr/local/bin/gcloud && \
|
||||
\
|
||||
gor=1.0.0 && \
|
||||
curl -L "https://github.com/buger/goreplay/releases/download/v${gor}/gor_${gor}_x64.tar.gz" | tar xz --directory /usr/local/bin && \
|
||||
\
|
||||
groovy=3.0.3 && \
|
||||
curl -L "https://dl.bintray.com/groovy/maven/apache-groovy-binary-${groovy}.zip" -o /groovy.zip && \
|
||||
unzip groovy.zip && rm groovy.zip && \
|
||||
ln -s "/groovy-3.0.3/bin/groovy" /usr/local/bin/groovy && \
|
||||
\
|
||||
pip3 install \
|
||||
awscli==1.18.43 `# aws=1.18.43` \
|
||||
httpie==2.1.0 `# http=2.1.0` && \
|
||||
\
|
||||
hub=2.14.2 && \
|
||||
curl -L "https://github.com/github/hub/releases/download/v${hub}/hub-linux-386-${hub}.tgz" | tar xz && \
|
||||
ln -s "/hub-linux-386-${hub}/bin/hub" /usr/local/bin/hub && \
|
||||
\
|
||||
`# javac=11.0.5` && \
|
||||
ln -s "/usr/lib/jvm/java-11-openjdk/bin/javac" /usr/local/bin/javac && \
|
||||
\
|
||||
kotlin=1.3.72 && \
|
||||
curl -L "https://github.com/JetBrains/kotlin/releases/download/v${kotlin}/kotlin-compiler-${kotlin}.zip" -o /kotlin.zip && \
|
||||
unzip kotlin.zip && rm kotlin.zip && \
|
||||
ln -s /kotlinc/bin/kotlin /usr/local/bin/kotlin && \
|
||||
ln -s /kotlinc/bin/kotlinc /usr/local/bin/kotlinc && \
|
||||
\
|
||||
netlifyctl=0.4.0 && \
|
||||
curl -L "https://github.com/netlify/netlifyctl/releases/download/v${netlifyctl}/netlifyctl-linux-amd64-${netlifyctl}.tar.gz" | tar xz --directory /usr/local/bin && \
|
||||
\
|
||||
perl6=2020.02.1-04 && \
|
||||
curl -L "https://github.com/nxadm/rakudo-pkg/releases/download/v${perl6}/rakudo-pkg-Alpine3.11_${perl6}_x86_64.apk" --output perl6.apk && \
|
||||
apk add --allow-untrusted perl6.apk && rm perl6.apk && \
|
||||
ln -s /opt/rakudo-pkg/bin/perl6 /usr/local/bin/perl6 && \
|
||||
\
|
||||
rg=12.0.1 && \
|
||||
curl -L "https://github.com/BurntSushi/ripgrep/releases/download/${rg}/ripgrep-${rg}-x86_64-unknown-linux-musl.tar.gz" | tar xz && \
|
||||
ln -s "/ripgrep-${rg}-x86_64-unknown-linux-musl/rg" /usr/local/bin/rg && \
|
||||
\
|
||||
sbt=1.3.4 && \
|
||||
curl -L "https://piccolo.link/sbt-${sbt}.tgz" | tar xz && \
|
||||
ln -s /sbt/bin/sbt /usr/local/bin/sbt && \
|
||||
sbt --version && sbt --version && \
|
||||
\
|
||||
scala=2.12.11 && \
|
||||
curl -L "https://downloads.lightbend.com/scala/${scala}/scala-${scala}.tgz" | tar xz && \
|
||||
ln -s "/scala-${scala}/bin/scala" /usr/local/bin/scala && \
|
||||
\
|
||||
echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
|
||||
apk add --no-cache \
|
||||
leiningen=2.9.1-r0 `# lein=2.9.1` \
|
||||
podman=1.9.0-r0
|
|
@ -0,0 +1,33 @@
|
|||
FROM debian:buster-20200327-slim
|
||||
|
||||
# already contains
|
||||
# apt
|
||||
# apt-get
|
||||
# bash
|
||||
# grep
|
||||
# gzip
|
||||
# tar
|
||||
RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y -qq \
|
||||
bc \
|
||||
pv \
|
||||
xz-utils \
|
||||
unar \
|
||||
make \
|
||||
curl \
|
||||
git \
|
||||
unzip \
|
||||
xz-utils `#xz` \
|
||||
unar \
|
||||
pv \
|
||||
zip \
|
||||
sudo \
|
||||
file \
|
||||
&& apt-get -y autoremove && apt-get -y clean && rm -rf /var/lib/apt/lists/*; \
|
||||
\
|
||||
#bats
|
||||
commit="87b16eb"; \
|
||||
curl -L "https://github.com/bats-core/bats-core/tarball/${commit}" | tar xz; \
|
||||
"bats-core-bats-core-${commit}/install.sh" /usr/local; \
|
||||
\
|
||||
#hub
|
||||
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.2
|
|
@ -0,0 +1,143 @@
|
|||
FROM ubuntu:bionic-20200311
|
||||
|
||||
# already contains
|
||||
# apt=1.6.12
|
||||
# apt-get=1.6.12
|
||||
# awk
|
||||
# bash=4.4.20
|
||||
# bzip2=1.0.6
|
||||
# gnu_coreutils=8.28
|
||||
# grep=3.1
|
||||
# gzip=1.6
|
||||
# perl=26
|
||||
# sed=4.4
|
||||
# tar=1.29
|
||||
# tput #todo
|
||||
RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y -qq \
|
||||
ack=2.22* \
|
||||
ant=1.10.5* \
|
||||
apache2-utils=2.4* `# ab=2.3` \
|
||||
apt-utils `# todo` \
|
||||
aptitude=0.8.10* \
|
||||
autojump=22.5.0* \
|
||||
awscli=1.14.44* `# aws=1.14.44` \
|
||||
build-essential zlib1g-dev libssl-dev libncurses-dev libffi-dev libsqlite3-dev libreadline-dev libbz2-dev `# required for eb` \
|
||||
bzr=2.7.0+bzr6622-10 `# bzr=2.8.0` \
|
||||
curl=7.58.0* \
|
||||
docker.io=19.03.6* `# docker=19.03.6` \
|
||||
emacs=47.0 `# emacs=25.2.2` \
|
||||
file=1:5.32* \
|
||||
gcc=4:7.4.0-1ubuntu2.3 `# gcc=7.5.0` \
|
||||
git=1:2.17.1* \
|
||||
gpg-agent `# todo:apt-key` \
|
||||
gradle=4.4.1* \
|
||||
groovy=2.4.16* \
|
||||
httpie=0.9.8* `# http=0.9.8` \
|
||||
hugo=0.40.1* \
|
||||
jq=1.5* \
|
||||
leiningen=2.8.1* `# lein=2.8.1` \
|
||||
locales `# required for brew` \
|
||||
make=4.1* \
|
||||
maven=3.6.0* `# mvn=3.6.0` \
|
||||
mercurial=4.5.3* `# hg=4.5.3` \
|
||||
nano=2.9.3* \
|
||||
openjdk-11-jdk-headless=11.0.7* `# java=11.0.7 # javac=11.0.7` \
|
||||
perl6=6.c-1 `# perl6=2018.03` \
|
||||
php=1:7.2+60ubuntu1 `# php=7.2.24` \
|
||||
postgresql-client=10+190* `# psql=10.12` \
|
||||
pv=1.6.6* \
|
||||
python=2.7.15~rc1-1 `# python=2.7.17` \
|
||||
python3=3.6.7-1~18.04 `# python3=3.6.9` \
|
||||
r-cran-littler=0.3.3* `# R=3.4.4` \
|
||||
rake=12.3.1* \
|
||||
ruby=1:2.5.1 \
|
||||
ruby-bundler=1.16.1* `# bundle=1.16.1` \
|
||||
rubygems `# gem=2.7.6` \
|
||||
scala=2.11.12* \
|
||||
silversearcher-ag=2.1.0* `# ag=2.1.0` \
|
||||
software-properties-common `# todo:add-apt-repository` \
|
||||
subversion=1.9.7* `# svn=1.9.7` \
|
||||
sudo=1.8.21* \
|
||||
tree=1.7.0* \
|
||||
unar=1.10.1* \
|
||||
unzip=6.0-21ubuntu1 `# unzip=6.00` \
|
||||
vim=2:8.0* \
|
||||
wget=1.19.4* \
|
||||
xz-utils=5.2.2* `# xz=5.2.2` \
|
||||
yarn `# yarn=0.32` \
|
||||
zip=3.0* \
|
||||
zsh=5.4.2* && \
|
||||
\
|
||||
commit="87b16eb" `# bats=1.2.0` && \
|
||||
curl -L "https://github.com/bats-core/bats-core/tarball/${commit}" | tar xz && \
|
||||
"bats-core-bats-core-${commit}/install.sh" /usr/local && \
|
||||
\
|
||||
brew=2.2.13 && \
|
||||
git clone --branch ${brew} https://github.com/Homebrew/brew && \
|
||||
locale-gen en_US en_US.UTF-8 && \
|
||||
eval $(brew/bin/brew shellenv) && \
|
||||
ln -s /brew/bin/brew /usr/local/bin/brew && \
|
||||
brew --version && \
|
||||
\
|
||||
code=1.44.2 && \
|
||||
curl -L "https://az764295.vo.msecnd.net/stable/ff915844119ce9485abfe8aa9076ec76b5300ddd/code_${code}-1587059832_amd64.deb" --output code_${code}.deb && \
|
||||
`# installing missing dependencies requires apt update which is the first done above` \
|
||||
dpkg -i code_${code}.deb || apt-get install -f -y && \
|
||||
rm -f code_${code}.deb && \
|
||||
\
|
||||
commit="102025c" `# eb=3.18.0` && \
|
||||
curl -L "https://github.com/aws/aws-elastic-beanstalk-cli-setup/tarball/${commit}" | tar xz && \
|
||||
"aws-aws-elastic-beanstalk-cli-setup-${commit}/scripts/bundled_installer" && \
|
||||
ln -s /root/.ebcli-virtual-env/executables/eb /usr/local/bin/eb && \
|
||||
\
|
||||
gcloud=289.0.0 && \
|
||||
curl -L "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-${gcloud}-linux-x86_64.tar.gz" | tar xz && \
|
||||
ln -s /google-cloud-sdk/bin/gcloud /usr/local/bin/gcloud && \
|
||||
\
|
||||
gor=1.0.0 && \
|
||||
curl -L "https://github.com/buger/goreplay/releases/download/v${gor}/gor_${gor}_x64.tar.gz" | tar xz --directory /usr/local/bin && \
|
||||
\
|
||||
hub=2.14.2 && \
|
||||
curl -fsSL "https://github.com/github/hub/raw/master/script/get" | bash -s ${hub} && \
|
||||
\
|
||||
kotlin=1.3.72 && \
|
||||
curl -L "https://github.com/JetBrains/kotlin/releases/download/v${kotlin}/kotlin-compiler-${kotlin}.zip" -o /kotlin.zip && \
|
||||
unzip kotlin.zip && rm kotlin.zip && \
|
||||
ln -s /kotlinc/bin/kotlin /usr/local/bin/kotlin && \
|
||||
ln -s /kotlinc/bin/kotlinc /usr/local/bin/kotlinc && \
|
||||
\
|
||||
netlifyctl=0.4.0 && \
|
||||
curl -L "https://github.com/netlify/netlifyctl/releases/download/v${netlifyctl}/netlifyctl-linux-amd64-${netlifyctl}.tar.gz" | tar xz --directory /usr/local/bin && \
|
||||
\
|
||||
rg=12.0.1 && \
|
||||
curl -L "https://github.com/BurntSushi/ripgrep/releases/download/${rg}/ripgrep-${rg}-x86_64-unknown-linux-musl.tar.gz" | tar xz && \
|
||||
ln -s "/ripgrep-${rg}-x86_64-unknown-linux-musl/rg" /usr/local/bin/rg && \
|
||||
\
|
||||
sbt=1.3.4 && \
|
||||
curl -L "https://piccolo.link/sbt-${sbt}.tgz" | tar xz && \
|
||||
ln -s /sbt/bin/sbt /usr/local/bin/sbt && \
|
||||
sbt --version && sbt --version && \
|
||||
\
|
||||
add-apt-repository -y ppa:longsleep/golang-backports `#go` && \
|
||||
curl -sL https://deb.nodesource.com/setup_12.x | bash - `#node and npm` &&\
|
||||
add-apt-repository -y ppa:ondrej/php `#php5` && \
|
||||
add-apt-repository -y ppa:projectatomic/ppa `#podman` && \
|
||||
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add - `#subl` && \
|
||||
add-apt-repository -y "deb https://download.sublimetext.com/ apt/stable/" `#subl` && \
|
||||
apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y -qq \
|
||||
golang-go=2:1.14* `# go=1.14.2` \
|
||||
nodejs=12.16.2* `# node=12.16.2 # npm=6.14.4` \
|
||||
php5.6=5.6.40* `# php5=5.6.40` \
|
||||
podman=1.6.2* \
|
||||
sublime-text=3211 `# subl=3211` && \
|
||||
ln -s /usr/bin/php5.6 /usr/bin/php5 && \
|
||||
\
|
||||
npm install --global \
|
||||
brunch@"=3.0.0" \
|
||||
grunt-cli@"=1.3.2" \
|
||||
gulp-cli@"=2.2.0" \
|
||||
heroku@"=7.39.3" \
|
||||
netlify-cli@"=2.46.0" \
|
||||
serverless@"=1.67.3" `# sls=1.67.3` && \
|
||||
\
|
||||
apt-get -y autoremove && apt-get -y clean && rm -rf /var/lib/apt/lists/*
|
|
@ -0,0 +1,33 @@
|
|||
FROM ubuntu:xenial-20200212
|
||||
|
||||
# already contains
|
||||
# apt
|
||||
# apt-get
|
||||
# bash
|
||||
# grep
|
||||
# gzip
|
||||
# tar
|
||||
RUN apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y -qq \
|
||||
bc \
|
||||
pv \
|
||||
xz-utils \
|
||||
unar \
|
||||
make \
|
||||
curl \
|
||||
git \
|
||||
unzip \
|
||||
xz-utils `#xz` \
|
||||
unar \
|
||||
pv \
|
||||
zip \
|
||||
sudo \
|
||||
file \
|
||||
&& apt-get -y autoremove && apt-get -y clean && rm -rf /var/lib/apt/lists/*; \
|
||||
\
|
||||
#bats
|
||||
commit="87b16eb"; \
|
||||
curl -L "https://github.com/bats-core/bats-core/tarball/${commit}" | tar xz; \
|
||||
"bats-core-bats-core-${commit}/install.sh" /usr/local; \
|
||||
\
|
||||
#hub
|
||||
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.2
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
## This script outputs all of the packages that has explicitly supports.
|
||||
set -euo pipefail
|
||||
|
||||
pushd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null
|
||||
|
||||
grep -o "^ \\+[a-zA-Z0-9_|-]\\+)" ../has | grep -o "[a-zA-Z0-9_|-]\\+" | tr "|" "\\n" | sort -f
|
||||
|
||||
popd >/dev/null
|
|
@ -0,0 +1,55 @@
|
|||
# Not pre-installed to container, but repository cloned during CI
|
||||
has
|
||||
|
||||
# non-alpine packages
|
||||
apt
|
||||
apt-get
|
||||
aptitude
|
||||
code
|
||||
subl
|
||||
|
||||
# gnu_coreutils shows as installed, but is not on alpine.
|
||||
# todo: We should change the command we use for this to
|
||||
# something busybox doesn't also implement. Examples:
|
||||
# chcon, csplit, dir, dircolors, fmt, join, logname, pathchk,
|
||||
# pinky, pr, ptx, runcon, stdbuf, tsort, users, vdir, who
|
||||
# Then we can move this to the "non-alpine packages" list above.
|
||||
gnu_coreutils
|
||||
|
||||
# installed on container (and has confirms), but
|
||||
# todo: has shows EMPTY version string on container
|
||||
awk
|
||||
bzip2
|
||||
grep
|
||||
gzip
|
||||
wget
|
||||
xz
|
||||
|
||||
# installed on container (and has confirms), but
|
||||
# todo: has grabs INCORRECT version string on container
|
||||
jq
|
||||
perl
|
||||
|
||||
# installed on container, but
|
||||
# todo: has reports command not found
|
||||
gor
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# tools below have not be added to the alpine test container image.
|
||||
# todo: we may need to compile executable binaries that run on alpine 3.11
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
# todo: compile binary with help from:
|
||||
# https://github.com/ggreer/the_silver_searcher
|
||||
# https://github.com/Ketouem/ag-alpine
|
||||
ag
|
||||
|
||||
# apk available for alpine 3.8
|
||||
# todo: compile binary with help from:
|
||||
# https://github.com/sgerrand/alpine-pkg-php5
|
||||
php5
|
||||
|
||||
# todo: compile binary with help from:
|
||||
# https://theunarchiver.com/command-line
|
||||
# https://github.com/ashang/unar
|
||||
unar
|
|
@ -0,0 +1,16 @@
|
|||
# Not pre-installed to container, but repository cloned during CI
|
||||
has
|
||||
|
||||
# Tests are run as admin in CI. Code requires an extra paramater to get version as admin.
|
||||
# todo: add --user-data-dir=/tmp for code when has is run as admin
|
||||
code
|
||||
|
||||
# installed on container (and has confirms), but
|
||||
# todo: has shows EMPTY version string on container
|
||||
awk
|
||||
groovy
|
||||
|
||||
# --------------------------------------------------------------------------
|
||||
# tools below have not be added to the ubuntu test container image.
|
||||
# --------------------------------------------------------------------------
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
cd $BATS_TEST_DIRNAME
|
||||
|
||||
distro="alpine"
|
||||
if grep -iq "ubuntu" /etc/issue; then
|
||||
distro="ubuntu"
|
||||
fi
|
||||
SKIP_FILE=packages_${distro}_skip.txt
|
||||
DOCKER_FILE=./containers/${distro}.Dockerfile
|
||||
|
||||
expected_version() {
|
||||
grep -Eo "( |#)${1}(|-cli)(|@\"|~)=[^\`\"; *-]+" $DOCKER_FILE | tr "=" "\n" | tr ":" "\n" | tail -1
|
||||
}
|
||||
|
||||
@test "test each package individually and verify version" {
|
||||
packages_count=0
|
||||
final_status=0
|
||||
for package in $(bash packages_all.sh); do
|
||||
if [ -n $package ] && ! grep -q "^$package$" $SKIP_FILE; then
|
||||
run expected_version $package
|
||||
[ "$status" -eq 0 ]
|
||||
[ -n "$output" ]
|
||||
|
||||
package="$package" expected_ver="$output" run bats -t test_package.bats
|
||||
echo "# $output" >&3
|
||||
echo "#" >&3
|
||||
packages_count=$(($packages_count + 1))
|
||||
final_status=$(($final_status + $status))
|
||||
fi
|
||||
done
|
||||
|
||||
echo "# tested ${packages_count} commands individually" >&3
|
||||
echo "#" >&3
|
||||
|
||||
echo "# status code=$final_status" >&3
|
||||
[ "$final_status" -eq 0 ]
|
||||
echo "#" >&3
|
||||
}
|
||||
|
||||
@test "test all packages at once" {
|
||||
# subtract skips from full list
|
||||
packages_to_skip="$(grep -Ev "^\s*(#|$)" $SKIP_FILE | xargs | tr " " "|")"
|
||||
packages=$(bash packages_all.sh | egrep -Ev "^($packages_to_skip)$" | xargs)
|
||||
|
||||
run ../has $packages
|
||||
echo "$output" >&3
|
||||
echo "#" >&3
|
||||
|
||||
packages_count=$(echo "${packages}" | wc -w)
|
||||
echo "# tested ${packages_count} commands simultaneously" >&3
|
||||
actual_packages_count=$(echo "${output}" | wc -l)
|
||||
echo "# received output from ${actual_packages_count} commands" >&3
|
||||
[ "$packages_count" -eq "$actual_packages_count" ]
|
||||
echo "#" >&3
|
||||
|
||||
echo "# status code=$status" >&3
|
||||
[ "$status" -eq 0 ]
|
||||
echo "#" >&3
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
cd $BATS_TEST_DIRNAME
|
||||
|
||||
get_version_from_has() {
|
||||
echo "$1" | tr " " "\n" | tail -1
|
||||
}
|
||||
|
||||
@test "test $package" {
|
||||
# Ensure inputs
|
||||
[ "$(echo "${package}" | wc -w)" -eq 1 ]
|
||||
[ "$(echo "${expected_ver}" | wc -w)" -eq 1 ]
|
||||
|
||||
# Confirm package is installed
|
||||
run ../has $package
|
||||
echo "$output" >&3
|
||||
[ "$status" -eq 0 ]
|
||||
|
||||
# Get actual version (reported from has)
|
||||
actual_ver=""
|
||||
run get_version_from_has "$output"
|
||||
if [ "$status" -eq 0 ]; then
|
||||
actual_ver="$output"
|
||||
[ "$(echo "${actual_ver}" | wc -w)" -eq 1 ]
|
||||
fi
|
||||
|
||||
# Compare expected with actual
|
||||
# We grep instead of direct compare because has adds ansi colors with tput
|
||||
[ "$(echo "${actual_ver}" | grep "$expected_ver")" ]
|
||||
}
|
Loading…
Reference in New Issue