-
Notifications
You must be signed in to change notification settings - Fork 17
feat(/w3c/update): add endpoint to trigger groups data refresh #505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
14aa77f
feat(w3c): auto-refresh groups list every 24 hours
marcoscaceres 256952a
fix(w3c): guard concurrent refresh and self-heal on corrupt JSON
marcoscaceres 5f14fd3
Apply suggestions from code review
marcoscaceres c9c92b6
Apply suggestion from @Copilot
marcoscaceres e18c1fa
Apply suggestion from @Copilot
marcoscaceres edfd844
Apply suggestion from @Copilot
marcoscaceres 4c64814
Apply suggestion from @Copilot
marcoscaceres 8d47d75
Apply suggestion from @Copilot
marcoscaceres 595b1b0
Apply suggestions from code review
marcoscaceres 06a077c
fix(w3c): clean up group.ts - fix TDZ, duplicates, add retry/backoff
Copilot a85782b
Apply suggestion from @Copilot
marcoscaceres 13f33f2
Apply suggestion from @Copilot
marcoscaceres 153aa7e
Apply suggestion from @Copilot
marcoscaceres be80aca
Apply suggestion from @Copilot
marcoscaceres 1314d8a
Merge branch 'main' into feat/auto-refresh-groups
marcoscaceres 33c5e5f
fix(w3c): reloadGroups returns boolean, retry on any refresh failure
Copilot d3b6242
Merge branch 'main' into feat/auto-refresh-groups
marcoscaceres c840be6
Merge branch 'main' into feat/auto-refresh-groups
marcoscaceres 9f88197
refactor(w3c): use BackgroundTaskQueue and webhook update model
marcoscaceres b2ecc13
fix(w3c): address Sid's review feedback on group update route
marcoscaceres 4936436
fix(w3c): return 500 when groups reload fails after update
marcoscaceres 6b4947e
Merge branch 'main' into feat/auto-refresh-groups
marcoscaceres File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,14 @@ | ||
| import { Router } from "express"; | ||
| import cors from "cors"; | ||
|
|
||
| import authGithubWebhook from "../../utils/auth-github-webhook.js"; | ||
| import { env } from "../../utils/misc.js"; | ||
|
|
||
| import groupsRoute from "./group.js"; | ||
| import updateRoute from "./update.js"; | ||
|
|
||
| const w3c = Router(); | ||
| w3c.get("/groups{/:shortname}{/:type}", cors(), groupsRoute); | ||
| w3c.post("/update", authGithubWebhook(env("W3C_GROUPS_SECRET")), updateRoute); | ||
|
|
||
| export default w3c; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import path from "path"; | ||
|
|
||
| import { Request, Response } from "express"; | ||
|
|
||
| import { BackgroundTaskQueue } from "../../utils/background-task-queue.js"; | ||
|
|
||
| import { reloadGroups } from "./group.js"; | ||
|
|
||
| const workerFile = path.join(import.meta.dirname, "update.worker.js"); | ||
| const taskQueue = new BackgroundTaskQueue<typeof import("./update.worker.ts")>( | ||
| workerFile, | ||
| "w3c_groups_update", | ||
| ); | ||
|
|
||
| export default async function route(_req: Request, res: Response) { | ||
| const job = taskQueue.add(); | ||
| try { | ||
| const { updated } = await job.run(); | ||
| if (updated && !reloadGroups()) { | ||
| res.status(500); | ||
| } | ||
| } catch { | ||
| res.status(500); | ||
| } finally { | ||
| res.locals.job = job.id; | ||
| res.send(job.id); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import w3cGroupsScraper from "../../scripts/update-w3c-groups-list.js"; | ||
|
|
||
| export default async function w3cGroupsUpdate() { | ||
| try { | ||
| await w3cGroupsScraper(); | ||
| return { updated: true }; | ||
| } catch (error) { | ||
| console.error("W3C groups update failed:", error); | ||
| return { updated: false }; | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What will trigger this webhook?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's supposed to be a cron job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to this:
respec-web-services/.github/workflows/codeql-analysis.yml
Line 20 in d0a0f9e
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A cron GitHub action in this repo, that sends a request to update endpoint? Will it have same payload format we expect in
authGithubWebhook?Edit: just saw #505 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, does that sound ok?