Skip to content

Commit 59d97af

Browse files
committed
updated README
1 parent 4f97310 commit 59d97af

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

README.md

+20-20
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<p>Works in python and PySpark.</p>
77
<br>
88
<h3>How to use:</h3>
9-
<p>You can clone the repo <a target="_blank" href="https://github.com/anthonypernia/pre-commit-python-action-example.git">https://github.com/anthonypernia/pre-commit-python-action-example.git</a> or just download the files that you need and use in your repo.</p>
9+
<p>You can clone the repo <a target="_blank" href="https://github.com/anthonypernia/pre-commit-python-action-example.git">https://github.com/anthonypernia/pre-commit-python-action-example.git</a> or just download the files that you need and use in your repo.</p>
1010
<p>Install the necessary libraries:</p>
1111
<ul>
1212
<li>pre-commit</li>
@@ -20,7 +20,7 @@
2020
<p>Or just install the requirements.txt that is in this repo using: <code>pip install -r requirements.txt </code></p>
2121
<h2>Pre-commit</h2>
2222
<p>Pre-commit is a tool that we use to identify issues in our code, such as type errors, syntax errors, functions without documentation, etc </p>
23-
<p>To learn more about Pre-commit you can check the <a target="_blank" href="https://pre-commit.com/#intro">Documentation</a> </p>
23+
<p>To learn more about Pre-commit you can check the <a target="_blank" href="https://pre-commit.com/#intro">Documentation</a> </p>
2424
<p>To execute <code>pre-commit</code> use the following command:</p>
2525
<pre><code>pre-commit run --all-files</code></pre>
2626
<p>And then, the library starts checking the code with all the hooks that we are using in the <code>pre-commit-config</code> file. The first time it will take about 2 minutes </p>
@@ -44,32 +44,32 @@
4444
<img src="https://raw.githubusercontent.com/anthonypernia/setup-python-environment-with-testing-and-github-actions/main/assets/commit-example.png"></img>
4545
<p>In case it passes all the tests, the commit will be executed, otherwise it will not</p>
4646
<p>You can copy my pre-commit configuration:</p>
47-
<p>Pre-commit file: <code>.pre-commit-config.yaml</code> <a target="_blank" href="https://github.com/anthonypernia/setup-python-environment-with-testing-and-github-actions/blob/main/.pre-commit-config.yaml">Link</a></p>
47+
<p>Pre-commit file: <code>.pre-commit-config.yaml</code> <a target="_blank" href="https://github.com/anthonypernia/setup-python-environment-with-testing-and-github-actions/blob/main/.pre-commit-config.yaml">Link</a></p>
4848
<h2>Github Action using Pre-Commit, PyTest and Coverage</h2>
4949
<p>Github actions is the way that we have to apply CICD or run customized workflows</p>
50-
<p>You can take a look at the <a target="_blank" href="https://docs.github.com/en/actions">Documentation</a></p>
50+
<p>You can take a look at the <a target="_blank" href="https://docs.github.com/en/actions">Documentation</a></p>
5151
<p>The funniest thing is that pre-commit can be added to a workflow as an automated task, we can add unit testing, check the coverage, etc. All this task can be executed after push our code or create a pull request.</p>
5252
<h4>There are some examples with customized workflows:</h4>
5353
<ul>
54-
<li><p><a target="_blank" href="https://github.com/anthonypernia/setup-python-environment-with-testing-and-github-actions/blob/main/action-to-use/pre-commit-and-merge.yml">pre-commit-and-merge.yml</a>, This workflow will merge all the push that pass the pre-commit tests, from the develop branch, into the master branch</p></li>
55-
<li><p><a target="_blank" href="https://github.com/anthonypernia/setup-python-environment-with-testing-and-github-actions/blob/main/action-to-use/pre-commit-on-pr.yml">pre-commit-on-pr.yml</a>, This workflow will execute pre-commit on all pull requests to main branch and will show the result in the PR</p></li>
56-
<li><p><a target="_blank" href="https://github.com/anthonypernia/setup-python-environment-with-testing-and-github-actions/blob/main/action-to-use/pre-commit-on-push-and-pr.yml">pre-commit-on-push-and-pr.yml</a>, Same as before , but in this case it will execute test on PR to main branch and all push to develop
54+
<li><p><a target="_blank" href="https://github.com/anthonypernia/setup-python-environment-with-testing-and-github-actions/blob/main/action-to-use/pre-commit-and-merge.yml">pre-commit-and-merge.yml</a>, This workflow will merge all the push that pass the pre-commit tests, from the develop branch, into the master branch</p></li>
55+
<li><p><a target="_blank" href="https://github.com/anthonypernia/setup-python-environment-with-testing-and-github-actions/blob/main/action-to-use/pre-commit-on-pr.yml">pre-commit-on-pr.yml</a>, This workflow will execute pre-commit on all pull requests to main branch and will show the result in the PR</p></li>
56+
<li><p><a target="_blank" href="https://github.com/anthonypernia/setup-python-environment-with-testing-and-github-actions/blob/main/action-to-use/pre-commit-on-push-and-pr.yml">pre-commit-on-push-and-pr.yml</a>, Same as before , but in this case it will execute test on PR to main branch and all push to develop
5757
</p></li>
58-
<li><p><a target="_blank" href="https://github.com/anthonypernia/setup-python-environment-with-testing-and-github-actions/blob/main/action-to-use/pre-commit-and-pytest.yml">pre-commit-and-pytest.yml.yml</a>, In this case, in addition to running the pre-commit tests, this workflow will run the pytest suite.</p></li>
59-
<li><p><a target="_blank" href="https://github.com/anthonypernia/setup-python-environment-with-testing-and-github-actions/blob/main/action-to-use/pre-commit-pytest-coverage-codecov.yml">pre-commit-pytest-coverage-codecov.yml</a>, This workflow is the most complete. it will execute the following actions:
58+
<li><p><a target="_blank" href="https://github.com/anthonypernia/setup-python-environment-with-testing-and-github-actions/blob/main/action-to-use/pre-commit-and-pytest.yml">pre-commit-and-pytest.yml.yml</a>, In this case, in addition to running the pre-commit tests, this workflow will run the pytest suite.</p></li>
59+
<li><p><a target="_blank" href="https://github.com/anthonypernia/setup-python-environment-with-testing-and-github-actions/blob/main/action-to-use/pre-commit-pytest-coverage-codecov.yml">pre-commit-pytest-coverage-codecov.yml</a>, This workflow is the most complete. it will execute the following actions:
6060
<ul>
6161
<li>run pre-commit test</li>
6262
<li>run pytest suite</li>
6363
<li>check the coverage and upload to Codecov</li>
6464
<li>it will fail if coverage is not ok</li>
6565
</ul>
66-
You can find more info in <a target="_blank" href="https://app.codecov.io/gh">Codecov</a></p></li>
66+
You can find more info in <a target="_blank" href="https://app.codecov.io/gh">Codecov</a></p></li>
6767
</ul>
6868
<h3>Best Option: pre-commit-pytest-coverage-codecov</h3>
6969
<p>The one that I consider the best is the last one because it checks the coverage, execute the pytest suite, and executes the pre-commit so that at the end you can see the coverage graphs in the PR</p>
70-
<p>You need to create an account in <a target="_blank" href="https://app.codecov.io/gh">Codecov</a>, give it permission to scan repositories, get the codecov token , and store in secrets as CODECOV_TOKEN</p>
70+
<p>You need to create an account in <a target="_blank" href="https://app.codecov.io/gh">Codecov</a>, give it permission to scan repositories, get the codecov token , and store in secrets as CODECOV_TOKEN</p>
7171
<p>If you want to configure coverage to approve, you need to create a file called <code>codecov.yml</code></p>
72-
<p>You can check the file that I use in <a target="_blank" href="https://github.com/anthonypernia/setup-python-environment-with-testing-and-github-actions/blob/main/codecov.yml" ></a></p>
72+
<p>You can check the file that I use in <a target="_blank" href="https://github.com/anthonypernia/setup-python-environment-with-testing-and-github-actions/blob/main/codecov.yml" ></a></p>
7373
<p>Here is an example of a PR using that workflow, in that case, we have some errors in pre-commit and we need to solve it</p>
7474
<img src="https://raw.githubusercontent.com/anthonypernia/setup-python-environment-with-testing-and-github-actions/main/assets/pre-commit-fail-github.png"></img>
7575
<p>When the problem is solved, when you push your code again, the tests will be updated, in that case, we need to update the test to complete the coverage</p>
@@ -79,19 +79,19 @@
7979
<img src="https://raw.githubusercontent.com/anthonypernia/setup-python-environment-with-testing-and-github-actions/main/assets/pr-ok.png"></img>
8080
<br>
8181
The documentation that I used to create this repository is:
82-
<p><a target="_blank" href="https://pre-commit.com/#install">https://pre-commit.com/#install</a></p>
83-
<p><a target="_blank" href="https://pre-commit.com/#usage">https://pre-commit.com/#usage</a></p>
84-
<p><a target="_blank" href="https://composed.blog/python/pre-commit">https://composed.blog/python/pre-commit</a></p>
82+
<p><a target="_blank" href="https://pre-commit.com/#install">https://pre-commit.com/#install</a></p>
83+
<p><a target="_blank" href="https://pre-commit.com/#usage">https://pre-commit.com/#usage</a></p>
84+
<p><a target="_blank" href="https://composed.blog/python/pre-commit">https://composed.blog/python/pre-commit</a></p>
8585
<p><a
86-
target="_blank" href="https://towardsdatascience.com/pre-commit-hooks-you-must-know-ff247f5feb7e">https://towardsdatascience.com/pre-commit-hooks-you-must-know-ff247f5feb7e</a>
86+
target="_blank" href="https://towardsdatascience.com/pre-commit-hooks-you-must-know-ff247f5feb7e">https://towardsdatascience.com/pre-commit-hooks-you-must-know-ff247f5feb7e</a>
8787
</p>
8888
<p><a
89-
target="_blank" href="https://verdantfox.com/blog/view/how-to-use-git-pre-commit-hooks-the-hard-way-and-the-easy-way">https://verdantfox.com/blog/view/how-to-use-git-pre-commit-hooks-the-hard-way-and-the-easy-way</a>
89+
target="_blank" href="https://verdantfox.com/blog/view/how-to-use-git-pre-commit-hooks-the-hard-way-and-the-easy-way">https://verdantfox.com/blog/view/how-to-use-git-pre-commit-hooks-the-hard-way-and-the-easy-way</a>
9090
</p>
9191
<p>Some hooks examples:</p>
92-
<p><a target="_blank" href="https://github.com/pre-commit/pre-commit-hooks">https://github.com/pre-commit/pre-commit-hooks</a></p>
92+
<p><a target="_blank" href="https://github.com/pre-commit/pre-commit-hooks">https://github.com/pre-commit/pre-commit-hooks</a></p>
9393
<p>Information about Pytest:</p>
94-
<p><a target="_blank" href="https://docs.pytest.org/en/6.2.x/customize.html">https://docs.pytest.org/en/6.2.x/customize.html</a></p>
94+
<p><a target="_blank" href="https://docs.pytest.org/en/6.2.x/customize.html">https://docs.pytest.org/en/6.2.x/customize.html</a></p>
9595
<p>Codecov Documentation:</p>
96-
<p><a target="_blank" href="https://docs.codecov.com/docs">https://docs.codecov.com/docs</a></p>
96+
<p><a target="_blank" href="https://docs.codecov.com/docs">https://docs.codecov.com/docs</a></p>
9797
</div>

0 commit comments

Comments
 (0)