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
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Every change needs a review from a maintainer.
* @adssib
19 changes: 19 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## What this changes

<!-- One plugin or one fix. Which provider, which source, what kind of change it reports. -->

## Checklist

- [ ] **Added to / updated in `docs/plugins.md`** (new plugin: a row; changed id, provider, source, what it watches, format or status: the row updated; removed: the row removed). Not applicable: <!-- say why -->
- [ ] Every commit is signed off (`git commit -s`, DCO)
- [ ] Golden test over a real saved copy of the source (`testdata/golden/<api>.json`)
- [ ] `testdata/README.md` lists each file: URL, date fetched, license, quote of the part the plugin reads
- [ ] One pinned drop test: a realistic input that produces no event
- [ ] `providers/<api>.md` written or updated from `providers/_template.md`, including **Why this source**
- [ ] Fetches only through `env.Get` / `kit/`
- [ ] `go build ./... && go vet ./... && gofmt -l . && go test -race ./...` pass locally
- [ ] Nothing private: no credentials, internal hosts, private links, customer names

## Notes for the reviewer

<!-- Anything you weren't sure about: borderline changes you chose not to emit, trimmed testdata, golden diffs. -->
51 changes: 51 additions & 0 deletions .github/workflows/CI_dco.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Every commit carries a DCO sign-off (`git commit -s`) by its author:
# a "Signed-off-by: Name <email>" line whose email is the commit author's.
# Merge commits are skipped. See CONTRIBUTING.md#sign-your-commits-dco.
name: CI_dco

on:
pull_request:
merge_group:
workflow_dispatch:

permissions:
contents: read

# A new push cancels the run it supersedes.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
dco:
name: commits are signed off
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0

- name: check sign-offs
env:
PR_BASE: ${{ github.event.pull_request.base.sha }}
PR_HEAD: ${{ github.event.pull_request.head.sha }}
MQ_BASE: ${{ github.event.merge_group.base_sha }}
MQ_HEAD: ${{ github.event.merge_group.head_sha }}
run: |
base="${PR_BASE:-$MQ_BASE}"; head="${PR_HEAD:-$MQ_HEAD}"
if [ -z "$base" ]; then
# A manual run checks the last commit only.
base="HEAD~1"; head="HEAD"
fi
bad=0
for sha in $(git rev-list --no-merges "$base..$head"); do
email=$(git log -1 --format='%ae' "$sha")
if git log -1 --format='%(trailers:key=Signed-off-by,valueonly)' "$sha" | grep -qiF "<$email>"; then
echo "ok ${sha:0:12} $(git log -1 --format=%s "$sha")"
else
echo "::error::commit ${sha:0:12} ($(git log -1 --format=%s "$sha")) has no Signed-off-by for its author. Fix: git rebase --signoff $base, then push."
bad=1
fi
done
exit $bad
99 changes: 99 additions & 0 deletions .github/workflows/CI_go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# The plugins build, are formatted and vetted, and their tests pass with the race
# detector. Two guards keep plugins self-contained:
# - imports: only this module, the standard library and the approved dependencies;
# - network: net/http only in the fetch layer (fetch/, kit/, adapter/).
# Until the Go code lands there is no go.mod, and every step after the first is skipped
# with a notice, so the check passes.
name: CI_go

on:
pull_request:
merge_group:
workflow_dispatch:

permissions:
contents: read

# A new push cancels the run it supersedes.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
go:
name: go build, vet, gofmt, test
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v6

- name: is there Go code yet
id: go
run: |
if [ -f go.mod ]; then
echo "present=true" >> "$GITHUB_OUTPUT"
else
echo "::notice::No go.mod yet: no Go packages to check. CI_go passes until the plugin code lands."
echo "present=false" >> "$GITHUB_OUTPUT"
fi

- uses: actions/setup-go@v7
if: steps.go.outputs.present == 'true'
with:
go-version-file: go.mod
cache-dependency-path: go.sum

- name: go.mod and go.sum are tidy
if: steps.go.outputs.present == 'true'
run: |
go mod tidy
if ! git diff --exit-code -- go.mod go.sum; then
echo "::error file=go.mod::go.mod/go.sum are not tidy. Run 'go mod tidy' and commit the result."
exit 1
fi

- name: go build
if: steps.go.outputs.present == 'true'
run: go build ./...

- name: gofmt
if: steps.go.outputs.present == 'true'
run: |
unformatted=$(gofmt -l .)
if [ -n "$unformatted" ]; then
for f in $unformatted; do echo "::error file=$f::not gofmt-formatted. Run 'gofmt -w .'."; done
exit 1
fi

- name: go vet
if: steps.go.outputs.present == 'true'
run: go vet ./...

