From 74cc2eee813430ff0e521f70f31e710107e17ea1 Mon Sep 17 00:00:00 2001 From: t1m0t Date: Thu, 3 Feb 2022 09:26:01 +0100 Subject: [PATCH] adding docker folder --- docker/Dockerfile_pre_test | 9 +++++++++ docker/Dockerfile_test | 8 ++++++++ docker/README.md | 27 +++++++++++++++++++++++++++ docker/run_local_tests.sh | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 docker/Dockerfile_pre_test create mode 100644 docker/Dockerfile_test create mode 100644 docker/README.md create mode 100644 docker/run_local_tests.sh diff --git a/docker/Dockerfile_pre_test b/docker/Dockerfile_pre_test new file mode 100644 index 000000000..6e0af4987 --- /dev/null +++ b/docker/Dockerfile_pre_test @@ -0,0 +1,9 @@ +FROM rust:1.58-buster + +RUN apt update +RUN apt install -y libglib2.0-dev libgtk-3-dev libsoup2.4-dev libappindicator3-dev libwebkit2gtk-4.0-dev firefox-esr + +RUN cargo install cargo-make --debug +RUN cargo install cargo-cache && cargo cache -a + +CMD ["echo","\"base image built\""] diff --git a/docker/Dockerfile_test b/docker/Dockerfile_test new file mode 100644 index 000000000..f6265c2bb --- /dev/null +++ b/docker/Dockerfile_test @@ -0,0 +1,8 @@ +FROM dioxus-base-test-image + +RUN mkdir run_test +COPY tmp /run_test +WORKDIR /run_test +RUN cargo make tests + +CMD ["exit"] diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000..57578f405 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,27 @@ +# Why this? + +This part is used to test whole package before pushing it + +# How to use it? + +Just run in the folder: +`bash run_local_tests.sh`. If nothing fails, then you can push your code to the repo. +or run: +`bash run_local_tests.sh --with-full-docker-cleanup` +for cleaning up images as well + +# How is it composed of? + + 1. `Dockerfile_pre_test` will build the base image for the tests to be run into + 2. `Dockerfile_test` will run the actual tests based on 1. + 3. `run_local_tests.sh` to wrap this up + +# Warning + +The task requires some amount of CPU work and disk space (5GB per tests). Some clean up is included in the script. + +# Requirements + + * [docker](https://docs.docker.com/engine/install/) + * bash + * rsync \ No newline at end of file diff --git a/docker/run_local_tests.sh b/docker/run_local_tests.sh new file mode 100644 index 000000000..0d6c1fb8b --- /dev/null +++ b/docker/run_local_tests.sh @@ -0,0 +1,36 @@ +set -eux + +echo "Test script started" + +function run_script { + if [[ -d tmp ]] + then + rm -rf tmp + mkdir tmp + else + mkdir tmp + fi + + # copy files first + rsync -a --progress ../ tmp --exclude target --exclude docker + + # build base image + docker build -f Dockerfile_pre_test -t dioxus-base-test-image . + # run test + docker build -f Dockerfile_test -t dioxus-test-image . + + # clean up + rm -rf tmp + if [ $1 = "--with-full-docker-cleanup" ] + then + docker image rm dioxus-base-test-image + docker image rm dioxus-test-image + docker system prune -a --force + fi +} + +run_script || echo "Error occured.. cleaning a bit." && + docker system prune -a --force && \ + rm -rf tmp; + +echo "Script finished to execute"