Skip to content

Commit 7de6ac2

Browse files
authored
feat: support nox and update readme (#202)
* fix: update noxfile.py to fix Sessions defined in /workspace/commit-check/noxfile.py: * lint - test-hook - build - install-wheel - commit-check - coverage - docs sessions marked with * are selected, sessions marked with - are skipped. * feat: add docs-live * docs: update to add example * docs: update to add example * feat: use nox commands in pipeline * feat: use nox commands in pipeline * fix: remove cd to docs step * fix: get branch name to fix ci failure * fix: update noxfile.py * fix: add build session back * fix: install then run test * fix: install nox for test
1 parent 1d194eb commit 7de6ac2

File tree

4 files changed

+70
-48
lines changed

4 files changed

+70
-48
lines changed

.github/workflows/main.yml

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,26 @@ jobs:
2121
- uses: actions/setup-python@v5
2222
with:
2323
python-version: '3.x'
24-
25-
- name: Install dependencies
26-
run: |
27-
pip install -r requirements-dev.txt
28-
pip install -e .
24+
- run: pip install -r requirements-dev.txt
2925

3026
- name: Run pre-commit
3127
run: |
32-
pre-commit run --all-files
33-
pre-commit try-repo .
28+
nox -s lint
29+
nox -s test-hook
3430
3531
- name: Build wheel
36-
run: python3 -m pip wheel --no-deps -w dist .
32+
run: nox -s build
3733
- name: Upload wheel as artifact
3834
uses: actions/upload-artifact@v4
3935
with:
4036
name: commit-check_wheel
4137
path: ${{ github.workspace }}/dist/*.whl
4238
- name: Run commit-check
43-
run: |
44-
python3 -m pip install dist/*.whl
45-
commit-check -h
46-
commit-check --message --branch --author-email
39+
run: nox -s commit-check
4740

4841
- name: Collect Coverage
49-
run: |
50-
coverage run --source commit_check -m pytest
51-
coverage report && coverage xml
42+
run: nox -s coverage
43+
5244
- uses: codecov/codecov-action@v5.0.2
5345
with:
5446
token: ${{ secrets.CODECOV_TOKEN }}
@@ -69,6 +61,7 @@ jobs:
6961
- uses: actions/setup-python@v5
7062
with:
7163
python-version: ${{ matrix.py }}
64+
- run: pip install -r requirements-dev.txt
7265

7366
- name: Download wheel artifact
7467
uses: actions/download-artifact@v4
@@ -79,20 +72,21 @@ jobs:
7972
- name: Install test
8073
# using a wildcard as filename on Windows requires a bash shell
8174
shell: bash
82-
run: python3 -m pip install dist/*.whl
75+
run: nox -s install-wheel
8376

8477
docs:
8578
runs-on: ubuntu-latest
8679
steps:
8780
- uses: actions/checkout@v4
81+
with:
82+
ref: ${{ github.head_ref }} # get current branch name
8883
- uses: actions/setup-python@v5
8984
with:
9085
python-version: "3.10"
91-
- run: python -m pip install . -r docs/requirements.txt
86+
- run: pip install -r requirements-dev.txt
9287

9388
- name: Build docs
94-
working-directory: docs
95-
run: sphinx-build -E -W -b html . _build/html
89+
run: nox -s docs
9690

9791
- name: Save built docs as artifact
9892
uses: actions/upload-artifact@v4

README.rst

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ Commit Check
3030
Overview
3131
--------
3232

33-
**Commit Check** is a free, powerful tool that enforces commit metadata standards, including commit message, branch naming, committer name/email, and commit signoff. Fully customizable with error messages and suggested commands, it ensures compliance across teams.
33+
**Commit Check** is a free, powerful tool that enforces commit metadata standards, including commit message, branch naming, committer name/email, commit signoff and more.
3434

35-
As an alternative to GitHub Enterprise `Metadata restrictions <https://docs.github.com/en/enterprise-server@3.11/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets#metadata-restrictions>`_ and Bitbucket's paid puglin `Yet Another Commit Checker <https://marketplace.atlassian.com/apps/1211854/yet-another-commit-checker?tab=overview&hosting=datacenter>`_, Commit Check stands out by integrating DevOps principles and Infrastructure as Code (IaC).
35+
Fully customizable with error messages and suggested commands, it ensures compliance across teams.
36+
37+
As an alternative to GitHub Enterprise `Metadata restrictions <https://docs.github.com/en/enterprise-server@3.11/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/available-rules-for-rulesets#metadata-restrictions>`_ and Bitbucket's paid plugin `Yet Another Commit Checker <https://marketplace.atlassian.com/apps/1211854/yet-another-commit-checker?tab=overview&hosting=datacenter>`_, Commit Check stands out by integrating DevOps principles and Infrastructure as Code (IaC).
3638

3739
Configuration
3840
-------------
@@ -70,7 +72,7 @@ Running as pre-commit hook
7072
- repo: https://github.com/commit-check/commit-check
7173
rev: the tag or revision
7274
hooks: # support hooks
73-
- id: check-message # requires hook prepare-commit-msg
75+
- id: check-message # requires prepare-commit-msg hook
7476
- id: check-branch
7577
- id: check-author-name
7678
- id: check-author-email
@@ -80,25 +82,25 @@ Running as pre-commit hook
8082
Running as CLI
8183
~~~~~~~~~~~~~~
8284

83-
Global Installation
85+
Install globally
8486

8587
.. code-block:: bash
8688
8789
sudo pip3 install -U commit-check
8890
89-
User Installation
91+
Install locally
9092

9193
.. code-block:: bash
9294
9395
pip install -U commit-check
9496
95-
Install from Git Repo
97+
Install from source code
9698

9799
.. code-block:: bash
98100
99101
pip install git+https://github.com/commit-check/commit-check.git@main
100102
101-
Then, run ``commit-check`` from the command line. For more information, see the `docs <https://commit-check.github.io/commit-check/cli_args.html>`_.
103+
Then, run ``commit-check --help`` from the command line. For more information, see the `docs <https://commit-check.github.io/commit-check/cli_args.html>`_.
102104

103105
Running as Git Hooks
104106
~~~~~~~~~~~~~~~~~~~~
@@ -118,8 +120,8 @@ Save the script file as ``pre-push`` and make it executable:
118120
119121
Now, ``git push`` will trigger this hook automatically.
120122

121-
Example
122-
-------
123+
Examples
124+
--------
123125

124126
Check Commit Message Failed
125127

@@ -155,24 +157,47 @@ Check Branch Naming Failed
155157
156158
Commit rejected by Commit-Check.
157159
158-
(c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c)
159-
/ ._. \ / ._. \ / ._. \ / ._. \ / ._. \
160-
__\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__
160+
(c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c)
161+
/ ._. \ / ._. \ / ._. \ / ._. \ / ._. \
162+
__\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__
161163
(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)
162-
|| E || || R || || R || || O || || R ||
163-
_.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._
164+
|| E || || R || || R || || O || || R ||
165+
_.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._
164166
(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)
165-
`-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´
167+
`-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´
166168
167169
Commit rejected.
168170
169-
Type branch check failed => my-test-branch
171+
Type branch check failed => patch-1
170172
It doesn't match regex: ^(bugfix|feature|release|hotfix|task|chore)\/.+|(master)|(main)|(HEAD)|(PR-.+)
171-
172173
Branches must begin with these types: bugfix/ feature/ release/ hotfix/ task/ chore/
173174
Suggest: run command `git checkout -b type/branch_name`
174175
175176
177+
Check Commit Signature Failed
178+
179+
.. code-block:: text
180+
181+
Commit rejected by Commit-Check.
182+
183+
(c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c) (c).-.(c)
184+
/ ._. \ / ._. \ / ._. \ / ._. \ / ._. \
185+
__\( C )/__ __\( H )/__ __\( E )/__ __\( C )/__ __\( K )/__
186+
(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)(_.-/'-'\-._)
187+
|| E || || R || || R || || O || || R ||
188+
_.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._ _.' '-' '._
189+
(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)(.-./`-´\.-.)
190+
`-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´ `-´
191+
192+
Commit rejected.
193+
194+
Type commit_signoff check failed => c92ce259ff041c91859c7fb61afdbb391e769d0f
195+
It doesn't match regex: Signed-off-by:.*[A-Za-z0-9]\s+<.+@.+>
196+
Signed-off-by not found in latest commit
197+
Suggest: run command `git commit -m "conventional commit message" --signoff`
198+
199+
200+
176201
Badging your repository
177202
-----------------------
178203

noxfile.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import glob
33

44
nox.options.reuse_existing_virtualenvs = True
5-
nox.options.reuse_venv = True
65
nox.options.sessions = ["lint"]
76

87
REQUIREMENTS = {
@@ -42,30 +41,34 @@ def build(session):
4241

4342
@nox.session(name="install-wheel", requires=["build"])
4443
def install_wheel(session):
44+
session.run("python3", "-m", "pip", "wheel", "--no-deps", "-w", "dist", ".")
4545
whl_file = glob.glob("dist/*.whl")
4646
session.install(str(whl_file[0]))
4747

4848

49-
# @nox.session(name="commit-check", requires=["install-wheel"])
50-
@nox.session(name="commit-check", requires=["install-wheel"])
49+
@nox.session(name="commit-check")
5150
def commit_check(session):
52-
session.run(
53-
"commit-check",
54-
"--message",
55-
"--branch",
56-
"--author-email",
57-
)
51+
session.install(".")
52+
session.run("commit-check", "--message", "--branch", "--author-email")
5853

5954

60-
@nox.session(requires=["install-wheel"])
55+
@nox.session()
6156
def coverage(session):
57+
session.install(".")
6258
session.run("coverage", "run", "--source", "commit_check", "-m", "pytest")
6359
session.run("coverage", "report")
6460
session.run("coverage", "xml")
6561

6662

6763
@nox.session()
6864
def docs(session):
69-
session.install("-e", ".")
65+
session.install(".")
7066
session.install("-r", REQUIREMENTS["docs"])
7167
session.run("sphinx-build", "-E", "-W", "-b", "html", "docs", "_build/html")
68+
69+
70+
@nox.session(name="docs-live")
71+
def docs_live(session):
72+
session.install(".")
73+
session.install("-r", REQUIREMENTS["docs"], "sphinx-autobuild")
74+
session.run("sphinx-autobuild", "-b", "html", "docs", "_build/html")

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
coverage
2-
nox
2+
git+https://github.com/wntrblm/nox.git@main
33
pre-commit
44
pytest
55
pytest-mock

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy