Skip to content

Commit d278b73

Browse files
SecondSkollCopilot
andauthored
feat: add test framework (#157)
* fix: scope of specific rules * fix: spelling scoping * fix: spelling ignores * feat: customise spelling filters * chore: revert hyphenated words inclusion * feat: add POC tests * feat: improve test framework * feat: add tests * chore: backup initial tests * feat: implement copilot assisted test suite * fix: remove blockignore * Apply suggestions from code review chore: apply review suggestions Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * feat: testing and rule update * feat: rule 004 testing update * chore: add comment regarding missing rules * fix: apply suggested changes * fix: test case name * fix: clarify rule --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d6ead2b commit d278b73

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+803
-1344
lines changed

.github/workflows/pytest.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Vale + Pytest
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
# Allow manual trigger
7+
workflow_dispatch: {}
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
tests:
14+
name: Pytest (Vale rules)
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: [ '3.10', '3.12' ]
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Python
24+
uses: actions/setup-python@v5
25+
with:
26+
python-version: ${{ matrix.python-version }}
27+
cache: 'pip'
28+
29+
- name: Install Python dependencies
30+
run: |
31+
pip install -r tests/requirements.txt
32+
33+
- name: Run pytest suite
34+
env:
35+
# Set to 1 once manifest covers ALL style rules to enforce coverage.
36+
VALE_ENFORCE_COVERAGE: 0
37+
run: |
38+
python -m pytest -q || python -m pytest -vv
39+

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
node_modules
22
coverage
33
build/
4+
.venv
5+
.vscode
6+
.pytest_cache/
7+
tests/__pycache__/

getting-started.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,12 @@ in the root directory `documentation-style-guide/`.
147147
**My rule isn't getting applied to the text**
148148
* Make sure the rule file uses the extension `.yml` instead of `.yaml`
149149
* There might be a hidden syntax issue - consider using a local YAML linter or [online tool](https://jsonformatter.org/yaml-validator) to validate your rule.
150+
151+
### Conditionally ignoring rules
152+
153+
Some rules can be ignored conditionally, these conditions can come in a variety
154+
of forms.
155+
156+
Rulesets that extend the default `existence` rule can use the dictionary to
157+
ignore specific terms (including hyphenated terms or terms consisting of
158+
multiple words).

styles/Canonical/003-Ubuntu-names-versions.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ message: |
66
link: https://docs.ubuntu.com/styleguide/en/#ubuntu
77
nonword: true
88
ignorecase: true
9+
vocab: false
910
scope:
1011
- sentence
1112
- list
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
extends: substitution
2-
message: "Use '%s' instead of '%s'"
2+
message: "Use '%[1]s' instead of '%[2]s'"
33
link: https://docs.ubuntu.com/styleguide/en/#other-canonical-products
4-
ignorecase: true
54
level: error
65
scope:
76
- sentence & ~blockquote
87
- list
98
- heading
109
- table.header
1110
- table.cell
12-
action:
13-
name: replace
11+
ignorecase: true
12+
nonword: true
1413
swap:
15-
Anbox Cloud: Anbox Cloud
14+
"(?<=Anbox )Cloud": "Cloud" # Because Anbox is a dictionary term, multi-word capture does not work
1615
Anbox: Anbox
17-
Charmed Kubeflow: Charmed Kubeflow
16+
Kubeflow: "Kubeflow"
17+
"Charmed(?= kubeflow)": "Charmed"
1818
Canononical Observability Stack: Canonical Observability Stack
1919
Juju: Juju
2020
Landscape(?! environment| layout): Landscape
@@ -27,8 +27,12 @@ swap:
2727
MicroOVN: MicroOVN
2828
MicroStack: MicroStack
2929
Multipass: Multipass
30+
(?<=Canonical )Observability Stack: Observability Stack
3031
Snapcraft: Snapcraft
31-
snapd: snapd
32+
snapd: snapd # Vale seems to allow normal capitalisation, may need specific existence rule for Snapd
3233
Ubuntu Core: Ubuntu Core
33-
Ubuntu Pro: Ubuntu Pro
34+
(?<=Ubuntu )Pro: Pro
3435
Ubuntu Server: Ubuntu Server
36+
37+
# Not working with multi-word terms that have the first word in the accept list
38+
# Workaround is to positive lookbehind for the term

styles/Canonical/025a-latinisms-with-english-equivalents.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
# 025 - Latinisms that have English equivalents
2-
31
extends: substitution
42
message: "Instead of '%[2]s', use %[1]s."
53
link: https://docs.ubuntu.com/styleguide/en#latin-words-and-phrases
6-
level: suggestion
4+
level: error
75
scope:
86
- sentence
97
- list
108
- heading
119
- table.header
1210
- table.cell
13-
nonword: true
1411
ignorecase: true
15-
swap:
16-
\ba\spriori\b: "'self-evident', 'presupposed', 'presumed', or 'assumed'"
12+
swap: # Multiple word terms need to use "this\\sword" to match properly
13+
"a\\spriori": "'self-evident', 'presupposed', 'presumed', or 'assumed'"
1714
\bad\shoc\b: "'unscheduled', 'unexpected', 'improvised', 'temporary', or 'bespoke'"
1815
\bad\sinfinitum\b: "'and so on', 'to the fullest extent', or 'recursively'"
1916
\bcf\.?\b: "'refer to'"
@@ -39,4 +36,4 @@ swap:
3936
\b(?:versus|vs\.(?!\w)|vs(?![\.\w])): "'compared to/with' or 'opposed to'"
4037
\bvia\b: "'through', 'with', or 'using'"
4138
\bvice\sversa\b: "'the reverse' or 'the other way around'"
42-
\b(viz\.(?!\w)|viz(?![\w\.])): "'specifically' or 'namely'"
39+
\b(?:viz\.(?!\w)|viz(?![\w\.])): "'specifically' or 'namely'"

styles/Canonical/400-Enforce-inclusive-terms.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ tokens:
1818
- (?<!jenkins\-)slaves?
1919
- chairman
2020
- foreman
21-
- dumm(y|ies)
21+
- dum(b|my|mies)
2222
- grandfather(ed)?
2323
- guys?
2424
- hangs?

styles/Canonical/500-Repeated-words.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ scope:
1010
alpha: true
1111
ignorecase: true
1212
tokens:
13-
- '[^\s]+'
13+
- '(\w\n?)+'
14+
15+
16+
## Currently not detecting across multiple lines

styles/config/vocabularies/Canonical/accept.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ Linkerd
177177
Linux
178178
LinuxONE
179179
Livepatch
180+
LTS
180181
LTV
181182
LXC
182183
LXD
@@ -295,7 +296,7 @@ SLA
295296
SMTP
296297
Snapcraft
297298
snapcrafting
298-
Snapd
299+
snapd
299300
Snap Store Proxy
300301
SOW
301302
Spark
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
ROCKcraft
1+
ROCKcraft
2+
Snapd

0 commit comments

Comments
 (0)