Skip to content

Commit

Permalink
overhaul travis config; run acceptance in docker container
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoblitt committed Jul 9, 2018
1 parent f8ebb64 commit f00b527
Show file tree
Hide file tree
Showing 12 changed files with 259 additions and 84 deletions.
8 changes: 8 additions & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
ignored:
# disable USER root
- DL3002
# disable pinning apk package versions
- DL3018
# disable following sourced files
- SC1091
8 changes: 8 additions & 0 deletions .mdl_style.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# https://github.com/markdownlint/markdownlint/blob/master/docs/creating_styles.md
# https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md
all
rule "MD013", :code_blocks => false
exclude_rule "MD003"
exclude_rule "MD013"
exclude_rule "MD034"
exclude_rule "MD036"
5 changes: 5 additions & 0 deletions .mdlrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# a separate "style" file must be used to pass "parameters" to a rule
#
# https://github.com/markdownlint/markdownlint/blob/master/docs/configuration.md
# https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md
style ".mdl_style.rb"
133 changes: 49 additions & 84 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,95 +1,60 @@
language: cpp
os:
- linux
#- osx
# the default precise linux container has gcc 4.6
sudo: required
dist: trusty
compiler:
- clang
- gcc
addons:
apt:
packages:
- tcsh
script: |
set -e
if [[ -n ${ANCIENT_BASH+1} ]]; then
VER="bash-${ANCIENT_BASH}"
curl -sSLO "http://ftp.gnu.org/gnu/bash/${VER}.tar.gz"
tar -xf "${VER}.tar.gz"
cd "$VER"
./configure
make -j
export PATH="$(pwd):$PATH"
cd ..
bash --version
fi
if [[ $BATCH == true ]]; then
echo -e "*** testing batch mode in Python version $PYVER ***\n"
bash -x ./scripts/newinstall.sh -cb -${PYVER}
else
echo -e "*** testing interactive mode in Python version $PYVER ***\n"
echo -e "yes\nyes" | bash -x ./scripts/newinstall.sh -c -${PYVER}
fi
echo -e "*** Testing initializaion of shell environment ***\n"
case $MANGLER in
tcsh)
# csh_20110502-2ubuntu2_amd64.deb from ubuntu:trusty (travis) opens a new
# shell interactive shell when passed--version
tcsh --version
tcsh -ec 'source loadLSST.csh && echo $EUPS_PKGROOT'
;;
*)
bash --version
bash -ec 'source loadLSST.bash && echo $EUPS_PKGROOT'
;;
esac
echo -e "*** Sanity checking EUPS_PKGROOT construction ***\n"
source loadLSST.bash
eups distrib install python -t v14_0_rc2
env:
- BATCH=true PYVER="3"
- BATCH=false PYVER="3"
- BATCH=true PYVER="3" ANCIENT_BASH="3.2.57"
- BATCH=false PYVER="3" ANCIENT_BASH="3.2.57"
- MANGLER=tcsh BATCH=true PYVER="3"
---
sudo: false
language: c
matrix:
# osx builds are often very slow to start due to high demand
fast_finish: true
#allow_failures:
# - os: osx
include:
- os: linux
env: RSPEC_BASH=true
compiler:
language: ruby
rvm: '2.4'
script: bundle exec rubocop && bundle exec rspec --format doc
- os: linux
env: SHELLCHECK=true
compiler:
- &accept
os: linux
env:
- BATCH=false PYVER="3"
- BATCH=true PYVER="3"
- BATCH=true PYVER="3" ANCIENT_BASH="3.2.57"
- BATCH=false PYVER="3" ANCIENT_BASH="3.2.57"
- MANGLER=tcsh BATCH=true PYVER="3"
- MANGLER=tcsh BATCH=false PYVER="3"
services:
- docker
script:
- docker run -v $(pwd):/r koalaman/shellcheck-alpine:v0.4.7 /r/scripts/newinstall.sh
- os: linux
script: ./tests/docker-acceptance.sh

- &ruby
env: TEST=rubocop
language: ruby
rvm: '2.5'
script: bundle exec rubocop

- <<: *ruby
env: TEST=rspec-bash
script: bundle exec rspec --format doc

- &plumb
env: TEST=markdownlint
language: c
services:
- docker
script: |
set -e
shopt -s globstar nullglob
CHECK=( **/*.md )
[[ ${#CHECK[@]} -eq 0 ]] && exit
docker run -ti -v $(pwd):$(pwd) -w $(pwd) \
mivok/markdownlint:0.4.0 "${CHECK[@]}"
script: ./tests/mdl.sh

- <<: *plumb
env: TEST=yamllint
script: ./tests/yamllint.sh

- <<: *plumb
env: TEST=shellcheck
script: ./tests/shellcheck.sh

- <<: *plumb
env: TEST=hadolint
script: ./tests/hadolint.sh

- env: TEST=make
script: ./tests/make.sh
# osx builds are often very slow to start due to high demand
fast_finish: true
# allow_failures:
# - os: osx
branches:
only:
- master
- /^\d+\.\d+(\.\d+)?$/
- master
# also matched against tag pushes
- /^\d+\.\d+(\.\d+)?$/
notifications:
email: false
19 changes: 19 additions & 0 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM lsstsqre/centos:7-stackbase-devtoolset-6

ARG D_USER
ARG D_UID
ARG D_GROUP
ARG D_GID
ARG D_HOME

USER root
RUN yum install -y tcsh

RUN mkdir -p "$(dirname "$D_HOME")"
RUN groupadd -g "$D_GID" "$D_GROUP"
RUN useradd -d "$D_HOME" -g "$D_GROUP" -u "$D_UID" "$D_USER"

USER $D_USER
WORKDIR $D_HOME

SHELL ["/bin/bash", "-lc"]
10 changes: 10 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
docker:
docker build \
-t newinstall-testenv \
--pull=true \
--build-arg D_USER="$(shell id -un)" \
--build-arg D_UID="$(shell id -u)" \
--build-arg D_GROUP="$(shell id -gn)" \
--build-arg D_GID="$(shell id -g)" \
--build-arg D_HOME="$(HOME)" \
.
15 changes: 15 additions & 0 deletions tests/docker-acceptance.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

set -eo pipefail

( set -eo pipefail
cd tests
make
)

docker run -ti \
-v"$(pwd):$(pwd)" -w "$(pwd)" \
-e MODE="$MODE" \
newinstall-testenv:latest bash -lc ./tests/acceptance.sh

# vim: tabstop=2 shiftwidth=2 expandtab
28 changes: 28 additions & 0 deletions tests/hadolint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -e
shopt -s globstar nullglob

CHECK=( **/Dockerfile )
IGNORE=()

