Skip to content

Commit ef0f4ec

Browse files
committed
feat: integrate html2rss validate CLI and add editor schema support
- CI: bump actions/checkout and actions/setup-node to v4; add "Validate configs" step to the lint job using `make validate` - Makefile: add `validate` target (html2rss validate over all configs), add `schema` target (html2rss schema --write); include validate in the default goal; drop obsolete migrate-tests/restore-tests targets whose backing script no longer exists; fix double-space in prettier invocation - README: add Validation section documenting `make validate` and the single-file CLI; add Editor Setup section explaining how to generate schema/html2rss-config.schema.json and use it in VS Code or any yaml-language-server editor via the modeline comment - .vscode/settings.json: associate generated schema with all configs so VS Code + YAML extension provides inline validation automatically - .gitignore: exclude /schema/ (generated artifact) https://claude.ai/code/session_01MYdMDpKySqfU1E3qgdikoe
1 parent 2075ecb commit ef0f4ec

5 files changed

Lines changed: 61 additions & 21 deletions

File tree

.github/workflows/ruby.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- uses: actions/checkout@v2
15-
- uses: actions/setup-node@v2
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-node@v4
1616
with:
1717
node-version: "20"
1818

1919
- name: Install dependencies
20-
run: |
21-
sudo apt-get install -yqq yamllint
20+
run: sudo apt-get install -yqq yamllint
2221

2322
- name: Set up Ruby
2423
uses: ruby/setup-ruby@v1
@@ -29,6 +28,9 @@ jobs:
2928
- name: Run linters
3029
run: make lint
3130

31+
- name: Validate configs
32+
run: make validate
33+
3234
test:
3335
strategy:
3436
fail-fast: false
@@ -38,7 +40,7 @@ jobs:
3840
runs-on: ubuntu-latest
3941

4042
steps:
41-
- uses: actions/checkout@v2
43+
- uses: actions/checkout@v4
4244

4345
- name: Set up Ruby
4446
uses: ruby/setup-ruby@v1
@@ -53,7 +55,7 @@ jobs:
5355
runs-on: ubuntu-latest
5456

5557
steps:
56-
- uses: actions/checkout@v2
58+
- uses: actions/checkout@v4
5759

5860
- name: Set up Ruby
5961
uses: ruby/setup-ruby@v1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
/spec/reports/
88
/tmp/
99
/node_modules/
10+
/schema/
1011

1112
# rspec failure tracking
1213
.rspec_status

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"yaml.schemas": {
3+
"./schema/html2rss-config.schema.json": "lib/html2rss/configs/**/*.yml"
4+
}
5+
}

Makefile

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
default: lint test
1+
default: lint validate test
22

33
lint:
44
yamllint lib/html2rss/configs/ .github/
55
bundle exec rubocop -P -f quiet
6-
npx prettier --check lib/**/*.yml .github/**/*.yml README.md
6+
npx prettier --check lib/**/*.yml .github/**/*.yml README.md
7+
8+
validate:
9+
find lib/html2rss/configs -name '*.yml' -print0 | xargs -0 -n1 bundle exec html2rss validate
10+
11+
schema:
12+
mkdir -p schema
13+
bundle exec html2rss schema --write schema/html2rss-config.schema.json
714

815
test:
916
bundle exec rspec
@@ -39,18 +46,6 @@ test-debug:
3946
fi
4047
DEBUG_CONFIG=$(CONFIG) bundle exec rspec spec/html2rss/configs_dynamic_spec.rb
4148

42-
# Migration commands
43-
migrate-tests:
44-
bin/migrate_to_dynamic_tests
45-
46-
restore-tests:
47-
@if [ -d "spec/html2rss/configs_backup" ]; then \
48-
cp -r spec/html2rss/configs_backup/* spec/html2rss/configs/; \
49-
echo "✅ Restored tests from backup"; \
50-
else \
51-
echo "❌ No backup found"; \
52-
fi
53-
5449
lintfix:
5550
bundle exec rubocop -a
5651
npx prettier --write lib/**/*.yml .github/**/*.yml README.md

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ channel:
4040

4141
The `type` field specifies the parameter type (currently only `string` is supported), and `default` provides the default value when no parameter is explicitly provided.
4242

43+
## Validation
44+
45+
Validate configs against the html2rss schema before committing:
46+
47+
```bash
48+
# Validate all configs
49+
make validate
50+
51+
# Validate a single config directly
52+
bundle exec html2rss validate lib/html2rss/configs/github.com/releases.yml
53+
```
54+
4355
## Testing
4456

4557
Uses **dynamic test generation** - no individual spec files needed!
@@ -55,10 +67,35 @@ make test-config CONFIG=github.com/releases.yml
5567
make test-domain DOMAIN=github.com
5668
```
5769

58-
**Adding new configs**: Just create the YAML file and run tests. No spec file needed.
70+
**Adding new configs**: Just create the YAML file and run `make validate` then tests. No spec file needed.
5971

6072
**Config folder convention**: Place configs under the registrable domain folder (e.g., `example.com/` or `bbc.co.uk/`). Legacy subdomain folders (e.g., `news.example.com/`) are allowed but not preferred.
6173

74+
## Editor Setup (JSON Schema)
75+
76+
Get inline validation and autocompletion when editing configs in your IDE.
77+
78+
**Step 1** — Generate the schema from the installed gem:
79+
80+
```bash
81+
make schema
82+
# writes schema/html2rss-config.schema.json
83+
```
84+
85+
**Step 2** — The included `.vscode/settings.json` automatically associates the schema
86+
with all configs in `lib/html2rss/configs/`. Open the project in VS Code and the
87+
[YAML extension](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml)
88+
will pick it up immediately.
89+
90+
For other editors that support the `yaml-language-server` protocol, add this
91+
modeline at the top of any config file:
92+
93+
```yaml
94+
# yaml-language-server: $schema=../../../../schema/html2rss-config.schema.json
95+
```
96+
97+
> Re-run `make schema` after upgrading the html2rss gem to keep the schema in sync.
98+
6299
## Documentation
63100

64101
- [Main Documentation](https://html2rss.github.io/html2rss-configs/)

0 commit comments

Comments
 (0)