if: tag IS present OR type = pull_request OR (branch = master AND type = push)   # we only CI the master, tags and PRs
language: python

# Main test jobs: The lowest and highest current Python versions.
python:
  - 3.6
  - 3.9

# List additional test configurations individually, instead of using
# matrix expansion, to prevent an exponential growth of test jobs.
matrix:
  include:
    # Python versions that are EOL, but we still support.
    # PY2.7 here should bring out any PY3.5 incompatibilities as well.
    - python: 2.7
      arch: amd64
    # pydot itself should be architecture-independent. Still, some
    # limited testing on other architectures to catch corner cases.
    - python: 2.7
      arch: ppc64le
    - python: 3.9
      arch: ppc64le

addons:
  apt:
    packages:
      - graphviz

install:
  - pip install -U pip setuptools
  - python setup.py sdist
  - pip install dist/pydot-*.tar.gz
  - pip install -r requirements.txt

script:
  - cd test/
  - python pydot_unittest.py

# after_success:
#   - coveralls

if: tag IS present OR type = pull_request OR (branch = master AND type = push)   # we only CI the master, tags and PRs
language: python

# Main test jobs: The lowest and highest current Python versions.
python:
  - 3.6
  - 3.9

# List additional test configurations individually, instead of using
# matrix expansion, to prevent an exponential growth of test jobs.
matrix:
  include:
    # Python versions that are EOL, but we still support.
    # PY2.7 here should bring out any PY3.5 incompatibilities as well.
    - python: 2.7
      arch: amd64
    # pydot itself should be architecture-independent. Still, some
    # limited testing on other architectures to catch corner cases.
    - python: 2.7
      arch: ppc64le
    - python: 3.9
      arch: ppc64le
    # Additional job to run linters that only need to run once.
    - name: black
      language: python
      python: 3.6
      arch: amd64
      addons:
        apt:
          packages: []
      install:
        - pip install -e .[dev]
      script:
        - black --check --diff .

addons:
  apt:
    packages:
      - graphviz

install:
  - pip install -U pip setuptools
  - python setup.py sdist
  - pip install dist/pydot-*.tar.gz
  - pip install -r requirements.txt

script:
  - cd test/
  - python pydot_unittest.py

Switch to code formatter Black: Travis integration
Switch to code formatter Black: Travis integration

This adds a new job for running `black` to our Travis CI continuous
integration configuration. See the previous commits for more details on
Black.

If `black` finds a problem with the formatting, its job will be marked
as "Failed". A diff of the required changes can be found on Travis CI
by clicking on job `black` and scrolling down the Job log. You may also
run `black` on your local machine to let it make the corrections for
you.

The new job is added to the default stage (`test`), meaning it will run
alongside the regular test suite jobs. `black` is kept separate from
the test suite, because it only needs to run once, not on multiple
Python versions and architectures.

A failure reported by `black` will not stop the test suite jobs from
running, but will result in the build as a whole to be marked "Failed"
in the end, even if the other jobs all passed.

Using a separate Travis CI "stage" (named `lint`) was attempted, but
considered inadequate:
- Running stage `lint` *after* stage `test` meant long waiting for
  what was actually the fastest job.
- Running stage `lint` *before* stage `test` meant a minor formatting
  issue could prevent the test suite from running at all.
  - Defining stage `lint` as an `allowed_failure` meant its outcome
    would become irrelevant for the outcome of the build as a whole,
    i.e. the build would pass even if `lint` had failed.