# An allowlist, so a plugin can't pull in a database driver, a cloud SDK or
# anything private. Adding a dependency means adding it here, in review.
- name: imports are this module, the standard library or approved
if: steps.go.outputs.present == 'true'
run: |
module=$(go list -m)
allowed="^($module(/|$)|gopkg\.in/yaml\.v3$)"
others=$(go list -deps -test -f '{{if not .Standard}}{{.ImportPath}}{{end}}' ./... | sed 's/ \[.*//' | sort -u | grep -vE "$allowed" || true)
if [ -n "$others" ]; then
echo "::error::imports outside the allowlist (CI_go.yml):"; echo "$others"; exit 1
fi

# Plugins fetch through env.Get / kit, never on their own.
- name: net/http only in the fetch layer
if: steps.go.outputs.present == 'true'
run: |
module=$(go list -m)
bad=$(go list -f '{{.ImportPath}} {{join .Imports " "}}' ./... \
| grep -E '(^| )net/http( |$)' | cut -d' ' -f1 \
| grep -vE "^$module/(fetch|kit|adapter)(/|$)" || true)
if [ -n "$bad" ]; then
echo "::error::these packages import net/http; fetch through env.Get or kit instead:"; echo "$bad"; exit 1
fi

# -race: the fetcher and the tests' HTTP servers run on other goroutines.
- name: go test
if: steps.go.outputs.present == 'true'
run: go test -race -count=1 ./...
79 changes: 79 additions & 0 deletions .github/workflows/CI_leak_guard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# This repo is public: nothing private may land in it.
# - gitleaks (pinned release, checksum-verified) looks for secrets in the PR's commits,
# and in the whole history on the weekly run.
# - scripts/leak_guard.py looks for known internal names. The list is committed only as
# SHA-256 hashes (scripts/banned-terms.sha256); a hit prints file:line, never the term.
# Runs on every PR and weekly (a new term added to the list then covers old files too).
name: CI_leak_guard

on:
pull_request:
merge_group:
schedule:
- cron: "41 4 * * 1"
workflow_dispatch:

permissions:
contents: read

# A new push cancels the run it supersedes.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
GITLEAKS_VERSION: 8.30.1
GITLEAKS_SHA256: 551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb

jobs:
leak-guard:
name: secrets and internal names
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0

- name: which commits to check
id: range
env:
PR_BASE: ${{ github.event.pull_request.base.sha }}
PR_HEAD: ${{ github.event.pull_request.head.sha }}
MQ_BASE: ${{ github.event.merge_group.base_sha }}
MQ_HEAD: ${{ github.event.merge_group.head_sha }}
run: |
# PRs and the merge queue: only what they add. Schedule and manual runs: everything.
base="${PR_BASE:-$MQ_BASE}"; head="${PR_HEAD:-$MQ_HEAD}"
echo "base=$base" >> "$GITHUB_OUTPUT"
echo "head=$head" >> "$GITHUB_OUTPUT"
if [ -n "$base" ]; then echo "checking $base..$head"; else echo "checking the whole repo"; fi

- name: install gitleaks ${{ env.GITLEAKS_VERSION }}
run: |
tarball="gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz"
curl -fsSL -o "$RUNNER_TEMP/$tarball" "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/${tarball}"
echo "${GITLEAKS_SHA256} $RUNNER_TEMP/$tarball" | sha256sum -c -
tar -xzf "$RUNNER_TEMP/$tarball" -C "$RUNNER_TEMP" gitleaks

- name: gitleaks
env:
BASE: ${{ steps.range.outputs.base }}
HEAD: ${{ steps.range.outputs.head }}
run: |
if [ -n "$BASE" ]; then
"$RUNNER_TEMP/gitleaks" git --no-banner --redact --verbose --log-opts="$BASE..$HEAD" .
else
"$RUNNER_TEMP/gitleaks" git --no-banner --redact --verbose .
fi

- name: internal names (hashed)
env:
BASE: ${{ steps.range.outputs.base }}
HEAD: ${{ steps.range.outputs.head }}
run: |
if [ -n "$BASE" ]; then
python3 scripts/leak_guard.py --diff "$BASE" "$HEAD"
else
python3 scripts/leak_guard.py --all
fi
64 changes: 64 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# AGENTS.md

Rules for AI coding agents (and humans) working in this repo. `CLAUDE.md` imports this file.

## Rule 1: every new or changed plugin goes in `docs/plugins.md`

**If you add a plugin, add its row to [`docs/plugins.md`](docs/plugins.md) in the same PR. If you change a plugin's id, provider, source, what it watches, format plugin or status, update its row in the same PR. If you remove one, remove its row.**

The list of supported APIs on docs.patch-it.dev is generated from that file, so a plugin missing from it doesn't exist as far as users can tell. No CI check enforces this: you are the check. Before you finish, compare the registered plugins with the table and say in the PR that you did.

Keep the table between the `<!-- plugins:start -->` and `<!-- plugins:end -->` markers a plain Markdown table, one row per plugin, absolute links only (the docs site copies it verbatim).

## Rule 2: this repo is public

Everything you write here is public forever, including commit messages, branch names, PR titles and descriptions, and test data. Never write:

