diff --git a/ci/deploy.yml b/ci/deploy.yml index b9841357455cb3505640fe77f4c566c58453c383..8e4379344cceac071235728e24c5074eec1daf19 100644 --- a/ci/deploy.yml +++ b/ci/deploy.yml @@ -18,6 +18,7 @@ stages: - deploy + - run - cleanup # These are all configurable, globally and per-build. @@ -43,7 +44,9 @@ variables: variables: # Internal, do not change. DEPLOY_ENV_FILE: "deploy-${VM_TAG}.env" - BUILD_DIR: "$CI_PROJECT_DIR/build-$CI_JOB_ID" + # This can be any temporary directory as long as it is unique + # (multiple jobs may be running off the same CI_PROJECT_DIR). + BUILD_DIR: "${CI_PROJECT_DIR}/env-${VM_TAG}-${CI_JOB_ID}" VMINE_STATE_FILE: ".vmine_state_${CI_MERGE_REQUEST_ID}_${VM_TAG}" before_script: - mkdir -p $BUILD_DIR @@ -69,22 +72,33 @@ variables: ${BUILD_DIR} - with-ssh-key floatup $FLOATUP_ARGS --inventory $BUILD_DIR/hosts.yml --ram $VM_RAM --cpu $VM_CPU --image $VM_IMAGE --state-file $VMINE_STATE_FILE --env $DEPLOY_ENV_FILE --ttl $VM_TTL --dashboard-url $VM_DASHBOARD_URL up - with-ssh-key $BUILD_DIR/float/test-driver init --no-vagrant $BUILD_DIR - - with-ssh-key $BUILD_DIR/float/test-driver run $BUILD_DIR - after_script: - - with-ssh-key $BUILD_DIR/float/test-driver cleanup --no-vagrant $BUILD_DIR + - echo BUILD_DIR=$BUILD_DIR >> $DEPLOY_ENV_FILE allow_failure: true artifacts: when: always + expire_in: "1 day" reports: dotenv: "$DEPLOY_ENV_FILE" paths: - - "${BUILD_DIR}/logs" + - "${BUILD_DIR}" - "$VMINE_STATE_FILE" environment: name: "review/$CI_COMMIT_REF_SLUG" url: "$VMINE_GROUP_URL" auto_stop_in: "3 hours" +.run_template: + stage: run + image: registry.git.autistici.org/ai3/docker/float-runner:master + script: + - with-ssh-key $BUILD_DIR/float/test-driver run $BUILD_DIR + after_script: + - with-ssh-key $BUILD_DIR/float/test-driver cleanup --no-vagrant $BUILD_DIR + artifacts: + when: always + paths: + - "${BUILD_DIR}/logs" + .stop_deploy_template: stage: cleanup image: registry.git.autistici.org/ai3/docker/float-runner:master @@ -103,6 +117,9 @@ deploy: environment: on_stop: "stop_deploy" +run: + extends: .run_template + stop_deploy: extends: .stop_deploy_template rules: