Skip to content
Snippets Groups Projects
.gitlab-ci.yml 3.94 KiB

stages:
  - docker_build
  - test
  - cleanup

variables:
  IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
  BUILD_DIR: build-$CI_JOB_ID

.base_test_template: &base_test
  stage: test
  image: registry.git.autistici.org/ai3/docker/float-runner:master
  before_script:
    - mkdir -p $BUILD_DIR
  script:
    - >
      ./float create-env
      --domain=example.com
      --services=${TEST_DIR}/services.yml
      --passwords=${TEST_DIR}/passwords.yml
      --num-hosts=1
      ${LIBVIRT:+-e libvirt.remote_host=${LIBVIRT#*@} -e libvirt.remote_user=${LIBVIRT%@*}}
      -e ansible_cfg.defaults.strategy=mitogen_linear ${MITOGEN:+-e ansible_cfg.defaults.strategy_plugins=${MITOGEN}/ansible_mitogen/plugins/strategy}
      ${APT_PROXY:+-e config.apt_proxy=${APT_PROXY}}
      $CREATE_ENV_VARS $BUILD_DIR

    - with-ssh-key floatup ${LIBVIRT:+--ssh $LIBVIRT} --inventory $BUILD_DIR/hosts.yml --ram 2048 --cpu 2 --image ${VM_IMAGE:-bookworm} ${FLOATUP_ARGS} up
    - ls -al /root/.ssh
    - cat /root/.ssh/config
    - cat $BUILD_DIR/hosts.yml
    - with-ssh-key ./test-driver init --no-vagrant $BUILD_DIR
    - with-ssh-key ./test-driver run $BUILD_DIR
  after_script:
    - with-ssh-key ./test-driver cleanup --no-vagrant $BUILD_DIR
    - with-ssh-key floatup ${LIBVIRT:+--ssh $LIBVIRT} down
  variables:
    CREATE_ENV_VARS: ""
    TEST_DIR: ""
  tags: [ai3]
  # Some artifacts may be missing, depending on the specific job.
  artifacts:
    when: always
    expire_in: 1 week
    name: "${CI_JOB_NAME}_${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHORT_SHA}"
    reports:
      dotenv: deploy.env
      junit: pytest.xml
    paths:
      - ".vmine_group_review*"
      - "${BUILD_DIR}/ansible.log"
      - "${BUILD_DIR}/logs"

base_test:
  <<: *base_test
  variables:
    VM_IMAGE: "bookworm"
    TEST_DIR: "test/base.ref"

trixie_test:
  <<: *base_test
  # Need a more recent Ansible version, for Python 3.12 targets.
  image: registry.git.autistici.org/ai3/docker/float-runner:trixie
  variables:
    VM_IMAGE: "trixie"
    CREATE_ENV_VARS: "-e config.float_debian_dist=trixie"
    TEST_DIR: "test/base.ref"

full_test:
  <<: *base_test