Skip to content

Commit 4539b36

Browse files
committed
🧪 TESTS: Add pre-commit hook CI test
1 parent 81cd262 commit 4539b36

File tree

6 files changed

+41
-6
lines changed

6 files changed

+41
-6
lines changed

.github/workflows/tests.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,37 @@ jobs:
4444
- name: Run pytest
4545
run: pytest
4646

47+
pre-commit-hook:
48+
runs-on: ubuntu-latest
49+
strategy:
50+
matrix:
51+
python-version: [3.8]
52+
53+
steps:
54+
- uses: actions/checkout@v2
55+
- name: Set up Python ${{ matrix.python-version }}
56+
uses: actions/setup-python@v2
57+
with:
58+
python-version: ${{ matrix.python-version }}
59+
60+
- name: Install tox
61+
run: |
62+
python -m pip install --upgrade pip
63+
pip install tox
64+
65+
- name: run initial
66+
# the first run should populate the files with a non-zero exit code
67+
continue-on-error: true
68+
run: tox -e try-repo
69+
70+
- name: run secondary
71+
# the second run should not change any files and exit cleanly
72+
run: tox -e try-repo
73+
4774
publish:
4875

4976
name: Publish to PyPi
50-
needs: [pre-commit, tests]
77+
needs: [pre-commit, tests, pre-commit-hook]
5178
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
5279
runs-on: ubuntu-latest
5380
steps:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,4 @@ dmypy.json
129129
.pyre/
130130

131131
.vscode/
132+
tests/example_dist/

.pre-commit-hooks.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
language: python
66
language_version: python3
77
require_serial: true
8+
pass_filenames: false
89
# types: [css, javascript, jinja2, json, scss, toml, yaml]
910
types: [text]

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ Add to your `.pre-commit-config.yaml`
3333
args: [--config=config.yml]
3434
files: >-
3535
(?x)^(
36+
web-compile-config.yml|
3637
src/.*|
3738
dist/.*
3839
)$
3940
```
4041
4142
By default, the hook will be initiated for all text file changes.
42-
But it is advisable to constrain this to the known input and output folders.
43+
But it is advisable to constrain this to the known configuration file, and input/output folders.
4344
4445
## Configuration
4546
@@ -319,6 +320,12 @@ To test out the CLI:
319320
tox -e py37-cli
320321
```
321322

323+
To test the pre-commit hook:
324+
325+
```console
326+
tox -e try-repo
327+
```
328+
322329
For code style:
323330

324331
```console

web-compile-config.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ web-compile:
1818
tests/example_src/example3.j2: tests/example_dist/example3.txt
1919
variables:
2020
a: b
21-
exit_code: 2
22-
verbose: false
21+
exit_code: 3
22+
verbose: true
2323
test_run: false
2424
continue_on_error: true
2525
quiet: false
26+
git_add: false

web_compile/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import os
66
from pathlib import Path
77
import sys
8-
from typing import List
98

109
import click
1110
from git import Repo, InvalidGitRepositoryError
@@ -110,7 +109,6 @@
110109
@QUIET
111110
@VERBOSE
112111
def run_compile(
113-
files: List[str],
114112
config_path: Path,
115113
sass_files: dict,
116114
sass_format: str,

0 commit comments

Comments
 (0)