Skip to content
Snippets Groups Projects
.gitlab-ci.yml 2.74 KiB
Newer Older
Mélodie Boillet's avatar
Mélodie Boillet committed
stages:
  - test
  - build
  - deploy

lint:
Yoann Schneider's avatar
Yoann Schneider committed
  image: python:3.10
Mélodie Boillet's avatar
Mélodie Boillet committed
  stage: test

  cache:
    paths:
      - .cache/pre-commit

  except:
    - schedules

  variables:
    PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
    PRE_COMMIT_HOME: "$CI_PROJECT_DIR/.cache/pre-commit"

  before_script:
    - pip install pre-commit

  script:
    - pre-commit run -a

Yoann Schneider's avatar
Yoann Schneider committed
test:
  image: python:3.10

  stage: test
  cache:
    paths:
      - .cache/pip

  variables:
    PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"

  before_script:
    - pip install tox

    # Add system deps for opencv
    - apt-get update -q
    - apt-get install -q -y libgl1

  except:
    - schedules

  script:
Yoann Schneider's avatar
Yoann Schneider committed
    - tox -e teklia-dan -- -v
docker-build:
  stage: build
  image: docker:19.03.1
  services:
    - docker:dind
  variables:
    DOCKER_DRIVER: overlay2
    DOCKER_HOST: tcp://docker:2375/

  except:
    - schedules

  script:
    - ci/build.sh

# Make sure docs still build correctly
.docs:
  image: python:3.10
  artifacts:
    paths:
      - public

  before_script:
Yoann Schneider's avatar
Yoann Schneider committed
    - pip install tox
Yoann Schneider's avatar
Yoann Schneider committed
    - tox -e doc

docs-build:
  extends: .docs
  stage: build

  # Test job outside of tags to ensure the docs still can build before merging
  # Does not use the `pages` name, therefore will be ignored by GitLab Pages
  except:
    - tags
    - schedules

pages:
  extends: .docs
  stage: deploy

  only:
  except:
    - schedules

docs-deploy:
  image: node:18
  stage: deploy

  dependencies:
    - docs-build

  before_script:
    - npm install -g surge

  except:
    - tags
    - schedules

  environment:
    name: ${CI_COMMIT_REF_SLUG}
    url: https://${CI_COMMIT_REF_SLUG}-teklia-atr-dan.surge.sh
    on_stop: docs-stop-surge

  script:
    - surge public ${CI_ENVIRONMENT_URL}

docs-stop-surge:
  image: node:18
  stage: deploy
  when: manual

  # Do not try to checkout the branch if it was deleted
  variables:
    GIT_STRATEGY: none

  except:
    - tags
    - schedules

  environment:
    name: ${CI_COMMIT_REF_SLUG}
    url: https://${CI_COMMIT_REF_SLUG}-teklia-atr-dan.surge.sh
    action: stop

  before_script:
    - npm install -g surge

  script:
    - surge teardown ${CI_ENVIRONMENT_URL}

deploy-pypi:
  stage: deploy
  image: python:3.10

  only:
    - tags

  before_script:
    - pip install twine build
Yoann Schneider's avatar
Yoann Schneider committed
    - twine upload -r pypi dist/*
Mélodie Boillet's avatar
Mélodie Boillet committed
bump-python-deps:
  stage: deploy
  image: registry.gitlab.teklia.com/infra/devops:latest
Mélodie Boillet's avatar
Mélodie Boillet committed

  only:
    - schedules

  script:
    - devops python-deps pyproject.toml doc-requirements.txt
Mélodie Boillet's avatar
Mélodie Boillet committed

release-notes:
  stage: deploy
  image: registry.gitlab.teklia.com/infra/devops:latest
Mélodie Boillet's avatar
Mélodie Boillet committed

  rules:
    - if: '$CI_COMMIT_TAG'
      when: on_success
    - when: never

  script:
    - devops release-notes