Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run tests in Docker container / generate goldens #558

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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
15 changes: 15 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM ubuntu:20.04

ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Paris
RUN apt update && apt install -y curl git unzip xz-utils zip libglu1-mesa openjdk-8-jdk wget

RUN useradd -ms /bin/bash developer
USER developer
WORKDIR /home/developer

ARG flutter_version
RUN git clone https://github.com/flutter/flutter.git -b ${flutter_version}
ENV PATH "$PATH:/home/developer/flutter/bin"

RUN flutter doctor
5 changes: 5 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
To build the docker image used for creating goldens, use:

```docker build --build-arg flutter_version=<flutter-version> -t docker_tests docker/```

Where **flutter-version** is obtained using `flutter --version`
26 changes: 26 additions & 0 deletions docker/docker_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
packagePath=${PACKAGE_PATH:-}
testPath=${TEST_PATH:-}
updateGoldens=${UPDATE_GOLDENS:-}
coverage=${COVERAGE:-}

while [ $# -gt 0 ]; do
if [ "$1" == "--update-goldens" ]; then
declare= updateGoldens="--update-goldens"
shift
elif [ "$1" == "--coverage" ]; then
declare= coverage="--coverage"
shift
elif [[ $1 == *"--"* ]]; then
param="${1/--/}"
declare $param="$2"
shift
shift
else
shift
fi
done

cd $packagePath
flutter test $testPath $updateGoldens $coverage --no-pub --test-randomize-ordering-seed random
exit
7 changes: 7 additions & 0 deletions update_goldens.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
project_dir=$(git rev-parse --show-toplevel)

flutter_dir=$(which flutter | rev | cut -c12- | rev)

flutter_cache=~/.pub-cache/hosted/pub.dev/

docker run --rm -ti -v $project_dir:/project -v $flutter_dir:$flutter_dir -v $flutter_cache:$flutter_cache -e PACKAGE_PATH="/project/" docker_tests /bin/sh -c "/project/docker/docker_test.sh --update-goldens"
Loading