Skip to content
This repository was archived by the owner on Oct 14, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 2 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,11 @@ services:
- docker

env:
- VERSION=0.8.0
- VERSION=0.8.1
- VERSION=0.8.2
- VERSION=0.8.3
- VERSION=0.8.4
- VERSION=0.8.5
- VERSION=0.8.6
- VERSION=0.9.0
- VERSION=0.9.1
- VERSION=0.9.2
- VERSION=0.9.3
- VERSION=0.9.4
- VERSION=1.0.0
- VERSION=edge
matrix:
exclude:
- evn: VERSION=0.8.0 TRAVIS_EVENT_TYPE=cron
- evn: VERSION=0.8.1 TRAVIS_EVENT_TYPE=cron
- evn: VERSION=0.8.2 TRAVIS_EVENT_TYPE=cron
- evn: VERSION=0.8.3 TRAVIS_EVENT_TYPE=cron
- evn: VERSION=0.8.4 TRAVIS_EVENT_TYPE=cron
- evn: VERSION=0.8.5 TRAVIS_EVENT_TYPE=cron
- evn: VERSION=0.8.6 TRAVIS_EVENT_TYPE=cron
- evn: VERSION=0.9.0 TRAVIS_EVENT_TYPE=cron
- evn: VERSION=0.9.1 TRAVIS_EVENT_TYPE=cron
- evn: VERSION=0.9.2 TRAVIS_EVENT_TYPE=cron
- evn: VERSION=0.9.3 TRAVIS_EVENT_TYPE=cron
- evn: VERSION=0.9.4 TRAVIS_EVENT_TYPE=cron
- evn: VERSION=1.0.0 TRAVIS_EVENT_TYPE=cron
allow_failures:
- env: VERSION=edge

Expand Down
10 changes: 2 additions & 8 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,15 @@
build() {
declare build_files="${*:-versions/**/options}"

[[ "$BUILDER_IMAGE" ]] || {
BUILDER_IMAGE="phan-builder"
docker build -t "$BUILDER_IMAGE" builder
}

for file in $build_files; do
(
source "$file"
local version_dir
version_dir="$(dirname "$file")"
: "${TAGS:?}" "${BUILD_OPTIONS:?}" "${RELEASE:?}"
docker run -e "TRACE=$TRACE" --rm "$BUILDER_IMAGE" "${BUILD_OPTIONS[@]}" \
> "$version_dir/rootfs.tar.gz"

for tag in "${TAGS[@]}"; do
docker build -t "$tag" "$version_dir"
docker build ${BUILD_OPTIONS[@]} -t "$tag" "$version_dir"
done
)
done
Expand Down Expand Up @@ -62,6 +55,7 @@ new_version() {
sed "s:{{.VERSION}}:${version}:g;s:{{.AST}}:${ast}:g"<"$file">"versions/${version}/$(basename "$file")"
)
done
chmod +x "versions/${version}/docker-entrypoint.sh"

sed "s:{{.VERSION}}:${version}:g"<"templates/test/test_cloudflare_phan.bats">"test/test_cloudflare_phan-${version}.bats"
}
Expand Down
6 changes: 0 additions & 6 deletions builder/Dockerfile

This file was deleted.

16 changes: 0 additions & 16 deletions builder/README.md

This file was deleted.

93 changes: 0 additions & 93 deletions builder/scripts/mkimage-phan.bash

This file was deleted.

