# core/tor releases:
# https://gitlab.torproject.org/tpo/core/team/-/wikis/NetworkTeam/CoreTorReleases
# As of 2021.03.02 all dirauths are running with version greater or equal to
# 0.4.5.
# 0.4.6 stable by Jun 15, 2021
# 0.4.5 (LTS) EOL Feb 15, 2023
# 0.3.5 (LTS) EOL Feb 1, 2022
# Python releases:
# 3.10 stable by 2021-10-04: https://www.python.org/dev/peps/pep-0619/
# Python stable releases: https://www.python.org/downloads/
# 3.9 EOL 2025-10 PEP 596
# 3.8 EOL 2024-10 PEP 569, newest major release
# 3.7 EOL 2023-06-27 PEP 537, included in Debian buster
# 3.6 EOL 2021-12-23 PEP 494

variables:
    BASE_IMAGE: python:3.8
    RELEASE: tor-nightly-master-buster
    # Without version, the default available in the Debian repository will be
    # installed.
    # Specifying which version starts with will install the highest that start
    # with that version.
    TOR: tor=*
    PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"

cache:
  paths:
    - .cache/pip

image: $BASE_IMAGE

before_script:
  - "wget https://deb.torproject.org/torproject.org/\
    A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc"
  - cat A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc  | apt-key add -
  - echo deb [signed-by=A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89]
    http://deb.torproject.org/torproject.org $RELEASE
    main >> /etc/apt/sources.list
  - apt update -yqq
  - apt install -yqq $TOR
  - pip install tox
  - python --version
  - tor --version

after_script:
  - tox -e stats

python36:
  variables:
    BASE_IMAGE: python:3.6
  image: $BASE_IMAGE
  script:
  - tox -e py36
  - tox -e integration

python37tor035:
  variables:
    BASE_IMAGE: python:3.7
    RELEASE: tor-nightly-0.3.5.x-buster
    TOR: tor=0.3.5*
  image: $BASE_IMAGE
  script:
    - tox -e py37
    - tox -e integration

python37tor045:
  variables:
    BASE_IMAGE: python:3.7
    RELEASE: tor-nightly-0.4.5.x-buster
    TOR: tor=0.4.5*
  image: $BASE_IMAGE
  script:
  - tox -e py37
  - tox -e integration

python37tormaster:
  variables:
    BASE_IMAGE: python:3.7
    RELEASE: tor-nightly-master-buster
    TOR: tor=0.4.7*
  image: $BASE_IMAGE
  script:
  - tox -e py37
  - tox -e integration

python37torstable:
  variables:
    BASE_IMAGE: python:3.7
    RELEASE: buster
    TOR: tor
  image: $BASE_IMAGE
  script:
  - tox -e py37
  - tox -e integration

python38:
  # This will overwrite the default before_script, so need to repeat the
  # commands
  before_script:
    - "wget https://deb.torproject.org/torproject.org/\
      A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc"
    - cat A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc  | apt-key add -
    - echo deb [signed-by=A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89]
      http://deb.torproject.org/torproject.org $RELEASE
      main >> /etc/apt/sources.list
    - apt update -yqq
    - apt install -yqq $TOR
    - pip install tox
    - python --version
    - tor --version
    # To build the docs
    - apt install -yqq texlive-latex-extra
    - apt install -yqq dvipng
  image: $BASE_IMAGE
  script:
  - tox

python39:
  variables:
    BASE_IMAGE: python:3.9
  image: $BASE_IMAGE
  script:
  - tox -e py39
  - tox -e integration

python310:
  variables:
    BASE_IMAGE: python:3.10-rc-buster
  image: $BASE_IMAGE
  script:
  - tox -e py310
  - tox -e integration
  allow_failure: true

release_job:
  before_script:
    - echo "Nothing"
  after_script:
    - echo "Nothing"
  image: registry.gitlab.com/gitlab-org/release-cli:latest
  only: [tags]
  script:
    - echo "Running release job."
  release:
    name: "Release $CI_COMMIT_TAG"
    description: "Created using release-cli"
    tag_name: "$CI_COMMIT_TAG"
    ref: "$CI_COMMIT_TAG"
    milestones:
      - "sbws: 1.1.x-final"
