Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
f69e14a
feat(web): import history for a Plex Home user (#3669)
Quick104 Nov 8, 2026
67d0936
fix(watchsync): import provider watches once their title reaches the …
Quick104 Nov 9, 2026
4018816
feat(watchsync): accept a finished series as plugin watched state (#3…
Quick104 Nov 9, 2026
6e2f42f
fix(web): make the collection editor's Description box look like a fi…
blurbery Nov 9, 2026
491a7a4
fix(web): drop the empty Collections page's New collection card (#3705)
blurbery Nov 9, 2026
7d1e761
test(catalog): keep plan tests independent of database statistics (#3…
Rhainland Nov 9, 2026
26062f8
fix(collections): require a rule before a smart collection previews o…
blurbery Nov 9, 2026
b4944a4
fix(tonemap): ship Intel's legacy OpenCL runtime and log the probe re…
blurbery Nov 9, 2026
752754b
docs(readme): centre the Macroscope banner and tidy Supporting Silo (…
blurbery Nov 9, 2026
2866e95
fix(requests): omit download progress that has no report time (#3717)
Rhainland Nov 9, 2026
13aa54f
fix(playback): convert copied ADTS AAC for fMP4 HLS segments (#3677)
blurbery Nov 9, 2026
405439a
fix(notifications): count characters for every Discord embed limit (#…
blurbery Nov 9, 2026
6685aab
fix(apiv2): list null in the enum of nullable request members (#3534)
blurbery Nov 9, 2026
220ac9e
fix(notifications): keep admin test pushes on the caller's account (#…
Rhainland Nov 9, 2026
36e43f6
fix(jellycompat): give a Stopped report's confirmed stop time to reac…
blurbery Nov 9, 2026
40b1924
fix(web): show a removed star rating straight away (#3533)
blurbery Nov 9, 2026
f6507d3
ci: cache the pinned actionlint and shellcheck archives (#3659)
blurbery Nov 9, 2026
35b666e
fix(jellycompat): report audio channel layout and bitrates in bits pe…
blurbery Nov 9, 2026
98be900
fix(web): offer home removal on the dedicated Continue Watching page …
Rhainland Nov 9, 2026
1eaafc4
test(web): wait for the Watch Party fallback call before checking it …
blurbery Nov 9, 2026
07d2428
fix(metadata): report a failed Match Item folder lookup as a server e…
Rhainland Nov 9, 2026
347c31e
fix(web): show a collection's backdrop and description on its page (#…
blurbery Nov 9, 2026
f3259cd
fix(home): leave rows with nothing to show out of the v2 section list…
Rhainland Nov 9, 2026
34014d2
fix(metadata): clear the old match's values when a match is corrected…
Rhainland Nov 9, 2026
b777240
feat(web): group the dashboard Nodes card by node group (#3623)
Rhainland Nov 9, 2026
c584557
feat(sections): add a Show choice of both, movies or TV shows to the …
blurbery Nov 9, 2026
b3b25cc
fix(auth): take forwarded headers for built links only from trusted p…
blurbery Nov 9, 2026
451cba6
fix(profiles): hide profile actions an account at its limit can't use…
blurbery Nov 9, 2026
da60356
fix(plugins): show a refused automatic plugin update in web admin (#3…
Rhainland Nov 9, 2026
df5f496
fix(playback): break the remux response when the source stops mid-tit…
blurbery Nov 9, 2026
99ac69e
fix(jellycompat): compare profile bitrate limits in bits per second (…
blurbery Nov 9, 2026
eb80c9c
fix(notifications): key email settings by account and profile (#3688)
blurbery Nov 9, 2026
8701691
fix(apiv2): mark the unsaved dashboard layout members nullable (#3584)
blurbery Nov 9, 2026
4ec2a5c
fix(requests): complete a season request only once its seasons are in…
blurbery Nov 9, 2026
92419c8
fix(historyimport): import very large histories in bounded memory (#3…
Rhainland Nov 9, 2026
37aa92a
fix(subtitles): show added subtitles to people already watching (#2610)
Rhainland Nov 9, 2026
30f5079
ci: move feature requests to Discussions and close out-of-policy pull…
Quick104 Nov 9, 2026
8487cd7
feat(metadata): lock edited season and episode fields (#3588)
Rhainland Nov 9, 2026
ea6e664
fix(playback): reopen a progressive remux at the playhead instead of …
blurbery Nov 9, 2026
7695787
fix(collections): let a server smart collection draw from every libra…
blurbery Nov 9, 2026
65d1232
fix(watchsync): don't import a provider's copy of a play Silo recorde…
rangoDJ Nov 9, 2026
84dbfe1
fix(search): support sessions without Redis (#3699)
7487 Nov 9, 2026
5f6223e
perf(search): sweep in-memory search sessions at most once a minute (…
Quick104 Nov 9, 2026
35c3634
refactor(search): split the session store into Redis and in-memory st…
Quick104 Nov 9, 2026
c727c26
feat(web): give a collection page the homepage hero's look (#3734)
Quick104 Nov 9, 2026
f94b196
fix(tasks): enforce a scheduled trigger's max runtime (#3432)
Rhainland Nov 9, 2026
2a554c3
fix(collections): refresh smart collection counts after a scan (#3707)
blurbery Nov 9, 2026
df9f550
fix(access): let the primary profile inherit its account's libraries …
Quick104 Nov 9, 2026
7862009
feat(settings): add a per-profile app language setting (#3723)
Quick104 Nov 10, 2026
191dbc5
feat(sections): send title keys for server-written section titles (#3…
Quick104 Nov 10, 2026
002ee3d
feat(sections): send title keys on admin sections and default titles …
Quick104 Nov 10, 2026
c9074d9
feat(sections): send title keys for recommendation rows and the old t…
Quick104 Nov 10, 2026
1b77050
feat(web): apply the app language and format through it (#3725)
Quick104 Nov 10, 2026
dd038e5
feat(web): load the shared translation catalog and route text through…
Quick104 Nov 10, 2026
f5d5e68
feat(web): translate v2 problem details (#3894)
Quick104 Nov 10, 2026
4216539
feat(web): translate server-written section titles (#3898)
Quick104 Nov 10, 2026
9e1b72b
feat(web): translate the app shell, sign-in and setup wizard (#3899)
Quick104 Nov 10, 2026
410117c
feat(web): translate the home, library, detail, search and calendar s…
Quick104 Nov 10, 2026
63ba043
feat(web): translate the player, reader and audiobook screens (#3901)
Quick104 Nov 10, 2026
0e943cf
feat(web): translate profiles, settings, requests, Watch Together, co…
Quick104 Nov 10, 2026
c1d7636
perf(web): load admin text in its own catalog chunk (#3903)
Quick104 Nov 10, 2026
c3c21a1
feat(web): translate the admin library and media pages (#3904)
Quick104 Nov 10, 2026
4bda507
feat(web): translate the admin user, access and session pages (#3905)
Quick104 Nov 10, 2026
96b7cc6
feat(web): translate the admin shell, operations pages, settings, bac…
Quick104 Nov 10, 2026
42f22e4
feat(web): translate the shared helpers, and write possessives as who…
Quick104 Nov 10, 2026
26def12
fix(web): clear this browser's language override when the picker save…
Quick104 Nov 10, 2026
56feac0
feat(web): mirror the layout right to left (#3909)
Quick104 Nov 10, 2026
22fe6bf
feat(web): offer shipped languages and show decimals in the app's num…
Quick104 Nov 10, 2026
86d36a3
fix(i18n): web layout fixes from the seven-language QA (#3911)
Quick104 Nov 10, 2026
87782a6
fix(i18n): print Arabic numbers in one set of digits and keep episode…
Quick104 Nov 10, 2026
30a6abd
docs(i18n): record how clients translate their interface (#3913)
Quick104 Nov 10, 2026
99505d4
test(watchsync): wait for the admission lock until the test deadline …
Quick104 Nov 10, 2026
dc69fef
ci(dbpins): run the query-budget pins and database contracts in one p…
Quick104 Nov 10, 2026
c202ead
test(playback): answer the filter listing in the handlers' fake FFmpe…
Quick104 Nov 10, 2026
261d7fe
test(playback): pin MPEG-TS copy restarts in a unit test, not a timed…
Quick104 Nov 10, 2026
48db6bc
ci(web): run the web checks in one job and the web tests in two shard…
Quick104 Nov 10, 2026
6c1f4c9
ci(go): run go vet and the contract checks beside Go lint (#3931)
Quick104 Nov 10, 2026
51b1e0a
ci(dbpins): give each package its own copy of the test database (#3927)
Quick104 Nov 10, 2026
a494277
docs(agents): tell contributor agents to treat the code as someone el…
Quick104 Nov 11, 2026
5159df6
docs(agents): remove rules AGENTS.md repeats from CONTRIBUTING.md (#3…
Quick104 Nov 11, 2026
8bb3ab3
fix(web): show a loading state instead of blank admin text while it l…
Quick104 Nov 11, 2026
75e10d3
fix(backup): keep home section title keys through backup and restore …
Quick104 Nov 11, 2026
4a0aba6
feat(i18n): send title keys for seasonal rows, Discover rows and reci…
Quick104 Nov 11, 2026
4a9e527
fix(web): translate the text the localization audit found still in En…
Quick104 Nov 11, 2026
7d969e7
Merge commit from fork
Quick104 Nov 11, 2026
06057f7
fix(collections): sign personal collection posters only from the coll…
Quick104 Nov 11, 2026
34e2b7b
fix(jellycompat): keep play session IDs out of logs (#3964)
Quick104 Nov 11, 2026
8af4526
fix(collections): answer a busy artwork upload with 503, not 500 (#3973)
Quick104 Nov 11, 2026
7a0a659
perf(plugins): stop plugin processes that have been idle (#3960)
blurbery Nov 11, 2026
48748d9
perf(plugins): cap plugin processes at four CPUs (#3959)
blurbery Nov 11, 2026
2298110
fix(downloads): hide account-level downloads of titles a profile may …
Quick104 Nov 11, 2026
b4807da
perf(catalog): read a page's episodes in one query for Jellyfin episo…
blurbery Nov 11, 2026
8919a3c
perf(catalog): drop expired query cache entries (#3952)
blurbery Nov 11, 2026
a9c7580
ci: stop calling the v1 migration gates from the trusted tools (#3199)
Quick104 Nov 11, 2026
7bb66f9
feat(api)!: retire /api/v1 behind a 410 tombstone (#3200)
Quick104 Nov 11, 2026
0e95e55
perf(catalog): check a Jellyfin episode page's library membership in …
Quick104 Nov 11, 2026
1908856
refactor(playback): classify planner refusals beside the planner (#3946)
Quick104 Nov 11, 2026
0c30e54
fix(audiobooks): let only the acting admin open Audiobookshelf RSS fe…
Quick104 Nov 11, 2026
c00d86f
fix(jellycompat): end a Jellyfin play when an administrator stops or …
Quick104 Nov 11, 2026
79cb627
fix(collections): decode a personal collection's poster before the co…
Quick104 Nov 11, 2026
1224daa
fix(webhooksync): let only the household manager manage webhook sync …
Quick104 Nov 11, 2026
10aaeaf
perf(database): cap auto-tuned shared_buffers and worker counts (#3953)
blurbery Nov 11, 2026
5d7448a
fix(auth): let only the household manager disconnect a sign-in identi…
Quick104 Nov 11, 2026
2e142f0
refactor(playback): share one alternate-version fallback between star…
Quick104 Nov 11, 2026
ab8258f
fix(playback): back off the lifecycle sweep when an end's history wri…
Quick104 Nov 11, 2026
1ba89ab
refactor(playback): choose the playback route from a candidate list (…
Quick104 Nov 11, 2026
7b3e84c
fix(api): send nosniff on every API response (#3989)
Quick104 Nov 11, 2026
ce837a1
fix(web): remove the eyebrow and slide number from the home hero (#3995)
Quick104 Nov 11, 2026
2ee1b72
perf(catalog): build the letter index in one window pass (#3994)
Quick104 Nov 11, 2026
2fd918f
merge: bring upstream main into Vio (109 commits)
Nov 12, 2026
0bdc8b9
fix(web): align the merged web tree with its tests and the v2 contract
Nov 12, 2026
9917f3d
fix(testdb): accept dbpins clone names as disposable
Nov 12, 2026
a58e1b6
fix(testdb): let the handler fixtures run on dbpins clones
Nov 12, 2026
15a61a9
fix(api): keep the fork's v2 device headers and approve upstream's br…
Nov 12, 2026
3ca7dd5
fix(web): reset the learned limit without a caller header
Nov 12, 2026
bd56a1c
test(web): expect the learned-limit reset without a caller header
Nov 12, 2026
8594ec3
test(scenariocatalog): skip the v1 scenario run after retirement
Nov 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Lint configuration and protected contract files require maintainer review.
/.golangci*.yml @Quick104
/.github/actionlint.yaml @Quick104
/.github/workflows/reusable-contribution-gate.yml @Quick104
/.shellcheckrc @Quick104
/web/eslint.config.js @Quick104
/web/eslint-suppressions.json @Quick104
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
name: Feature request
description: Suggest an improvement or something Silo doesn't do yet
title: "[feature] "
labels: ["enhancement", "feature-request"]
body:
- type: markdown
attributes:
value: |
Silo is pre-1.0 and focused on correctness and polish. A request is most useful when it explains the problem you hit, with a concrete example, rather than prescribing a solution. One request per issue.
Silo is pre-1.0 and focused on correctness and polish. An idea is most useful when it explains the problem you hit, with a concrete example, rather than prescribing a solution. One idea per discussion. If someone already posted it, upvote it and add your case there instead.

Silo will not accept Live TV, OTA/DVB tuners, IPTV, EPG/XMLTV guides, DVR, or `.strm` remote-stream files; [Project non-goals](https://github.com/Silo-Server/silo-server/blob/main/docs/non-goals.md) explains why. Requests that only concern the Apple or Android apps belong in [silo-apple](https://github.com/Silo-Server/silo-apple/issues/new/choose) or [silo-android](https://github.com/Silo-Server/silo-android/issues/new/choose).
Maintainers turn ideas they plan to build into issues. An idea here is not a commitment, and a pull request for a feature needs an issue a maintainer has labeled `accepted`.

Silo will not accept Live TV, OTA/DVB tuners, IPTV, EPG/XMLTV guides, DVR, or `.strm` remote-stream files; [Project non-goals](https://github.com/Silo-Server/silo-server/blob/main/docs/non-goals.md) explains why. Ideas that only concern one app belong in that app's Ideas: [Apple](https://github.com/Silo-Server/silo-apple/discussions/categories/ideas), [Android](https://github.com/Silo-Server/silo-android/discussions/categories/ideas), or [Roku](https://github.com/Silo-Server/silo-roku/discussions/categories/ideas).
- type: textarea
id: problem
attributes:
Expand Down Expand Up @@ -78,15 +76,15 @@ body:
id: ai-review
attributes:
label: Independent or adversarial review
description: Summarize the scope, method, findings, and resolutions, or enter "n/a" when this issue does not require independent or adversarial review.
description: Summarize the scope, method, findings, and resolutions, or enter "n/a" when this idea does not require independent or adversarial review.
validations:
required: true
- type: checkboxes
id: confirmations
attributes:
label: Confirmations
options:
- label: I searched open and closed issues, including ones closed as not planned, and this is not already requested
- label: I searched Ideas and the issue tracker, including issues closed as not planned, and this is not already proposed
required: true
- label: This is not one of Silo's non-goals
required: true
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Suggest a feature
url: https://github.com/Silo-Server/silo-server/discussions/categories/ideas
about: Post feature ideas in Discussions under Ideas, or upvote an existing one. Issues are for bugs.
- name: Questions and setup help
url: https://discord.gg/siloserver
about: Ask how to set up or use Silo in the Silo Discord.
Expand Down
3 changes: 2 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ another repository. Delete the line when the PR only partly addresses an issue.
Related issue: #NNN
<!-- An epic, sub-issue, or partly addressed issue this work serves and that should
stay open, or "N/A". An open issue is not required — the Problem section below must
stand on its own. -->
stand on its own — except for a feat PR from someone without triage or write access,
which must link an issue in this repository labeled `accepted`. -->
Validation tasks: #NNN C1
<!-- Until 1.0 ships: v1.0 board tasks and cases this change unblocks or changes
(see "1.0 validation" in AGENTS.md), e.g. "unblocks #1144 C3; changes #1200 C1".
Expand Down
19 changes: 11 additions & 8 deletions .github/actions/ci-tools/go-checks.mk
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
# The Go jobs' lanes. CI runs this file from the trusted CI tools checkout in
# the repository root: Go lint runs lint and then contracts, and Go test runs
# tests, each job on its own runner.
# the repository root: Go lint runs lint, Go vet runs vet and then contracts,
# and Go test runs tests, each job on its own runner.
# LINT_BASE_REF, LINT_BASE_MODE, CONTRACT_BASE_REF, and TEST_GOFLAGS come from
# the workflow.
.PHONY: lint contracts tests test-dependencies
.PHONY: lint vet contracts tests test-dependencies

# Router recovery must hold over the whole tree, including inherited lines.
lint:
@unformatted="$$(gofmt -l .)"; if [ -n "$$unformatted" ]; then echo "::error::gofmt is required on:"; echo "$$unformatted"; exit 1; fi
go vet ./...
BASE_REF="$${LINT_BASE_REF}" LINT_CHANGED_CI=1 LINT_CHANGED_BASE_MODE="$${LINT_BASE_MODE}" CI_OPERATION=lint bash .ci-tools/scripts/lint-changed.sh
$(MAKE) -f Makefile lint-router-recovery

# The whole tree, so a change that breaks vet in a package it did not touch
# still fails; lint-changed reports only changed lines.
vet:
go vet ./...

# Package assertions belong to the tests lane; these check generated artifacts.
contracts:
$(MAKE) -j1 -f Makefile verify-settings-bindings verify-playback-fixtures verify-route-inventory
$(MAKE) -j1 -f Makefile verify-migration-ledger verify-apiv2-openapi CONTRACT_GO_TESTS=0
$(MAKE) -j1 -f Makefile verify-apiv2-openapi CONTRACT_GO_TESTS=0
git fetch --no-tags origin "+refs/heads/$${CONTRACT_BASE_REF}:refs/remotes/origin/$${CONTRACT_BASE_REF}"
$(MAKE) -j1 -f Makefile verify-v1-route-freeze BASE_REF="origin/$${CONTRACT_BASE_REF}"
$(MAKE) -j1 -f Makefile verify-apiv2-contract CONTRACT_GO_TESTS=0 BASE_REF="origin/$${CONTRACT_BASE_REF}"

# Go's test cache cannot see files a test's child process reads, so these
Expand All @@ -26,7 +29,7 @@ contracts:
UNCACHED := cmd/silo internal/jellycompat internal/pluginhost internal/plugins scripts/ci/sizeratchet scripts/ci/migrationcheck
# subprocess-manifest: scripts/ci/subprocess-tests.json
# deferred: no recorded occurrence; retain UNCACHED and the subprocess guard.
IMMUTABLE := internal/contractledger internal/contractspec internal/debugserver
IMMUTABLE := internal/contractspec internal/debugserver
test-dependencies:
@variants="$$(go list -deps -test -f '{{.ImportPath}}|{{.ForTest}}' ./internal/auth/ ./internal/api/handlers/)" || exit $$?; \
[ -n "$$variants" ] || { echo "::error::test dependency metadata is empty"; exit 1; }; \
Expand All @@ -40,7 +43,7 @@ test-dependencies:

tests: test-dependencies
GOFLAGS="$${TEST_GOFLAGS}" $(MAKE) -f Makefile test-go
@want="$$(printf '%s\n' $(UNCACHED) $(IMMUTABLE) | sort -u)"; \
@want="$$(printf '%s\n' $(wildcard $(UNCACHED) $(IMMUTABLE)) | sort -u)"; \
got="$$(git grep -l -E '(exec\.Command(Context)?\(([^,]+, )?"(go|git|node)"|LookPath\("(go|git|node)"\))' -- '*_test.go' | sed 's@/[^/]*$$@@' | sort -u)"; \
if [ "$$want" != "$$got" ]; then echo "::error::packages whose tests start go, git, or node changed"; echo "want: $$want"; echo "got: $$got"; exit 1; fi
go test -count=1 $(addprefix ./,$(UNCACHED))
9 changes: 4 additions & 5 deletions .github/actions/ci-tools/select-jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
import sys


GO_JOBS = ("go-lint", "go-test", "go-integration", "go-db-pins", "go-db-auth")
GO_JOBS = ("go-lint", "go-vet", "go-test", "go-integration", "go-db-pins", "go-db-auth")
WEB_JOBS = ("web", "web-test")
# Run on every event regardless of what the diff touched.
ALWAYS_JOBS = ("repo-checks",)
SHA = re.compile(r"[0-9a-fA-F]{40}\Z")
# These are embedded by contracts/api/v2 and consumed by the Go ledger,
# scenario and compatibility gates. Web generation consumes openapi/fixtures.
# These are embedded by contracts/api/v2 and consumed by the Go compatibility
# gate. Web generation consumes openapi/fixtures.
GO_ONLY_CONTRACTS = frozenset("contracts/api/v2/" + name for name in (
"migration.json", "migration.schema.json", "offline-routes.txt",
"breaking-approvals.json", "breaking-approvals.schema.json",
))

Expand All @@ -36,7 +35,7 @@ def classify(paths):
or any(ord(char) < 32 for char in path)):
return all_jobs("unrecognized path")
if (path == ".github/evidence.yml"
or (path.startswith(".github/ISSUE_TEMPLATE/") and path.endswith((".yml", ".yaml", ".md")))
or (path.startswith((".github/ISSUE_TEMPLATE/", ".github/DISCUSSION_TEMPLATE/")) and path.endswith((".yml", ".yaml", ".md")))
or (path.endswith(".md") and path.startswith((".github/", "scripts/", "cmd/")))):
continue
if (path in GO_ONLY_CONTRACTS
Expand Down
6 changes: 2 additions & 4 deletions .github/actions/ci-tools/test_select_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_understood_inputs_choose_only_required_groups(self):
("web/public/vendor/pdfjs/pdf.worker.mjs", False, True),
("web/public/vendor/pdfjs/standard_fonts_other/font.pfb", False, True),
("internal/catalog/history.go", True, False),
("internal/scenariocatalog/testdata/fixture.json", True, False),
("internal/routeinventory/testdata/fixture.json", True, False),
("internal/policy/vendor/README.md", True, False),
("internal/userdb/testdata/schema.sql", True, False),
("internal/ebookconvert/mobitool.wasm", True, False),
Expand All @@ -125,13 +125,11 @@ def test_understood_inputs_choose_only_required_groups(self):
("cmd/silo/main.go", True, False),
("scripts/ci/db-pins.txt", True, False),
("scripts/ci/db-contracts.txt", True, False),
("contracts/api/v2/migration.json", True, False),
("contracts/api/v2/migration.schema.json", True, False),
("contracts/api/v2/offline-routes.txt", True, False),
("contracts/api/v2/breaking-approvals.json", True, False),
(".github/actions/README.md", False, False),
(".github/evidence.yml", False, False),
(".github/ISSUE_TEMPLATE/bug-report.yml", False, False),
(".github/DISCUSSION_TEMPLATE/ideas.yml", False, False),
]
for number, (path, go, web) in enumerate(cases):
with self.subTest(path=path):
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/contribution-gate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Contribution gate

# Closes pull requests that fall outside the policy in CONTRIBUTING.md. The rules
# live in reusable-contribution-gate.yml, which the client repositories call too.

on:
pull_request_target:
types: [opened, reopened]

permissions: {}

concurrency:
group: contribution-gate-${{ github.event.pull_request.number }}

jobs:
gate:
permissions:
issues: read
pull-requests: write
uses: ./.github/workflows/reusable-contribution-gate.yml
138 changes: 138 additions & 0 deletions .github/workflows/reusable-contribution-gate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: Contribution gate (reusable)

# Enforces the Silo pull request policy. silo-server, silo-apple, silo-android,
# and silo-roku each call this from their own contribution-gate.yml on
# pull_request_target, so it acts on the calling repository:
#
# 1. Pull requests are open to people who have had one merged in a Silo-Server
# repository. Other pull requests are closed without review.
# 2. A feature pull request (title starts with `feat`) from someone without
# triage or write access must link an issue in the calling repository that
# a maintainer labeled `accepted`.
#
# Maintainers (triage access or higher) and bots are exempt. A maintainer lets
# a closed pull request through by reopening it, which adds the `invited` label;
# a pull request with that label is never closed by this workflow.
#
# pull_request_target runs with a write token on fork pull requests. That is safe
# here only because this job never checks out or runs code from the pull
# request. Keep it that way, and never interpolate pull request fields into the
# script with ${{ }}; read them from the event payload.

on:
workflow_call:
inputs:
contributing_url:
description: Page that explains the pull request policy. Defaults to the calling repository's CONTRIBUTING.md.
required: false
type: string
default: ""

jobs:
gate:
if: github.event.pull_request.user.type != 'Bot'
runs-on: ubuntu-latest
permissions:
issues: read
pull-requests: write
steps:
- name: Apply contribution policy
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
CONTRIBUTING_URL: ${{ inputs.contributing_url }}
with:
script: |
const { owner, repo } = context.repo;
const pr = context.payload.pull_request;
const author = pr.user.login;
const INVITED = "invited";
const ACCEPTED = "accepted";
const contributing = process.env.CONTRIBUTING_URL || `https://github.com/${owner}/${repo}/blob/HEAD/CONTRIBUTING.md`;
const ideas = `https://github.com/${owner}/${repo}/discussions/categories/ideas`;

// Triage counts, so org members can be exempted without write access.
async function isMaintainer(username) {
try {
const { data } = await github.rest.repos.getCollaboratorPermissionLevel({ owner, repo, username });
return ["admin", "maintain", "write", "triage"].includes(data.role_name);
} catch (error) {
if (error.status === 404) return false;
throw error;
}
}

async function close(reason) {
await github.rest.issues.createComment({ owner, repo, issue_number: pr.number, body: reason });
await github.rest.pulls.update({ owner, repo, pull_number: pr.number, state: "closed" });
}

if (pr.labels.some((label) => label.name === INVITED)) {
core.info(`#${pr.number} has the ${INVITED} label; skipping.`);
return;
}

if (context.payload.action === "reopened") {
const sender = context.payload.sender.login;
if (sender !== author && (await isMaintainer(sender))) {
await github.rest.issues.addLabels({ owner, repo, issue_number: pr.number, labels: [INVITED] });
core.info(`${sender} reopened #${pr.number}; marked it ${INVITED}.`);
return;
}
}

// Decide by repository role, not author_association: MEMBER and
// COLLABORATOR include read-only access, and CONTRIBUTOR only means a
// commit on the default branch, not a merged pull request.
if (await isMaintainer(author)) {
core.info(`${author} is a maintainer; skipping.`);
return;
}

const { data: merged } = await github.rest.search.issuesAndPullRequests({
q: `org:${owner} is:pr is:merged author:${author}`,
per_page: 1,
});
if (merged.incomplete_results) {
throw new Error(`Search for ${author}'s merged pull requests timed out; leaving #${pr.number} open.`);
}
if (merged.total_count === 0) {
core.info(`${author} has no merged pull request in ${owner}; closing #${pr.number}.`);
await close([
"Thanks for the pull request. Silo takes pull requests from people who have had one merged in a Silo repository, or whom a maintainer has asked for one, so this one is closed without review. That isn't a judgment of the work. If a maintainer asked you for it, they will reopen it.",
"",
`If the problem still matters, open an issue for it and link this pull request; a maintainer may reopen it or use the code as a reference. Feature ideas go in [Discussions → Ideas](${ideas}). [The contributing guide](${contributing}) explains why.`,
].join("\n"));
return;
}

if (!/^feat(\([^)]*\))?!?:/i.test(pr.title)) {
core.info(`#${pr.number} is not a feature pull request; nothing to check.`);
return;
}

// Issues in this repository that the description references as #N,
// owner/repo#N, or a full issue URL, outside HTML comments (the pull
// request template's comments carry example issue numbers).
const repoRef = `${owner}/${repo}`.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
const refPattern = new RegExp(
`(?:https://github\\.com/${repoRef}/issues/|(?<![\\w/])${repoRef}#|(?<![\\w/#])#)(\\d+)\\b`,
"gi",
);
const body = (pr.body || "").replace(/<!--[\s\S]*?-->/g, "");
const referenced = new Set([...body.matchAll(refPattern)].map((match) => Number(match[1])));

const acceptedIssues = await github.paginate(github.rest.issues.listForRepo, {
owner, repo, labels: ACCEPTED, state: "all", per_page: 100,
});
const linked = acceptedIssues.find((issue) => !issue.pull_request && referenced.has(issue.number));
if (linked) {
core.info(`#${pr.number} links accepted issue #${linked.number}.`);
return;
}

core.info(`#${pr.number} is a feature pull request without an accepted issue; closing.`);
await close([
`Thanks for the pull request. A feature pull request needs a linked issue in this repository that a maintainer has labeled \`${ACCEPTED}\`, and this one doesn't link one, so it is closed without review.`,
"",
`Propose the feature in [Discussions → Ideas](${ideas}), or ask on an existing issue. Once an issue in this repository carries the \`${ACCEPTED}\` label, link it in the description (for example \`Closes #123\`) of a new pull request, or ask a maintainer to reopen this one. [The contributing guide](${contributing}) has the details.`,
].join("\n"));
Loading
Loading