Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/CI_go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ jobs:
if: steps.go.outputs.present == 'true'
run: make nethttp

# A provider scaffolded with new-plugin, with a TODO(new-plugin) left.
- name: no TODO(new-plugin) left
if: steps.go.outputs.present == 'true'
run: make todos

# -race: the fetcher and the tests' HTTP servers run on other goroutines.
# Also fails when docs/plugins.json is out of date (make plugins-json).
- name: go test
Expand Down
7 changes: 5 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Refer to the service that runs these plugins as "patch-it's hosted ingestion ser

## Rules for plugin code

- **Start a new provider with `go run ./cmd/new-plugin --api <id> --provider <Name> --format <format>`**, then fill in every `TODO(new-plugin)`; `make todos` (part of `make check` and CI_go) fails while one is left.

- **Fetch only through the environment** (`env.Get` or `kit/`). No `net/http` outside the fetch layer, no filesystem outside `testdata/`, no database.
- **Golden test + dated source quote**: a saved copy of the real source in `testdata/`, a row in `testdata/README.md` (URL, date fetched, license, quote), and `testdata/golden/<api>.json` with the exact events.
- **Precision over recall.** When unsure whether something is a change, don't emit an event.
Expand All @@ -36,12 +38,12 @@ Refer to the service that runs these plugins as "patch-it's hosted ingestion ser
**Run `make check` before you say you're done.** It runs exactly what `CI_go` runs (each CI step is a Makefile target) plus the internal-names check over every tracked file; if it passes locally, those checks pass in CI.

```sh
make check # tidy, build, gofmt, vet, the import allowlist, the net/http guard, go test -race, leak guard
make check # tidy, build, gofmt, vet, the import allowlist, the net/http guard, go test -race, no TODO(new-plugin) left, leak guard
make check PATCH_IT=../patch-it # also CI_contract: contract/fixtures/ against a patch-it checkout
make plugins-json # regenerate docs/plugins.json after adding or changing a plugin or its row
```

One target at a time: `make tidy`, `make build`, `make fmt`, `make vet`, `make imports`, `make nethttp`, `make test`, `make leak-guard`, `make contract`. Use `make GO=/path/to/go check` for another Go.
One target at a time: `make tidy`, `make build`, `make fmt`, `make vet`, `make imports`, `make nethttp`, `make test`, `make todos`, `make leak-guard`, `make contract`. Use `make GO=/path/to/go check` for another Go.

## Layout

Expand All @@ -50,6 +52,7 @@ Go module `github.com/patch-it-dev/patch-it-plugins`; the only dependency is `go
```
plugin/ the Plugin interface, the registry, Env, Result, Spec (baselines)
cmd/list-plugins/ writes docs/plugins.json (make plugins-json); internal/pluginlist/ is its logic
cmd/new-plugin/ scaffolds a provider on a format plugin (go run ./cmd/new-plugin --help)
plugins/<format>/ one package per format plugin: openapi, retirements, migrationguide,
removedmembers, changelog, feed, apichangelog, catalog; plugins/all imports every one
kit/ kit/kittest/ Unchanged, Cite, Wayback; the test kit (Mem, Pages, Ingest, Golden)
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Thanks for helping patch-it watch more APIs. This file is the rulebook; [docs/writing-a-plugin.md](docs/writing-a-plugin.md) is the how-to.

**Start a new provider with the starter:** `go run ./cmd/new-plugin --api <id> --provider <Name> --format <format>` writes the definition, its registration, a test over placeholder sources, the testdata rows, the provider page and the `docs/plugins.md` row; you fill in the `TODO(new-plugin)`s ([how](docs/writing-a-plugin.md#1-scaffold-it-with-new-plugin)).

## The rules

1. **Add your plugin to [docs/plugins.md](docs/plugins.md).** Every new plugin gets a row; every change to a plugin's id, provider, source, what it watches or status updates its row. The list on docs.patch-it.dev is built from that file, so a plugin that isn't listed is invisible to users. Then run `make plugins-json` to regenerate [`docs/plugins.json`](docs/plugins.json); it fails if the registry and the table disagree, and the tests fail while the JSON is out of date.
Expand Down
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ PYTHON ?= python3
MODULE := github.com/patch-it-dev/patch-it-plugins
ALLOWED := ^($(MODULE)(/|$$)|gopkg\.in/yaml\.v3$$)

.PHONY: check tidy build fmt vet imports nethttp test leak-guard contract plugins-json
.PHONY: check tidy build fmt vet imports nethttp test todos leak-guard contract plugins-json

check: tidy build fmt vet imports nethttp test leak-guard contract
check: tidy build fmt vet imports nethttp test todos leak-guard contract
@echo "make check: all passed"

# go.mod and go.sum are tidy.
Expand Down Expand Up @@ -62,6 +62,16 @@ nethttp:
test:
$(GO) test -race -count=1 ./...

# A provider started with new-plugin is done when nothing it wrote still says
# TODO(new-plugin).
TODO_DIRS := plugins adapter retire sdkguide migrate providers docs/plugins.md
todos:
@left=$$(grep -rl 'TODO(new-plugin)' $(TODO_DIRS) || true); \
if [ -n "$$left" ]; then \
for f in $$left; do echo "::error file=$$f::TODO(new-plugin) left: fill it in (grep -n 'TODO(new-plugin)' $$f)."; done; \
exit 1; \
fi

# CI_leak_guard checks only what a PR adds (plus gitleaks); this checks every
# tracked file.
leak-guard:
Expand Down
Loading
Loading