Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added initial files for running build inside Docker.
- Loading branch information
Showing
13 changed files
with
308 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.git | ||
_build | ||
archlinux | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ tmp | |
/*.geany | ||
*.out | ||
/_build | ||
/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
FROM ubuntu:18.04 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
USER root | ||
ENV HOME /home/root | ||
|
||
# Install sudo. Not strictly required inside Docker, but it will allow Docker to run scripts that typically run outside Docker | ||
# which do use sudo. | ||
RUN apt update && apt -yq install sudo | ||
RUN sudo echo "hi" | ||
|
||
# Setup localization. | ||
ENV DEBIAN_FRONTEND noninteractive | ||
RUN apt update | ||
RUN apt install -y locales | ||
RUN rm -rf /var/lib/apt/lists/* && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 | ||
RUN apt update | ||
ENV LANG en_US.utf8 | ||
|
||
# Install dependencies | ||
RUN apt-get -yq update && apt-get install -y gnupg2 | ||
RUN apt-key update | ||
RUN apt-get -yq update | ||
RUN apt-get -yq install xvfb gnome-shell git make bc dbus procps | ||
|
||
# Install NodeJS from upstream, since the version that comes with the distro is ancient. | ||
# https://askubuntu.com/a/548776/13217 | ||
RUN apt-get -yq install curl | ||
RUN curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - | ||
RUN apt-get install -yq nodejs | ||
|
||
# Necessary on some versions of Ubuntu 14, which has a malformed npm/nodejs package. | ||
RUN bash -c "[ ! -f /usr/bin/node ] && ln -s /usr/bin/nodejs /usr/bin/node || true" | ||
RUN which nodejs | ||
RUN which node | ||
|
||
# Install NPM from upstream. | ||
RUN git clone git://github.com/npm/cli.git | ||
RUN cd cli/scripts; chmod +x install.sh; ./install.sh | ||
RUN npm install -g eslint | ||
|
||
# Install code. | ||
RUN mkdir -p /home/root/git/gnome-shell-system-monitor-applet | ||
COPY . /home/root/git/gnome-shell-system-monitor-applet | ||
WORKDIR /home/root/git/gnome-shell-system-monitor-applet | ||
|
||
# Run test wrapper. | ||
CMD ./docker_cmd_ubuntu1804.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
FROM ubuntu:20.04 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
USER root | ||
|
||
# Install sudo. Not strictly required inside Docker, but it will allow Docker to run scripts that typically run outside Docker | ||
# which do use sudo. | ||
RUN apt update && apt -yq install sudo | ||
RUN sudo echo "hi" | ||
|
||
# Setup localization. | ||
ENV DEBIAN_FRONTEND noninteractive | ||
RUN apt update | ||
RUN apt install -y locales | ||
RUN rm -rf /var/lib/apt/lists/* && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 | ||
RUN apt update | ||
ENV LANG en_US.utf8 | ||
|
||
# Install dependencies | ||
RUN apt-get -yq update && apt-get install -y gnupg2 | ||
RUN apt-key update | ||
RUN apt-get -yq update | ||
RUN apt-get -yq install xvfb gnome-shell git make bc dbus | ||
|
||
# Install NodeJS from upstream, since the version that comes with the distro is ancient. | ||
# https://askubuntu.com/a/548776/13217 | ||
RUN apt-get -yq install curl | ||
RUN curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - | ||
RUN apt-get install -yq nodejs | ||
|
||
# Necessary on some versions of Ubuntu 14, which has a malformed npm/nodejs package. | ||
RUN bash -c "[ ! -f /usr/bin/node ] && ln -s /usr/bin/nodejs /usr/bin/node || true" | ||
RUN which nodejs | ||
RUN which node | ||
|
||
# Install NPM from upstream. | ||
RUN git clone git://github.com/npm/cli.git | ||
RUN cd cli/scripts; chmod +x install.sh; ./install.sh | ||
RUN npm install -g eslint | ||
|
||
# Install code. | ||
RUN mkdir -p /home/root/git/gnome-shell-system-monitor-applet | ||
COPY . /home/root/git/gnome-shell-system-monitor-applet | ||
WORKDIR /home/root/git/gnome-shell-system-monitor-applet | ||
|
||
# Run test wrapper. | ||
CMD ./docker_cmd_ubuntu2004.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/bin/bash | ||
# Install eslint with: | ||
# sudo apt-get install npm && sudo npm install -g eslint | ||
set -e | ||
eslint system-monitor@paradoxxx.zero.gmail.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#https://docs.docker.com/compose/compose-file/#shm_size | ||
version: "3.5" | ||
services: | ||
|
||
test: | ||
build: | ||
context: . | ||
# Increase the size of shared memory. | ||
# The default shared memory is only 64mb, causing odd Selenium errors like: | ||
# selenium.common.exceptions.WebDriverException: Message: Failed to decode response from marionette | ||
shm_size: '1gb' | ||
dockerfile: Dockerfile.ubuntu1804 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#https://docs.docker.com/compose/compose-file/#shm_size | ||
version: "3.5" | ||
services: | ||
|
||
test: | ||
build: | ||
context: . | ||
# Increase the size of shared memory. | ||
# The default shared memory is only 64mb, causing odd Selenium errors like: | ||
# selenium.common.exceptions.WebDriverException: Message: Failed to decode response from marionette | ||
shm_size: '1gb' | ||
dockerfile: Dockerfile.ubuntu2004 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#https://docs.docker.com/compose/compose-file/#shm_size | ||
version: "3.5" | ||
services: | ||
test: | ||
build: | ||
context: . | ||
# Increase the size of shared memory. | ||
# The default shared memory is only 64mb, causing odd Selenium errors like: | ||
# selenium.common.exceptions.WebDriverException: Message: Failed to decode response from marionette | ||
shm_size: '1gb' | ||
dockerfile: Dockerfile.${DISTRO} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
# Called from the Dockerfile.* to execute our tests via the CMD. | ||
set -e | ||
|
||
echo "[$(date)] Launching Dbus." | ||
mkdir -p /var/run/dbus | ||
dbus-daemon --config-file=/usr/share/dbus-1/system.conf --print-address | ||
sleep 3 # give Dbus some time to start | ||
|
||
echo "[$(date)] Launching Xvfb." | ||
export DISPLAY=:99.0 | ||
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16 | ||
sleep 3 # give xvfb some time to start | ||
|
||
echo "[$(date)] Launching Gnome-Shell." | ||
sudo gnome-shell & | ||
sleep 3 # give gnome-shell some time to start | ||
echo "[$(date)] Confirming Gnome-Shell is running." | ||
pgrep gnome-shell | ||
|
||
echo "[$(date)] Showing Gnome-Shell log entries." | ||
sudo journalctl /usr/bin/gnome-shell || true | ||
echo "[$(date)] Rotating Gnome-Shell log entries." | ||
sudo journalctl --rotate || true | ||
echo "[$(date)] Clearing Gnome-Shell log entries." | ||
sudo journalctl --vacuum-time=1s || true | ||
|
||
echo "[$(date)] Show pre-extension Gnome-Shell performance." | ||
ps -C gnome-shell -o %cpu,%mem,cmd || true | ||
|
||
echo "[$(date)] Running JSLint check." | ||
#cd $TRAVIS_BUILD_DIR | ||
./checkjs.sh | ||
|
||
echo "[$(date)] Installing extension." | ||
sudo make install | ||
gnome-shell-extension-tool --enable-extension=system-monitor@paradoxxx.zero.gmail.com | ||
sleep 10 # Give extension time to run. | ||
|
||
echo "[$(date)] Showing post-extension Gnome-Shell performance." | ||
export MAX_CPU_PERCENT=20 | ||
export MAX_MEM_PERCENT=5 | ||
ps -C gnome-shell -o %cpu,%mem,cmd | ||
# Check CPU. On localhost with 2.80GHz x 4 takes ~3%, on Travis ~15%. | ||
bash -c '[[ $(bc <<< "$(ps -C gnome-shell -o %cpu|tail -1) < $MAX_CPU_PERCENT") -eq 1 ]]' | ||
# Check memory. On localhost with 32GB of memory, ~0.6%, on Travis ~3%. | ||
bash -c '[[ $(bc <<< "$(ps -C gnome-shell -o %mem|tail -1) < $MAX_MEM_PERCENT") -eq 1 ]]' | ||
|
||
echo "[$(date)] Confirming extension hasn't thrown any errors." | ||
# Note, finding no entries returns an error code of 1, which in our case means no error. | ||
sudo journalctl /usr/bin/gnome-shell | ||
sudo journalctl /usr/bin/gnome-shell|grep "\-\- No entries \-\-" | ||
sudo journalctl --since=$(date '+%Y-%m-%d') /usr/bin/gnome-shell|grep -i "Extension \"system-monitor@paradoxxx.zero.gmail.com\" had error" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
# Called from the Dockerfile.* to execute our tests via the CMD. | ||
set -e | ||
|
||
echo "[$(date)] Launching Dbus." | ||
mkdir -p /var/run/dbus | ||
dbus-daemon --config-file=/usr/share/dbus-1/system.conf --print-address | ||
sleep 3 # give Dbus some time to start | ||
|
||
echo "[$(date)] Launching Xvfb." | ||
export DISPLAY=:99.0 | ||
/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16 | ||
sleep 3 # give xvfb some time to start | ||
|
||
echo "[$(date)] Launching Gnome-Shell." | ||
sudo gnome-shell & | ||
sleep 3 # give gnome-shell some time to start | ||
|
||
echo "[$(date)] Clearing Gnome-Shell log entries." | ||
sudo journalctl /usr/bin/gnome-shell || true | ||
sudo journalctl --rotate | ||
sudo journalctl --vacuum-time=1s | ||
|
||
echo "[$(date)] Show pre-extension Gnome-Shell performance." | ||
ps -C gnome-shell -o %cpu,%mem,cmd | ||
|
||
echo "[$(date)] Running JSLint check." | ||
#cd $TRAVIS_BUILD_DIR | ||
./checkjs.sh | ||
|
||
echo "[$(date)] Installing extension." | ||
sudo make install | ||
gnome-shell-extension-tool --enable-extension=system-monitor@paradoxxx.zero.gmail.com | ||
sleep 10 # Give extension time to run. | ||
|
||
echo "[$(date)] Showing post-extension Gnome-Shell performance." | ||
export MAX_CPU_PERCENT=20 | ||
export MAX_MEM_PERCENT=5 | ||
ps -C gnome-shell -o %cpu,%mem,cmd | ||
# Check CPU. On localhost with 2.80GHz x 4 takes ~3%, on Travis ~15%. | ||
bash -c '[[ $(bc <<< "$(ps -C gnome-shell -o %cpu|tail -1) < $MAX_CPU_PERCENT") -eq 1 ]]' | ||
# Check memory. On localhost with 32GB of memory, ~0.6%, on Travis ~3%. | ||
bash -c '[[ $(bc <<< "$(ps -C gnome-shell -o %mem|tail -1) < $MAX_MEM_PERCENT") -eq 1 ]]' | ||
|
||
echo "[$(date)] Confirming extension hasn't thrown any errors." | ||
# Note, finding no entries returns an error code of 1, which in our case means no error. | ||
sudo journalctl /usr/bin/gnome-shell | ||
sudo journalctl /usr/bin/gnome-shell|grep "\-\- No entries \-\-" | ||
sudo journalctl --since=$(date '+%Y-%m-%d') /usr/bin/gnome-shell|grep -i "Extension \"system-monitor@paradoxxx.zero.gmail.com\" had error" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env bash | ||
# The top-level user script for executing tests from Docker. | ||
# The first argument should be a distro identifier. | ||
|
||
export DISTRO=${1:-ubuntu1804} | ||
|
||
echo "[$(date)] Running $DISTRO tests." | ||
|
||
COMPOSE_FILE_LOC="docker-compose.yml" | ||
|
||
# This must match the name in the docker-compose.*.yml file. | ||
TEST_CONTAINER_NAME="test" | ||
|
||
COMPOSE_PROJECT_NAME_ORIGINAL="test_${BUILD_TAG}" | ||
echo "[$(date)] COMPOSE_PROJECT_NAME_ORIGINAL=$COMPOSE_PROJECT_NAME_ORIGINAL" | ||
|
||
# Project name is sanitized by Compose, so we need to do the same thing. | ||
# See https://github.com/docker/compose/issues/2119. | ||
COMPOSE_PROJECT_NAME=$(echo $COMPOSE_PROJECT_NAME_ORIGINAL | awk '{print tolower($0)}' | sed 's/[^a-z0-9]*//g') | ||
echo "[$(date)] COMPOSE_PROJECT_NAME=$COMPOSE_PROJECT_NAME" | ||
TEST_CONTAINER_REF="${COMPOSE_PROJECT_NAME}_${TEST_CONTAINER_NAME}_1" | ||
echo "[$(date)] TEST_CONTAINER_REF=$TEST_CONTAINER_REF" | ||
|
||
# Record installed version of Docker and Compose with each build | ||
echo "[$(date)] Docker environment:" | ||
docker --version | ||
docker-compose --version | ||
|
||
function cleanup { | ||
echo "[$(date)] Shutting down..." | ||
docker-compose -f $COMPOSE_FILE_LOC -p $COMPOSE_PROJECT_NAME down --remove-orphans | ||
echo "[$(date)] Stopping..." | ||
docker ps -a --no-trunc | grep $COMPOSE_PROJECT_NAME | awk '{print $1}' | xargs --no-run-if-empty docker stop | ||
echo "[$(date)] Removing..." | ||
docker ps -a --no-trunc | grep $COMPOSE_PROJECT_NAME | awk '{print $1}' | xargs --no-run-if-empty docker rm | ||
echo "[$(date)] Delete old containers." | ||
docker system prune -a -f | ||
} | ||
|
||
function run_tests { | ||
echo "[$(date)] Creating containers..." | ||
docker-compose -f $COMPOSE_FILE_LOC -p $COMPOSE_PROJECT_NAME up --build --force-recreate --exit-code-from test | ||
ret_code=$? | ||
echo "[$(date)] Docker Compose exit code: $ret_code" | ||
|
||
# List images and containers related to this build | ||
docker images | grep $COMPOSE_PROJECT_NAME | awk '{print $0}' | ||
docker ps -a | grep $COMPOSE_PROJECT_NAME | awk '{print $0}' | ||
|
||
# Follow the container with tests... | ||
docker logs -f $TEST_CONTAINER_REF | ||
|
||
exit $ret_code | ||
} | ||
|
||
set -e | ||
cleanup # Initial cleanup. | ||
trap cleanup EXIT # Cleanup after tests finish running | ||
|
||
run_tests |
Oops, something went wrong.