diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..92a3d22d --- /dev/null +++ b/docker/Dockerfile @@ -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 \ No newline at end of file diff --git a/docker/README.md b/docker/README.md new file mode 100755 index 00000000..18d89839 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,5 @@ +To build the docker image used for creating goldens, use: + +```docker build --build-arg flutter_version= -t docker_tests docker/``` + +Where **flutter-version** is obtained using `flutter --version` \ No newline at end of file diff --git a/docker/docker_test.sh b/docker/docker_test.sh new file mode 100755 index 00000000..1b6fddda --- /dev/null +++ b/docker/docker_test.sh @@ -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 \ No newline at end of file diff --git a/update_goldens.sh b/update_goldens.sh new file mode 100755 index 00000000..80989a53 --- /dev/null +++ b/update_goldens.sh @@ -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" \ No newline at end of file