language: python
# The default python version on Travis bionic is 3.6
# But we add this line to show the python version in the Travis UI
python: "3.6"

sudo: false

cache: pip

env:
  matrix:
    ## This matrix entry is required, but it doesn't actually create any jobs
    ## by itself. All jobs are created by matrix: include: entries
    ##
    ## The TOR env var should be kept in sync with the Linux tor version in
    ## the addons section below
    - TOR="master-nightly"

matrix:
  # include creates Linux, python 3.6, tor master builds by default
  # we use tor master to catch tor issues before stable releases
  # the key(s) in each item override these defaults
  include:
    ## Test all supported and available tor versions on Linux
    ## If the deb.torproject.org repositories are removed, we will fall back to
    ## Ubuntu security's tor version (currently 0.2.9.14). We might want to
    ## automatically fail the job if we can't get a newer tor, see #29741.
    ##
    ## The current tor versions in Ubuntu are on this page:
    ## https://packages.ubuntu.com/search?keywords=tor&searchon=names&exact=1
    ##

    - addons:
        apt:
          sources:
            - sourceline: 'deb https://deb.torproject.org/torproject.org tor-nightly-0.3.5.x-bionic main'
              key_url: 'https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc'
          packages:
            - tor
      env: TOR="0.3.5-nightly"
    - addons:
        apt:
          sources:
            - sourceline: 'deb https://deb.torproject.org/torproject.org tor-nightly-0.4.1.x-bionic main'
              key_url: 'https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc'
          packages:
            - tor
      env: TOR="0.4.1-nightly"
    ## The current stable release is 0.4.2
    - addons:
        apt:
          sources:
            - sourceline: 'deb https://deb.torproject.org/torproject.org bionic main'
              key_url: 'https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc'
          packages:
            - tor
      env: TOR="stable-release"
    - addons:
        apt:
          sources:
            - sourceline: 'deb https://deb.torproject.org/torproject.org tor-nightly-0.4.2.x-bionic main'
              key_url: 'https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc'
          packages:
            - tor
      env: TOR="0.4.2-nightly"
    # We test nightly master by default, in our network tests. So we don't need
    # a nightly master test here.

    ## Test all supported python releases

    ## Pre-installed in Travis Bionic:
    ## https://docs.travis-ci.com/user/reference/bionic/#python-support

    ## End of Life: December 2021
    ## https://www.python.org/dev/peps/pep-0494/#lifespan
    - python: "3.6"

    ## End of Life: June 2023
    ## https://www.python.org/dev/peps/pep-0537/#lifespan
    - python: "3.7"

    ## Extra Installs

    ## End of Life: October 2024
    ## https://www.python.org/dev/peps/pep-0569/#lifespan
    - python: "3.8"

    ## Python 3.9
    ## (Add 3.9-dev), so far is the same as nightly
    ## Stable: 10 October 2020
    ## (Switch from 3.9-dev to 3.9, and check for {3.10,4.0}-dev)
    ## End of Life: October 2025
    ## https://www.python.org/dev/peps/pep-0596/#lifespan

    - python: "nightly"

  allow_failures:
    # stem fails:
    # <ERROR> Error initting controller socket: module 'collections' has no
    # attribute 'Iterable'
    - python: nightly

## (Linux only) Use the Ubuntu Bionic Linux Image
dist: bionic

## Download our dependencies
addons:
  ## (Linux only)
  apt:
    sources:
      - sourceline: 'deb https://deb.torproject.org/torproject.org tor-nightly-master-bionic main'
        key_url: 'https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc'
    packages:
      - tor
      # To build the docs
      - texlive-latex-extra
      - dvipng

install:
  - pip install tox-travis
  - dpkg-query --show
  ## Use the default spelling for python, unless it is overridden
  - export PYTHON=${PYTHON:-python}
  - $PYTHON --version
  - tor --version
  - tox --version

script:
  - tox
  # This is not in included in the tox envlist, in order to don't need Internet
  # when running tox
  # - tox -e doclinks
  - tox -e clean

after_success:
  # gather Python coverage
  - tox -e stats

notifications:
  irc:
    channels:
      - "irc.oftc.net#tor-ci"
    template:
      - "%{repository_slug} %{branch} %{commit} - %{author}: %{commit_subject}"
      - "Build #%{build_number} %{result}. Details: %{build_url}"
