FreedomBox/.ci/functional-tests.yml
James Valleroy 48ff4dd441
ci: Force pip install for functional tests
See 550f9192ae4e5c4dd486ba08738ecee322929fce.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
[sunil: Rely fully on running the install.sh script remove the pip3 rerun]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2023-04-05 08:50:10 -04:00

61 lines
2.4 KiB
YAML

---
# SPDX-License-Identifier: AGPL-3.0-or-later
.app-server:
stage: functional-tests
dependencies: []
except:
- $GITLAB_USER_LOGIN == "weblate"
script:
- BUILD_JOB_ID=$(curl -s "https://salsa.debian.org/api/v4/projects/$CI_PROJECT_ID/pipelines/$CI_PIPELINE_ID/jobs?scope[]=success" | jq -r '.[] | select(.name==env.BUILD_JOB_NAME) | .id')
- export AWS_DEFAULT_REGION=us-east-1
- |
aws lambda invoke --function-name launch_app_server --payload '{"launch_template_name": "'"$LAUNCH_TEMPLATE_NAME"'", "instance_name": "'"$INSTANCE_NAME"'", "ci_project_id": "'"$CI_PROJECT_ID"'", "build_job_id": "'"$BUILD_JOB_ID"'"}' response.json
- echo "APP_SERVER_IP=$(jq -r '.app_server_ip' response.json)" >> app-servers.env
- echo "INSTANCE_ID=$(jq -r '.instance_id' response.json)" >> app-servers.env
tags:
- functional-tests
artifacts:
reports:
dotenv: app-servers.env
.run-functional-tests:
stage: functional-tests
timeout: 3h
# Need to find a way of running the cleanup step even on failure
allow_failure: true
when: delayed
# Wait for the app-server to come up. Saves time for the CI runners.
start_in: 3 minutes
before_script:
- apt-get update
- apt-get install -y sudo curl wget
- ./plinth/tests/functional/install.sh
- adduser tester --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password && echo "tester:password" | chpasswd
script:
- cp -r . /home/tester/freedombox && chown -R tester:tester /home/tester/freedombox
- |
sudo FREEDOMBOX_URL="https://$APP_SERVER_IP" -u tester bash -c \
'cd /home/tester/freedombox && py.test-3 -v --durations=10 --include-functional --splinter-headless --template=html1/index.html --report=functional-tests.html'
after_script:
- echo "INSTANCE_ID=$INSTANCE_ID" >> app-servers.env
- cp /home/tester/freedombox/functional-tests.html .
- cp -r /home/tester/freedombox/screenshots/ .
artifacts:
when: always
reports:
dotenv: app-servers.env
paths:
- functional-tests.html
- screenshots/
# Does not run if the previous job times out or is cancelled
.terminate-app-server:
stage: functional-tests
script:
- export AWS_DEFAULT_REGION=us-east-1
- |
aws lambda invoke --function-name terminate_app_server --payload '{"instance_id": "'"$INSTANCE_ID"'"}' response.json
tags:
- functional-tests