Skip to content

Commit

Permalink
Merge branch 'master' into hotfix/#183
Browse files Browse the repository at this point in the history
  • Loading branch information
lherman-cs authored and Lukas Herman committed Sep 3, 2017
2 parents bdb93bb + 27eab4a commit 9adb1d2
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 55 deletions.
15 changes: 15 additions & 0 deletions .ci/check_maintainership.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# Do not use `set -x` here as then it displays the PYPIPW in logs
set -e

# Get environment variables, readily decrypted by rultor
source ../rultor_github_secrets.sh

# Make sure the user is a maintainer
response=$(curl "https://api.github.com/teams/1238757/memberships/${author}?access_token=${GITHUB_TOKEN}")
echo "$response"
if echo "$response" | grep -q "Not Found"; then
echo "@${author} is not in the maintainers group."
exit 1
fi
16 changes: 16 additions & 0 deletions .ci/rultor_github_secrets.sh.asc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-----BEGIN PGP MESSAGE-----

hQEMA5qETcGag5w6AQf/apsbE6KJcSn8JlJBc6mLdTdVdQcTaeQOTNDdrYUVXRlp
e/kDaOk+34+JyWJEKreIXXUNNEwmJ4qkDUCBBniiIhq1oT1Ch5125JdM8oKqnG/l
+2tquYrjTf5MueCKepd1VMYs7caw5o1hLyEROzPxoP+MDOwglKurOdAhAjZ8+Gt0
spRwp5+cIgRQTh8tnXpP8LiOdCiuPVicCrHcT5wFJfS1krk9lxFdzRFqn3GTosHo
23I2OoVVqLQB5ZdZe4MOR0IA3UZWwVHAz27PVrV4I2qVlJXdfkSkXSVxJRG8jtaK
rehbOaT304l9mqGYAKd/+nd1DtJTc0rfynCpPP8T/NLAbQEFT4Nafb2OZ/YIlulP
34QBkky62Z2kl8L9uZeygSgPcjt1G5aNMnNgVv71ObsjKFPF9sPDMwqyhJ7e2ZC0
0+7m6Ern+V9swEHW83cDVORRgbq2IuZt6a8MUfQafUp6wn56PuARdsbmEBgqgD/X
qq8qc5Wsw5VjIN9sHq7bqPtP51RwTLnp3MoaVV4MmfZh1MhE94zkHrQDGxSuwLJP
hi0uJPTPKWOD4s5edB3XQMSJIDUJnMTdDzTG9KnEV8CGlkMyEslFLBnlofsQP2sM
7SbGqG5q+8obt2T+S/sYhQAXAN4s9NM/l8yjI13XD1rcCN4bwx/O0TMOPtoYnnC9
L6EpSsQolNyCGg6uHNOlejopE2fxpvOn8XOPmxApUBXQINtmXNeRzJzv8pfoYr0=
=LwCm
-----END PGP MESSAGE-----
11 changes: 9 additions & 2 deletions .coafile
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
[shell]
files = hooks/*, tests/*.sh
bears = LineLengthBear, SpaceConsistencyBear, ShellCheckBear
shell = bash
max_line_length = 79
use_spaces = True

[commit]
bears = GitCommitBear
shortlog_trailing_period = False
shortlog_regex = ([^:]*|\S+: [A-Z0-9*].*)
shortlog_regex = ([^:]*|[^:]+[^ ]: [A-Z0-9*].*)

[yml]
bears = YAMLLintBear
files = *.yml, hooks/*.yml
files = *.yml, hooks/*.yml
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rultor_github_secrets.sh
6 changes: 5 additions & 1 deletion .rultor.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
merge:
fast-forward: only
script: echo "Nothing to do."
script:
- bash .ci/check_maintainership.sh

decrypt:
rultor_github_secrets.sh: "repo/.ci/rultor_github_secrets.sh.asc"
36 changes: 7 additions & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sudo: required
language: generic
language: go

services:
- docker
Expand All @@ -9,39 +9,17 @@ services:
env:
global:
- SOURCE_BRANCH=$TRAVIS_BRANCH
- IMAGE_NAME=coala-docker
- IMAGE_NAME=coala-docker:this

before_install:
- go get github.com/grammarly/rocker

install:
- hooks/build

script:
- docker images
- >
docker run -t -i --volume=$(pwd)/tests:/work coala-docker /bin/sh -c "
set -e -x;
/work/pytest.sh;
/work/vcs.sh;
/work/opensuse.sh;
"
# Verify MarkdownBear works outside of coala-bears directory.
# See https://github.com/coala/coala-bears/issues/1235
- >
docker run -t -i coala-docker /bin/sh -c "
cd /tmp;
echo foo > foo.md;
coala --non-interactive --no-config --bears MarkdownBear --files foo.md;
"
- /bin/sh -c "! docker run coala-docker"
- docker run --volume=$(pwd)/.ci/sample:/work --workdir=/work coala-docker
- ls -la ./.ci/sample/.coafile
- sudo chown $USER ./.ci/sample/.coafile
- echo -e
"[fail]\nbears = NoCommentsBear\nfile = **.py" >> ./.ci/sample/.coafile
- /bin/sh -c "
! docker run
--volume=$(pwd)/.ci/sample:/work
--volume=$(pwd)/.ci/bears:/additional_bears
--workdir=/work coala-docker
"
- hooks/test

notifications:
email: false
71 changes: 50 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,33 @@ RUN mkdir -p /root/.local/share/coala && \
RUN \
zypper addlock \
postfix \
'julia < 0.6' 'julia >= 0.7' julia-compat \
&& \
# Remove unnecessary repos to avoid refreshes
zypper removerepo 'NON-OSS' && \
# Package dependencies
time zypper --no-gpg-checks --non-interactive \
echo 'Running zypper install ...' && \
(time zypper -vv --no-gpg-checks --non-interactive \
# nodejs 7
--plus-repo http://download.opensuse.org/repositories/devel:languages:nodejs/openSUSE_Tumbleweed/ \
# science contains latest Julia
--plus-repo http://download.opensuse.org/repositories/science/openSUSE_Tumbleweed/ \
# luarocks
--plus-repo http://download.opensuse.org/repositories/devel:languages:lua/openSUSE_Factory/ \
# brotlipy
--plus-repo http://download.opensuse.org/repositories/devel:languages:python/openSUSE_Tumbleweed/ \
# ruby 2.2
--plus-repo http://download.opensuse.org/repositories/devel:languages:ruby/openSUSE_Tumbleweed/ \
# flawfinder
--plus-repo http://download.opensuse.org/repositories/home:illuusio/openSUSE_Tumbleweed/ \
install --replacefiles \
# astyle
--plus-repo http://download.opensuse.org/repositories/devel:tools/openSUSE_Tumbleweed/ \
# Python 3 packages
--plus-repo http://download.opensuse.org/repositories/devel:languages:python3/openSUSE_Tumbleweed/ \
# stable packages built for coala
--plus-repo http://download.opensuse.org/repositories/home:jayvdb:coala/openSUSE_Tumbleweed/ \
install --replacefiles --download-in-advance \
astyle \
bzr \
cppcheck \
curl \
Expand All @@ -40,7 +53,7 @@ RUN \
gcc-c++ \
gcc-fortran \
git \
go \
go1.7 \
mercurial \
hlint \
indent \
Expand All @@ -54,6 +67,7 @@ RUN \
libopenssl-devel \
# pcre needed by Julia runtime
libpcre2-8-0 \
libpython3_6m1_0 \
libxml2-devel \
# libxml2-tools provides xmllint
libxml2-tools \
Expand All @@ -64,9 +78,10 @@ RUN \
linux-glibc-devel \
liblua5_3-5 \
lua53 \
lua53-devel \
lua53-luarocks \
luacheck \
m4 \
nltk-data-averaged_perceptron_tagger \
nltk-data-punkt \
nodejs7 \
npm7 \
# patch is used by Ruby gem pg_query
Expand All @@ -84,19 +99,26 @@ RUN \
# Used by bzr, mecurial, hgext, and flawfinder
python \
python3 \
# Needed for HTTpolice
python3-brotlipy \
# Needed for proselint
python3-dbm \
python3-nltk \
python3-pip \
python3-devel \
R-base \
ruby \
ruby-devel \
ruby2.2 \
ruby2.2-devel \
ruby2.2-rubygem-bundler \
ShellCheck \
subversion \
tar \
texlive-chktex \
unzip && \
unzip \
> /tmp/zypper.out \
|| (cat /tmp/zypper.out && false)) \
&& \
grep -E '(new packages to install|^Retrieving: )' /tmp/zypper.out && \
time rpm -e -f --nodeps -v \
aaa_base \
cron \
Expand Down Expand Up @@ -131,7 +153,11 @@ RUN \
perl-X11-Protocol \
php7-zlib \
python-curses \
python2-packaging \
python2-Pygments \
python2-pyparsing \
python-rpm-macros \
python2-setuptools \
python-xml \
R-core-doc \
rsync \
Expand All @@ -149,6 +175,9 @@ RUN \
xorg-x11-fonts \
xorg-x11-fonts-core \
&& \
# Disable nltk downloader
printf 'def download(*args): pass\ndownload_shell = download\n' \
> /usr/lib/python3.6/site-packages/nltk/downloader.py && \
rm -rf \
/usr/lib64/python2.7/doctest.py \
/usr/lib64/python2.7/ensurepip/ \
Expand Down Expand Up @@ -192,6 +221,8 @@ RUN \
time zypper clean -a && \
find /tmp -mindepth 1 -prune -exec rm -rf '{}' '+'

# rocker TAG {{ .image }}_suse

# Coala setup and python deps
RUN cd / && \
git clone --depth 1 --branch=$branch https://github.com/coala/coala.git && \
Expand All @@ -203,8 +234,6 @@ RUN cd / && \
-e /coala-quickstart \
-r /coala/test-requirements.txt && \
cd coala-bears && \
# NLTK data
time python3 -m nltk.downloader punkt maxent_treebank_pos_tagger averaged_perceptron_tagger && \
# Remove Ruby directive from Gemfile as this image has 2.2.5
sed -i '/^ruby/d' Gemfile && \
# Ruby dependencies
Expand Down Expand Up @@ -267,17 +296,15 @@ RUN source /etc/profile.d/go.sh && time go get -u \

# Julia setup
RUN time julia -e 'Pkg.add("Lint")' && \
rm -rf \
~/.julia/.cache \
~/.julia/v0.5/.cache \
~/.julia/v0.5/METADATA \
~/.julia/v0.5/*/.git \
~/.julia/v0.5/*/test \
~/.julia/v0.5/*/docs && \
find /tmp -mindepth 1 -prune -exec rm -rf '{}' '+'

