You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: article/article.md
+14-14Lines changed: 14 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -9,13 +9,13 @@ Recently I was involved in configuring linters as a part of CI/CD in GitHub acti
9
9
10
10
I would like to share how to configure it for the python project. I prepared a full [github actions python configuration demo repository](https://github.com/iamtodor/github-actions-python-demo).
11
11
12
-
We use flakeheaven as flake8 wrapper, which is very easy to configure in one single `pyproject.toml` configuration file.
12
+
We use flakeheaven as a flake8 wrapper, which is very easy to configure in one single `pyproject.toml` configuration file.
13
13
The whole `pyproject.toml` configuration file could be found in
14
14
a [repo](https://github.com/iamtodor/github-actions-python-configuration-demo/blob/main/pyproject.toml).
Next, with default configuration we would get the next warning:
67
+
Next, with the default configuration we would get the next warning:
68
68
69
69
```
70
70
python -m flakeheaven lint .
@@ -84,7 +84,7 @@ specify task order.
84
84
85
85
**Disclaimer**: author assumes you are familiar with [GitHub actions](https://github.com/features/actions).
86
86
87
-
We configure GitHub Workflow to be triggered on every PR against main (master) branch.
87
+
We configure GitHub Workflow to be triggered on every PR against the main (master) branch.
88
88
89
89
Here are the linters and checks we are going to use:
90
90
@@ -102,17 +102,17 @@ We are interested in running linter only when PR has `.py` files. For instance,
102
102
103
103

104
104
105
-
We are interested in running a linter only against the modified files. Let's say, we take a look at the provided repo, if I update `dags/dummy.py` I don't want to waste a time and resources running linter against `main.py`. For this purpose we use [Paths Filter GitHub Action](https://github.com/dorny/paths-filter), that is very flexible.
105
+
We are interested in running a linter only against the modified files. Let's say, we take a look at the provided repo, if I update `dags/dummy.py` I don't want to waste a time and resources running linter against `main.py`. For this purpose we use [Paths Filter GitHub Action](https://github.com/dorny/paths-filter), which is very flexible.
If we have in one PR modified `.py` and any other files such as `.toml`, we don't want to run linter against not `.py`, so we use where we configured filtering only for `.py` files no matter its location: root, tests, src, etc.
110
110
111
-
Changed file can have the following statuses `added`, `modified`, or `deleted`. There is no reason to run a linter against deleted file as your workflow would simply fail, because there is no more that particular changed file in repo. So we need to configure what changes we consider to trigger linter.
111
+
The changed file can have the following statuses `added`, `modified`, or `deleted`. There is no reason to run a linter against deleted files as your workflow would simply fail, because there is no more that particular changed file in the repo. So we need to configure what changes we consider to trigger linter.
I define the variable where I can find the output (the only `.py` files) from the previous filter. This variable would contain modified `.py` files, that I can further pass to a `flakeheaven`, `black`, and `isort`. By default, the output is disabled, and Paths Changes Filter allows to customize it: you can list the files in `.csv`, `.json` or in a `shell` mode. Linters accept files separated simply by space, so our choice here is `shell` mode.
115
+
I define the variable where I can find the output (the only `.py` files) from the previous filter. This variable would contain modified `.py` files, that I can further pass to a `flakeheaven`, `black`, and `isort`. By default, the output is disabled, and Paths Changes Filter allows you to customize it: you can list the files in `.csv`, `.json`, or in a `shell` mode. Linters accept files separated simply by space, so our choice here is `shell` mode.
Before we run linter on changed files we run a check if there is an actual changes in `.py` files, if there are any `.py` files from the previous step than we can use.
125
+
Before we run linter on changed files we run a check if there is an actual change in `.py` files, if there are any `.py` files from the previous step.
126
126
127
127

128
128
@@ -132,12 +132,12 @@ Next, using the before-mentioned output variable we can safety pass the content
132
132
133
133
## Conclusion
134
134
135
-
That's all I would like to share. I hope it is useful for you, and you can utilize this experience and knowledge.
135
+
That's all I would like to share. I hope it is useful for you, and that you can utilize this experience and knowledge.
136
136
137
-
I wish you to see this success checks every time you push your code :)
137
+
I wish you to see these success checks every time you push your code :)
0 commit comments