# Run linter just once (outside the matrix)

**URL:** <https://travis-ci.community/t/run-linter-just-once-outside-the-matrix/14109>\
**Category:** Travis CI Discussions & Feedback\
**Created:** [December 9, 2023, 1:45pm UTC](https://travis-ci.community/t/run-linter-just-once-outside-the-matrix/14109 "2023-12-09T13:45:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![buhtz](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/buhtz/32/8238_2.png) [@buhtz](https://travis-ci.community/u/buhtz)\
**Post date:** [December 9, 2023, 1:45pm UTC](https://travis-ci.community/t/run-linter-just-once-outside-the-matrix/14109/1 "2023-12-09T13:45:41Z")

</div>

I do have a Python project using TravisCI with a build matrix resulting in 4 jobs.

> **[GitHub - bit-team/backintime: Back In Time - An an easy-to-use backup tool...](https://github.com/bit-team/backintime)**
>
> Back In Time - An an easy-to-use backup tool for Linux - GitHub - bit-team/backintime: Back In Time - An an easy-to-use backup tool for Linux

I do run linters in my unit tests, no matter that this is unusual I like it. 😉  
The point is that running linters 4 times on the same code is waste of resources (free credits from TravisCI) and CO2.

How can I run the linter just one time. Where to specify that in my [.travis.yml](https://github.com/bit-team/backintime/blob/dev/.travis.yml)?

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [December 28, 2023, 4:29am UTC](https://travis-ci.community/t/run-linter-just-once-outside-the-matrix/14109/2 "2023-12-28T04:29:25Z")

</div>

Hey @buhtz,

To have the linter only run once, you can simplify the lint job to:

```auto
jobs:
  include:
    - name: "lint"  
      python: "3.8"
      install:
        - pip install pylint 
      script:
        - python -m pylint common qt

```

Only run `pylint` on the `common` and `qt` code, no need for tests. This by design will run `pylint` once before the build matrix, without rerunning linting for every build job as you’ve stated that this is the problem you’re having in the OP.

The build matrix jobs can stay focused on running tests and coverage for the different Python versions.

I recommend caching `pylint` between builds to speed it up and run linting on pull requests only to reduce overhead. This can be done with simple branch conditionals.

---

<div class="post-metadata">

**Author:** ![buhtz](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/buhtz/32/8238_2.png) [@buhtz](https://travis-ci.community/u/buhtz)\
**Post date:** [December 28, 2023, 9:37am UTC](https://travis-ci.community/t/run-linter-just-once-outside-the-matrix/14109/3 "2023-12-28T09:37:06Z")

</div>

That is not an option because then I have to run the CI. But the linter do run in my own local environment as a unit tests.

In the end I think I will separate the tests in several categories to selectively run them.

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [December 28, 2023, 10:33am UTC](https://travis-ci.community/t/run-linter-just-once-outside-the-matrix/14109/4 "2023-12-28T10:33:37Z")

</div>

Hi @buhtz,

The second option would be yes; rewrite [backintime/.travis.yml at dev · bit-team/backintime · GitHub](https://github.com/bit-team/backintime/blob/dev/.travis.yml) in [stages](https://docs.travis-ci.com/user/build-stages/define-steps/) and have a separate linter stage defined.