4 changes: 2 additions & 2 deletions templates/test/test_cloudflare_phan.bats
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ setup() {
[ $status -eq 1 ]

[ ${#lines[@]} -eq 2 ]
[ "${lines[0]}" = "./undefined_class.php:3 PhanUndeclaredClassMethod Call to method __construct from undeclared class \Stub" ]
[ "${lines[1]}" = "./undefined_class.php:4 PhanUndeclaredClassConstant Reference to constant TYPE_STRING from undeclared class \Stub" ]
[ "${lines[0]}" = "undefined_class.php:3 PhanUndeclaredClassMethod Call to method __construct from undeclared class \Stub" ]
[ "${lines[1]}" = "undefined_class.php:4 PhanUndeclaredClassConstant Reference to constant TYPE_STRING from undeclared class \Stub" ]
}

@test "checkstyle output format is available" {
Expand Down
81 changes: 79 additions & 2 deletions templates/versions/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,80 @@
FROM alpine:3.3
ADD rootfs.tar.gz /
ARG ALPINE_VERSION=3.8
ARG APK_MIRROR="http://nl.alpinelinux.org/alpine"
ARG AST_VERSION=0.1.5
ARG PHAN_RELEASE="edge"

# Baseline
# ==========
FROM alpine:$ALPINE_VERSION AS base

# configure apk mirror
RUN echo "$APK_MIRROR/edge/main" >> "/etc/apk/repositories" \
&& echo "$APK_MIRROR/edge/community" >> "/etc/apk/repositories"

# install runtime dependencies
RUN apk --no-cache add \
php7 \
php7-dom \
php7-json \
php7-mbstring \
php7-pcntl \
php7-sqlite3 \
php7-tokenizer \
tini

# Builder
# ==========
FROM base AS builder

ARG AST_VERSION
ARG PHAN_RELEASE

# install build dependencies
RUN apk --no-cache add git build-base autoconf curl php7-dev php7-openssl php7-phar

COPY --from=composer:1.7 /usr/bin/composer /usr/local/bin/composer

# install php-ast
RUN set -xe; \
\
mkdir -p /src; \
cd /src; \
\
git clone -b "v${AST_VERSION}" --single-branch --depth 1 https://github.com/nikic/php-ast.git; \
\
cd php-ast; \
phpize7; \
./configure --with-php-config=php-config7; \
make install; \
echo "extension=ast.so" >> /etc/php7/php.ini

# install phan
RUN set -xe; \
\
mkdir -p /src; \
cd /src; \
\
if [[ "$PHAN_RELEASE" == "edge" ]]; then \
git clone --single-branch --depth 1 https://github.com/phan/phan.git; \
else \
git clone -b $PHAN_RELEASE --single-branch --depth 1 https://github.com/phan/phan.git; \
fi; \
\
cd phan; \
/usr/local/bin/composer --prefer-dist --no-dev --no-interaction install; \
rm -rf .git

# Runtime
# ==========
FROM base AS runtime

COPY --from=builder /src/phan /opt/phan
COPY --from=builder /usr/lib/php7/modules/ast.so /usr/lib/php7/modules/ast.so

RUN echo "extension=ast.so" >> /etc/php7/php.ini

COPY ./docker-entrypoint.sh /

VOLUME /mnt/src

ENTRYPOINT ["/sbin/tini", "-g", "--", "/docker-entrypoint.sh"]
2 changes: 1 addition & 1 deletion templates/versions/options
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export RELEASE="{{.VERSION}}"
export MIRROR="http://mirror.sfo12.us.leaseweb.net/alpine"
export AST="{{.AST}}"
export BUILD_OPTIONS=(-s -r $RELEASE -m $MIRROR -a $AST)
export BUILD_OPTIONS=(--build-arg APK_MIRROR=$MIRROR --build-arg AST_VERSION=$AST --build-arg PHAN_RELEASE=$RELEASE)
export TAGS=(cloudflare/phan:{{.VERSION}})
36 changes: 36 additions & 0 deletions test/test_cloudflare_phan-1.0.0.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
setup() {
VERSION=1.0.0
docker history "cloudflare/phan:${VERSION}" >/dev/null 2>&1
}

@test "pass arguments to phan" {
run docker run -v $PWD/test/fixtures/pass:/mnt/src "cloudflare/phan:${VERSION}" -h
[ $status -eq 0 ]
[ "${lines[0]}" = "Usage: /opt/phan/phan [options] [files...]" ]
}

@test "outputs zero lines if source has no issues" {
run docker run -v $PWD/test/fixtures/pass:/mnt/src "cloudflare/phan:${VERSION}" \
-l .
[ $status -eq 0 ]
[ ${#lines[@]} -eq 0 ]
}

@test "outputs lines if source has issues" {
run docker run -v $PWD/test/fixtures/fail:/mnt/src "cloudflare/phan:${VERSION}" \
-l .

# even if there's failures, phan reports 1
[ $status -eq 1 ]

[ ${#lines[@]} -eq 2 ]
[ "${lines[0]}" = "undefined_class.php:3 PhanUndeclaredClassMethod Call to method __construct from undeclared class \Stub" ]
[ "${lines[1]}" = "undefined_class.php:4 PhanUndeclaredClassConstant Reference to constant TYPE_STRING from undeclared class \Stub" ]
}

@test "checkstyle output format is available" {
run docker run -v $PWD/test/fixtures/pass:/mnt/src "cloudflare/phan:${VERSION}" \
--output-mode checkstyle -l .
[ $status -eq 0 ]
[ ${#lines[@]} -eq 2 ]
}
4 changes: 2 additions & 2 deletions test/test_cloudflare_phan-edge.bats
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ setup() {
[ $status -eq 1 ]

[ ${#lines[@]} -eq 2 ]
[ "${lines[0]}" = "./undefined_class.php:3 PhanUndeclaredClassMethod Call to method __construct from undeclared class \Stub" ]
[ "${lines[1]}" = "./undefined_class.php:4 PhanUndeclaredClassConstant Reference to constant TYPE_STRING from undeclared class \Stub" ]
[ "${lines[0]}" = "undefined_class.php:3 PhanUndeclaredClassMethod Call to method __construct from undeclared class \Stub" ]
[ "${lines[1]}" = "undefined_class.php:4 PhanUndeclaredClassConstant Reference to constant TYPE_STRING from undeclared class \Stub" ]
}

@test "checkstyle output format is available" {
Expand Down
Loading