diff --git a/.ci/functional-tests.yml b/.ci/functional-tests.yml index 1c479918b..706a8c5d7 100644 --- a/.ci/functional-tests.yml +++ b/.ci/functional-tests.yml @@ -2,15 +2,18 @@ # SPDX-License-Identifier: AGPL-3.0-or-later .app-server: - needs: - - job: build + stage: functional-tests + dependencies: [] except: - - '$CI_COMMIT_TITLE =~ /^Weblate.*/' + - $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" | jq -r '.[] | select(.name=="build") | .id') + - 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 - LAUNCH_TEMPLATE_ID=$(aws ec2 describe-launch-templates --launch-template-names $LAUNCH_TEMPLATE_NAME | jq -r ".LaunchTemplates[0].LaunchTemplateId") - - INSTANCE_ID=$(aws ec2 run-instances --launch-template LaunchTemplateId="$LAUNCH_TEMPLATE_ID" --associate-public-ip-address --tag-specifications "ResourceType=instance, Tags=[{Key=salsa:project-id,Value=$CI_PROJECT_ID},{Key=salsa:build-job-id,Value=$BUILD_JOB_ID},{Key=Name,Value=$INSTANCE_NAME}]" | jq -r ".Instances[0].InstanceId") + - | + INSTANCE_ID=$(aws ec2 run-instances --launch-template LaunchTemplateId="$LAUNCH_TEMPLATE_ID" --associate-public-ip-address \ + --tag-specifications "ResourceType=instance, Tags=[{Key=salsa:project-id,Value=$CI_PROJECT_ID},{Key=salsa:build-job-id,Value=$BUILD_JOB_ID},{Key=Name,Value=$INSTANCE_NAME}]" | \ + jq -r ".Instances[0].InstanceId") - APP_SERVER_IP=$(aws ec2 describe-instances --instance-ids $INSTANCE_ID | jq -r ".Reservations[0].Instances[0].PublicIpAddress") - echo "APP_SERVER_IP=$APP_SERVER_IP" >> app-servers.env - echo "INSTANCE_ID=$INSTANCE_ID" >> app-servers.env @@ -21,10 +24,8 @@ dotenv: app-servers.env .run-functional-tests: - needs: - - job: app-server-unstable - artifacts: true - timeout: 2h + stage: functional-tests + timeout: 150m # Need to find a way of running the cleanup step even on failure allow_failure: true when: delayed @@ -38,7 +39,9 @@ script: - cp -r . /home/tester/freedombox && chown -R tester:tester /home/tester/freedombox - sudo -u tester bash -c 'pip3 install --user splinter pytest-splinter pytest-reporter-html1' - - 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' + - | + 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 . @@ -53,6 +56,7 @@ # Does not run if the previous job times out or is cancelled .terminate-app-server: + stage: functional-tests script: - aws ec2 --region us-east-1 terminate-instances --instance-ids $INSTANCE_ID > /dev/null tags: diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8ddba4334..4da5bb988 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,6 +8,7 @@ image: registry.salsa.debian.org/freedombox-team/freedombox:gitlabci stages: - provisioning - build + - functional-tests - publish - test @@ -43,10 +44,30 @@ doc-tests: script: - doc/scripts/wikiparser.py +app-server-stable: + variables: + LAUNCH_TEMPLATE_NAME: functional-tests-stable + INSTANCE_NAME: app-server-stable + BUILD_JOB_NAME: build-backports + extends: .app-server + +run-functional-tests-stable: + needs: + - job: app-server-stable + artifacts: true + extends: .run-functional-tests + +terminate-app-server-stable: + needs: + - job: run-functional-tests-stable + artifacts: true + extends: .terminate-app-server + app-server-testing: variables: LAUNCH_TEMPLATE_NAME: functional-tests-testing INSTANCE_NAME: app-server-testing + BUILD_JOB_NAME: build extends: .app-server run-functional-tests-testing: @@ -65,6 +86,7 @@ app-server-unstable: variables: LAUNCH_TEMPLATE_NAME: functional-tests-unstable INSTANCE_NAME: app-server-unstable + BUILD_JOB_NAME: build extends: .app-server run-functional-tests-unstable: @@ -85,6 +107,11 @@ extract-source: build: extends: .build-package +build-backports: + extends: .build-package + variables: + RELEASE: bullseye-backports + build i386: extends: .build-package-i386 @@ -123,3 +150,4 @@ rc-bugs: aptly: extends: .publish-aptly +