Skip to content

Commit

Permalink
Switch to code formatter Black: Travis integration
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
peternowee committed Jun 21, 2021
1 parent 9377e3b commit 479bdca
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions .travis.yml
Expand Up @@ -20,6 +20,18 @@ matrix:
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:
Expand All @@ -35,6 +47,3 @@ install:
script:
- cd test/
- python pydot_unittest.py

# after_success:
# - coveralls

0 comments on commit 479bdca

Please sign in to comment.