20240822

GitHub Actions: Is it possible to apply linters only to changes?

Motivation

I'm refactoring a (sort of) old and large code base, and I want to force contributors to apply black for their changes.

(On second thought, maybe I can just apply black to all the files first and use black as a linter in GitHub Actions? :thinking_face:)

paths filter

I can use paths filter to trigger only when, for example, Python files change

on:
  pull_request:
    paths:
      - '**/*.py'

This way, we can avoid triggering linters such as Ruff or Flake8 when the changes are not about Python code.

Access changes in GitHub Actions

As I browsed several web pages / blogs, it seems there is no easy way to access changes.

We migt be able to

My conclusion

It seems to be difficult to implement it in GitHub Actions. I think configuring pre-hook on git commit is a popular practice, but I doubt the collaborators are happy configuring that.

We already have a workflow to run ruff, and it makes sense to not impose strict formatting rules. As long as changes follow PEP8, it should be fine.

Wait, it also makes sense to use black when having members who are not familiar with PEP8 because black can automate or get rid of effort formatting Python code. Hmm…

I will just stick to ruff for now.


Protein shake 200 Salad 500 Rice 400 Mexican rice 500 Yogurt 200 Protein bar 200

Total 2000 kcal

1-hour walking, 10k run (!)


MUST:

TODO:


index 20240821 20240823