for c in "${!CHECK[@]}"; do
for i in "${IGNORE[@]}"; do
[[ ${CHECK[c]} == "$i" ]] && unset -v 'CHECK[c]'
done
done
[[ ${#CHECK[@]} -eq 0 ]] && { echo 'no files to check'; exit 0; }

echo '---'
echo 'check:'
for c in "${CHECK[@]}"; do
echo " - ${c}"
done
echo

for f in "${CHECK[@]}"; do
docker run -ti -v "$(pwd):$(pwd)" -w "$(pwd)" \
hadolint/hadolint hadolint "$f"
done

# vim: tabstop=2 shiftwidth=2 expandtab
31 changes: 31 additions & 0 deletions tests/make.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

set -e
shopt -s globstar nullglob

CHECK=( tests/**/Makefile )
IGNORE=()

for c in "${!CHECK[@]}"; do
for i in "${IGNORE[@]}"; do
[[ ${CHECK[c]} == "$i" ]] && unset -v 'CHECK[c]'
done
done
[[ ${#CHECK[@]} -eq 0 ]] && { echo 'no files to check'; exit 0; }

echo '---'
echo 'check:'
for c in "${CHECK[@]}"; do
echo " - ${c}"
done
echo

for f in "${CHECK[@]}"; do
( set -e
cd "$(dirname "$f")"
echo "checking $f"
make --dry-run --warn-undefined-variables
)
done

# vim: tabstop=2 shiftwidth=2 expandtab
26 changes: 26 additions & 0 deletions tests/mdl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -e
shopt -s globstar nullglob

CHECK=( **/*.md )
IGNORE=()

for c in "${!CHECK[@]}"; do
for i in "${IGNORE[@]}"; do
[[ ${CHECK[c]} == "$i" ]] && unset -v 'CHECK[c]'
done
done
[[ ${#CHECK[@]} -eq 0 ]] && { echo 'no files to check'; exit 0; }

echo '---'
echo 'check:'
for c in "${CHECK[@]}"; do
echo " - ${c}"
done
echo

docker run -ti -v "$(pwd):$(pwd)" -w "$(pwd)" \
mivok/markdownlint:0.4.0 "${CHECK[@]}"

# vim: tabstop=2 shiftwidth=2 expandtab
26 changes: 26 additions & 0 deletions tests/shellcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

set -e
shopt -s globstar nullglob

CHECK=( **/*.sh bin/* )
IGNORE=( **/*.csh bin/flock-fd lsst_build/** )

for c in "${!CHECK[@]}"; do
for i in "${IGNORE[@]}"; do
[[ ${CHECK[c]} == "$i" ]] && unset -v 'CHECK[c]'
done
done
[[ ${#CHECK[@]} -eq 0 ]] && { echo 'no files to check'; exit 0; }

echo '---'
echo 'check:'
for c in "${CHECK[@]}"; do
echo " - ${c}"
done
echo

docker run -ti -v "$(pwd):$(pwd)" -w "$(pwd)" \
koalaman/shellcheck-alpine:v0.4.7 -x "${CHECK[@]}"

# vim: tabstop=2 shiftwidth=2 expandtab
34 changes: 34 additions & 0 deletions tests/yamllint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

set -e
shopt -s globstar nullglob

CHECK=( **/*.yaml **/*.yml **/*.eyaml .travis.yml )
EYAML=( **/*.eyaml )
IGNORE=()

# filter out plaintext versions of .eyaml files
for e in "${!EYAML[@]}"; do
uneyaml=${EYAML[e]/eyaml/yaml}
for c in "${!CHECK[@]}"; do
[[ ${CHECK[c]} == "$uneyaml" ]] && unset -v 'CHECK[c]'
done
done

for c in "${!CHECK[@]}"; do
for i in "${IGNORE[@]}"; do
[[ ${CHECK[c]} == "$i" ]] && unset -v 'CHECK[c]'
done
done
[[ ${#CHECK[@]} -eq 0 ]] && { echo 'no files to check'; exit 0; }

echo '---'
echo 'check:'
for c in "${CHECK[@]}"; do
echo " - ${c}"
done
echo

docker run -ti -v "$(pwd):/workdir" lsstsqre/yamllint:1.11.1 "${CHECK[@]}"

# vim: tabstop=2 shiftwidth=2 expandtab

0 comments on commit f00b527

Please sign in to comment.