From 479bdcae788dcfa92ec3cf699b2878190ba390fe Mon Sep 17 00:00:00 2001 From: Peter Nowee Date: Mon, 14 Jun 2021 08:12:43 +0200 Subject: [PATCH] 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. --- .travis.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 30fba6f..6d46fc0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: @@ -35,6 +47,3 @@ install: script: - cd test/ - python pydot_unittest.py - -# after_success: -# - coveralls