Skip to content
This repository has been archived by the owner on Apr 12, 2018. It is now read-only.

Commit

Permalink
Added test script
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasWinkelmann committed Mar 8, 2017
1 parent e19791b commit b64ca3d
Show file tree
Hide file tree
Showing 8 changed files with 639 additions and 11 deletions.
18 changes: 11 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ FROM mhart/alpine-node:latest

LABEL description "Run Google Chrome's Lighthouse Audit in the background"

LABEL version "1.0.1"
LABEL version="1.0.3"

LABEL author "Matthias Winkelmann <[email protected]>"
LABEL org.label-schema.vcs-url "https://github.com/MatthiasWinkelmann/lighthouse-chromium-alpine-docker"
LABEL org.label-schema.uri "https://matthi.coffee"
LABEL org.label-schema.usage "/README.md"
LABEL org.label-schema.schema-version "1.0"
LABEL author="Matthias Winkelmann <[email protected]>"
LABEL coffee.matthi.vcs-url="https://github.com/MatthiasWinkelmann/lighthouse-chromium-alpine-docker"
LABEL coffee.matthi.uri="https://matthi.coffee"
LABEL coffee.matthi.usage="/README.md"

WORKDIR /lighthouse

Expand All @@ -23,6 +22,7 @@ RUN echo "http://dl-2.alpinelinux.org/alpine/edge/main" > /etc/apk/repositories
#-----------------
RUN apk -U --no-cache upgrade && \
apk --no-cache add xvfb\
openrc\
dbus-x11\
libx11\
xorg-server\
Expand All @@ -46,6 +46,7 @@ ENV GEOMETRY "$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"
RUN echo $TZ > /etc/timezone

ADD lighthouse-chromium-xvfb.sh .
ADD test.sh .
RUN npm --global install yarn && yarn global add lighthouse
RUN mkdir output

Expand All @@ -62,5 +63,8 @@ RUN rm -rf /var/lib/apt/lists/* \
/usr/lib/node_modules/npm/html \
/usr/lib/node_modules/npm/scripts


# Alpine's grep is a BusyBox binary which doesn't provide
# the -R (recursive, following symlinks) switch.
#ADD grep ./grep
# RUN alias grep=/lighthouse/grep
ENTRYPOINT ["/lighthouse/lighthouse-chromium-xvfb.sh"]
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ Processes within the container cannot easily access the host's file system. You
```shell
run -v ./output/:/lighthouse/output/ lighthouse-chromium-alpine-docker --output-path=/lighthouse/output/results.html --save-assets --save-artifacts --output=html https://google.com
```

Run the tesT:

```shell
docker run -it --rm --entrypoint=sh lighthouse test.sh
```
1 change: 1 addition & 0 deletions grep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
eval $(echo "/bin/grep $@" | sed -e "s/\-ER /\-Er /")
14 changes: 10 additions & 4 deletions lighthouse-chromium-xvfb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,23 @@ XVFB_WHD=${XVFB_WHD:-1280x720x16}

export DISPLAY=:99


# Start Xvfb
Xvfb :99 -ac -screen 0 $XVFB_WHD -nolisten tcp &
dbus-run-session -- Xvfb :99 -ac -screen 0 $XVFB_WHD -nolisten tcp &

xvfb=$!

while [ 1 -gt $xvfb ]; do echo "waiting for Xvfb to start: $xvfb"; sleep 1; done

echo "xvfb started"


/usr/bin/chromium-browser --no-sandbox --user-data-dir=$TMP_PROFILE_DIR --start-maximized --no-first-run --remote-debugging-port=9222 "about:blank" &
dbus-run-session -- /usr/bin/chromium-browser --no-sandbox --user-data-dir=$TMP_PROFILE_DIR --start-maximized --no-first-run --remote-debugging-port=9222 "about:blank" &

chromium=$!

echo $@
lighthouse $@
while [ 1 -gt $chromium ]; do echo "waiting for chromium to start"; sleep 1; done

echo "chromium started"

lighthouse --port=9222 --disable-webgl --skip-autolaunch --disable-cpu-throttling=true $@
3 changes: 3 additions & 0 deletions lighthouse.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sut:
build: .
command: /lighthouse/test.sh
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"lighthouse": "^1.6.0"
}
}
4 changes: 4 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

/bin/sh -c "./lighthouse-chromium-xvfb.sh --output-path=/tmp/test-report.html https://matthi.coffee"
grep -q "Best Practices" /tmp/test-report*
Loading

0 comments on commit b64ca3d

Please sign in to comment.