- credentials, tokens, keys, or values from any `.env`;
- internal hostnames, internal service names, or links to private repos, dashboards or tickets;
- names or emails of customers, users or leads, or anything about sales or outreach;
- links to AI chat or agent sessions.

Refer to the service that runs these plugins as "patch-it's hosted ingestion service". `CI_leak_guard` checks every PR for secrets and for a list of known internal names (committed only as SHA-256 hashes), but it can't catch everything.

## Rules for plugin code

- **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.
- **One pinned drop test** per plugin: a realistic input that must produce no event.
- **`providers/<api>.md`** for every provider, copied from `providers/_template.md`, including **Why this source**: the link, the date it was checked, why it's the best source, the alternatives not used, and a short quote.
- **No source, no event**: every event carries the source URL and a quote.
- Don't edit golden files to make a test pass without explaining in the PR why the new output is right.

## Commands

```sh
go build ./...
go vet ./...
gofmt -l . # must print nothing
go test -race ./...
python3 scripts/leak_guard.py --all # the internal-names check over every tracked file
```

Until the plugin code lands there is no `go.mod`, and `CI_go` passes with a notice.

## Layout

```
docs/plugins.md the list of supported plugins (Rule 1)
docs/ contributor docs
providers/<api>.md one page per provider
scripts/leak_guard.py the hashed internal-names check
.github/ CODEOWNERS, PR template, workflows (CI_go, CI_dco, CI_leak_guard)
```

When the code lands (Go module `github.com/patch-it-dev/patch-it-plugins`): `plugin/` (the interface and registry), `plugins/<format>/` (one package per format plugin, `plugins/all` imports every one), `event/` (the change-event types from [patch-it's contract](https://github.com/patch-it-dev/patch-it/tree/main/docs/contract)), `fetch/`, `kit/`, `diff/`, `normalize/`, `hint/`, `retire/`, `sdkguide/`, `adapter/`, `contract/fixtures/`.

## Commits and PRs

- Sign off every commit: `git commit -s` (DCO; `CI_dco` checks it).
- Subjects short, lowercase, imperative: `add the foo plugin`.
- One plugin or fix per PR; fill in every checkbox of the PR template, including "added to docs/plugins.md".
- AI-assisted commits keep their co-author trailer.
- Never re-run, dispatch or retrigger CI to "see if it passes"; fix the cause and push.
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@AGENTS.md
42 changes: 42 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Contributing

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.

## 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.
2. **Fetch only through the environment.** Plugins get their sources from `env.Get` or the helpers in `kit/`, never from `net/http` directly, the filesystem or a database. That keeps tests offline and lets the hosted service cache, retry and rate-limit politely.
3. **Every plugin has a golden test** over a real saved copy of its source: `testdata/<file>` in, `testdata/golden/<api>.json` out. `testdata/README.md` lists each file with its URL, the date you fetched it, its license, and a short quote of the part your plugin reads. Keep openly licensed files whole; trim vendor documentation pages to what the test needs.
4. **Precision over recall.** A missed change is a bug we can fix later. A wrong change becomes a wrong pull request in someone's repo. When in doubt, don't emit.
5. **One pinned drop test per plugin**: a realistic input your plugin must *not* turn into an event (an unrelated section, a renamed heading, a non-breaking addition).
6. **Document the provider** in `providers/<api>.md`, copied from [`providers/_template.md`](providers/_template.md): what it watches, **why you chose that source** (and the alternatives you didn't), how the provider announces changes, what the plugin reads and ignores, and known gaps.
7. **Nothing private.** This repo is public. No credentials, tokens, internal hostnames or links to private repos or systems, in code, tests, commit messages or PR descriptions. CI scans every PR for secrets and for known internal names.

## Sign your commits (DCO)

We use the [Developer Certificate of Origin](https://developercertificate.org/). Sign off every commit:

```sh
git commit -s -m "add the foo plugin"
```

That adds `Signed-off-by: Your Name <you@example.com>`, matching the commit's author. `CI_dco` fails a PR with an unsigned commit. To fix one: `git commit --amend -s` (last commit) or `git rebase --signoff origin/main` (all of them), then force-push your branch.

## Pull requests

- One plugin or one fix per PR. Fill in the PR template's checklist.
- Commit subjects: short, lowercase, imperative (`add the foo plugin`, `fix stripe hint parsing`).
- Run the tests before you push (see [README](README.md#run-the-tests)).
- A maintainer listed in `.github/CODEOWNERS` reviews every PR.

## CI

| Workflow | What it checks |
|---|---|
| `CI_go` | `go mod tidy`, build, vet, gofmt, `go test -race`; plugins import only this module, the standard library and approved dependencies; `net/http` only in the fetch layer |
| `CI_dco` | Every commit in the PR is signed off by its author |
| `CI_leak_guard` | gitleaks over the PR's commits, and a check for known internal names (stored as hashes only). Also runs weekly over the whole repo |

## License

By contributing you agree that your contribution is licensed under [Apache-2.0](LICENSE).
Loading
Loading