From 7fc67804a82601ec253e8e7f73e6714a5700b579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20=C5=A0trauch?= Date: Fri, 19 Nov 2021 23:52:57 +0100 Subject: [PATCH] Automatic testing script --- .drone.yml | 12 +++++++++++- Makefile | 2 +- tests2.fish | 22 ++++++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 tests2.fish diff --git a/.drone.yml b/.drone.yml index bb0a1df..dc2e767 100644 --- a/.drone.yml +++ b/.drone.yml @@ -38,4 +38,14 @@ steps: privileged: true commands: - echo "$password" | podman login -u $username --password-stdin $repo - - make DOCKER=podman build + - make VERSION=test DOCKER=podman build +- name: test image + image: harbor.hq.rosti.cz/library/builder:35 + environment: + username: robot$rosti+rosti + password: + from_secret: repo_password + repo: harbor.hq.rosti.cz + privileged: true + commands: + - make DOCKER=podman VERSION=test test diff --git a/Makefile b/Makefile index dcf017b..4b4c305 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ build: $(DOCKER) build -t ${REPO}:dev . test: - DOCKER=$(DOCKER) ./tests.sh + DOCKER=$(DOCKER) ./tests2.sh squashed: $(DOCKER) pull debian:buster diff --git a/tests2.fish b/tests2.fish new file mode 100644 index 0000000..99c9161 --- /dev/null +++ b/tests2.fish @@ -0,0 +1,22 @@ +#!/usr/bin/fish + +if test -z "$DOCKER" + set DOCKER docker +end + +set CONTAINER_NAME dev_test + +for line in (cat Dockerfile | grep "RUN build_" | sed "s/RUN build_//" | sed "s/\.sh//" | sed "s/php8/php/") + set tech (string split " " $line)[1] + set tech_version (string split " " $line)[2] + + echo "Testing $tech $tech_version" + + $DOCKER run -d --rm --name $CONTAINER_NAME harbor.hq.rosti.cz/rosti/runtime:test > /dev/null; or exit 1 + + $DOCKER exec -e TESTMODE=1 -e MENUITEM=tech -e TECH=$tech-$tech_version $CONTAINER_NAME su app -c rosti > /dev/null; or exit 1 + sleep 3 + $DOCKER exec $CONTAINER_NAME curl --head http://localhost:8000 | grep "HTTP/1.1 200"; or exit 2 + + $DOCKER stop $CONTAINER_NAME; or exit 1 +end