# Lua commands
RUN time luarocks install luacheck && \
rm -rf ~/.julia/.cache && \
(cd ~/.julia/v0.* && \
rm -rf \
.cache \
METADATA \
.git \
*/test \
*/docs \
) && \
find /tmp -mindepth 1 -prune -exec rm -rf '{}' '+'

# PMD setup
Expand Down Expand Up @@ -336,3 +363,5 @@ RUN mkdir -p /root/.local/share/coala-bears/ScalaLintBear && \
# Entrypoint script
ADD docker-coala.sh /usr/local/bin/
CMD ["/usr/local/bin/docker-coala.sh"]

# rocker TAG {{ .image }}
32 changes: 30 additions & 2 deletions hooks/build
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
#!/usr/bin/env bash

set -e -x

if [[ "${IMAGE_NAME/:/}" == "${IMAGE_NAME}" ]]; then
# DockerCloud uses :this for pull requests
IMAGE_NAME="${IMAGE_NAME}:this"
fi

ROCKER="$(which rocker | true)"

if [[ -z "$TOOL" ]]; then
if [[ -n "$ROCKER" ]]; then
TOOL="$ROCKER"
else
TOOL=docker
fi
fi

if [[ "${TOOL%docker}" != "$TOOL" ]]; then
TOOL_ARGS="-t $IMAGE_NAME"
elif [[ "${TOOL%rocker}" != "$TOOL" ]]; then
TOOL_ARGS="--var image=$IMAGE_NAME"
sed -i 's/^# rocker \([A-Z]*\) /\1 /' Dockerfile
fi

COALA_BRANCH=$(python guess_branch.py "$SOURCE_BRANCH")

echo Building coala branch $COALA_BRANCH for docker branch $SOURCE_BRANCH
echo "Building coala branch $COALA_BRANCH for docker branch $SOURCE_BRANCH"
echo "as image ${IMAGE_NAME}, using ${TOOL} on $(uname -a)."

docker build -f Dockerfile --build-arg=branch=$COALA_BRANCH -t $IMAGE_NAME .
$TOOL build \
-f Dockerfile \
--build-arg=branch="$COALA_BRANCH" \
$TOOL_ARGS .
47 changes: 47 additions & 0 deletions hooks/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash

set -e -x

# Docker Cloud doesnt set USER
export USER=${USER:-root}

# Run tests
docker run -i --volume="$(pwd)/tests:/work" "$IMAGE_NAME" /bin/sh -c "
set -e -x;
/work/pytest.sh;
/work/vcs.sh;
/work/opensuse.sh;
"

# Verify MarkdownBear works outside of coala-bears directory.
# See https://github.com/coala/coala-bears/issues/1235
docker run -i "$IMAGE_NAME" /bin/sh -c "
set -e -x;
cd /tmp;
echo foo > foo.md;
coala --non-interactive --no-config --bears MarkdownBear --files foo.md;
"

# Verify that image fails in neither a command or work directory are given.
! docker run "$IMAGE_NAME"

# Verify that a missing .coafile in the work directory causes coala-quickstart
# to be run, creating a .coafile that is visible outside of the container.
docker run --volume="$(pwd)/.ci/sample:/work" --workdir=/work "$IMAGE_NAME"
ls -la ./.ci/sample/.coafile

# Verify a .coafile present causes coala-ci to run, with a custom bears loaded,
# and a non-zero exit status occurs when a bear emits a result.
sudo chown "$USER" ./.ci/sample/.coafile
echo -e "[fail]\nbears = NoCommentsBear\nfile = **.py" >> ./.ci/sample/.coafile
! docker run --volume="$(pwd)/.ci/sample:/work" \
--volume="$(pwd)/.ci/bears:/additional_bears" \
--workdir=/work "$IMAGE_NAME"

# Run coala
# https://github.com/coala/coala-bears/issues/1037
if [[ "$TRAVIS" == "true" && "$TRAVIS_PULL_REQUEST" != "false" ]]; then
sed -i.bak '/bears = GitCommitBear/d' .coafile
fi

docker run --volume="$(pwd):/work" --workdir=/work "$IMAGE_NAME"

0 comments on commit 9adb1d2

Please sign in to comment.