From cd042b48eeafbc016fab8f45947cd5c878257b22 Mon Sep 17 00:00:00 2001 From: snomiao Date: Tue, 21 Jan 2025 08:39:45 +0000 Subject: [PATCH 1/6] fix(gh-action-update-task): setup workflows setup workflows --- .github/workflows/updateGithubActionTask.yaml | 47 +++++++++++++++++++ app/(dashboard)/TotalsBlock.tsx | 17 +------ app/(dashboard)/getTotalsData.tsx | 19 ++++++++ app/tasks/GithubActionUpdateTask/actions.tsx | 2 +- app/tasks/page.tsx | 2 +- .../GithubActionUpdateTask.md | 0 .../GithubActionUpdateTask.ts | 0 .../checkoutRepoOnBranch.ts | 0 .../gptWriter.ts | 0 .../test-updated-publish.yml | 0 .../updateGithubActionPrepareBranch.ts | 0 .../updateGithubActionTask.ts | 23 +++++---- 12 files changed, 82 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/updateGithubActionTask.yaml create mode 100644 app/(dashboard)/getTotalsData.tsx rename src/{2025-01-20-GithubActionUpdateTask => GithubActionUpdateTask}/GithubActionUpdateTask.md (100%) rename src/{2025-01-20-GithubActionUpdateTask => GithubActionUpdateTask}/GithubActionUpdateTask.ts (100%) rename src/{2025-01-20-GithubActionUpdateTask => GithubActionUpdateTask}/checkoutRepoOnBranch.ts (100%) rename src/{2025-01-20-GithubActionUpdateTask => GithubActionUpdateTask}/gptWriter.ts (100%) rename src/{2025-01-20-GithubActionUpdateTask => GithubActionUpdateTask}/test-updated-publish.yml (100%) rename src/{2025-01-20-GithubActionUpdateTask => GithubActionUpdateTask}/updateGithubActionPrepareBranch.ts (100%) rename src/{2025-01-20-GithubActionUpdateTask => GithubActionUpdateTask}/updateGithubActionTask.ts (90%) diff --git a/.github/workflows/updateGithubActionTask.yaml b/.github/workflows/updateGithubActionTask.yaml new file mode 100644 index 0000000..0cb3323 --- /dev/null +++ b/.github/workflows/updateGithubActionTask.yaml @@ -0,0 +1,47 @@ +name: updateGithubActionTask +on: + schedule: + - cron: "0 */2 * * *" # Runs every 2 hours + workflow_dispatch: + push: + branches: + - main + - mass-pr + paths: + - ".github/workflows/*" + - "src/*.ts" +jobs: + run_comfy_pr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + # this dont need python + # # setup comfy-cli + # - uses: actions/setup-python@v5 + # with: + # python-version: "3.x" + # - run: python -m pip install --upgrade pip + # - run: python -m venv .venv + # - run: source .venv/bin/activate + # - run: pip install comfy-cli + # Setup SSH Key for git push + - uses: webfactory/ssh-agent@v0.9.0 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + # Setup Bun + # - run: pip install setuptools + - uses: oven-sh/setup-bun@v1 + # Run Comfy-PR Worker + - run: bun i + - run: bun src/GithubActionUpdateTask/updateGithubActionTask.ts + env: + COMFY_PR_REPO: ${{ secrets.COMFY_PR_REPO }} + FORK_OWNER: "ComfyNodePRs" + FORK_PREFIX: "PR-" + GH_TOKEN_COMFY_PR: ${{ secrets.GH_TOKEN_COMFY_PR }} + MONGODB_URI: ${{ secrets.MONGODB_URI }} + SLACK_BOT_CHANNEL: ${{ secrets.SLACK_BOT_CHANNEL }} + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} + AUTH_GOOGLE_ID: ${{ secrets.AUTH_GOOGLE_ID }} + AUTH_GOOGLE_SECRET: ${{ secrets.AUTH_GOOGLE_SECRET }} + AUTH_GCLOUD_URL: https://comfy-pr.vercel.app \ No newline at end of file diff --git a/app/(dashboard)/TotalsBlock.tsx b/app/(dashboard)/TotalsBlock.tsx index 6872cb7..f787b7e 100644 --- a/app/(dashboard)/TotalsBlock.tsx +++ b/app/(dashboard)/TotalsBlock.tsx @@ -1,24 +1,9 @@ "use server"; -import { $pipeline } from "@/packages/mongodb-pipeline-ts/$pipeline"; -import { Totals } from "@/src/Totals"; import { updateComfyTotals } from "@/src/updateComfyTotals"; import { yaml } from "@/src/utils/yaml"; -import { flatten } from "flat"; import Markdown from "react-markdown"; -import { sf } from "sflow"; import { TotalsChart } from "./TotalsChart"; - -function getTotalsData() { - return sf( - $pipeline(Totals) - .match({ "totals.data": { $exists: true } }) - .set({ "totals.data.date": "$totals.mtime" }) - .replaceRoot({ newRoot: "$totals.data" }) - .aggregate(), - ) - .map((e) => flatten(e) as { date: string } & Record) - .toArray(); -} +import { getTotalsData } from "./getTotalsData"; export async function TotalsBlock() { "use server"; diff --git a/app/(dashboard)/getTotalsData.tsx b/app/(dashboard)/getTotalsData.tsx new file mode 100644 index 0000000..73a19d8 --- /dev/null +++ b/app/(dashboard)/getTotalsData.tsx @@ -0,0 +1,19 @@ +"use server"; +import { $pipeline } from "@/packages/mongodb-pipeline-ts/$pipeline"; +import { Totals } from "@/src/Totals"; +import { flatten } from "flat"; +import sf from "sflow"; + +export async function getTotalsData() { + return sf( + $pipeline(Totals) + .match({ "totals.data": { $exists: true } }) + .match({ "totals.mtime": { $gt: new Date(+new Date() - 86400e3 * 30) } }) // 1 month + .set({ "totals.data.date": "$totals.mtime" }) + .replaceRoot({ newRoot: "$totals.data" }) + .aggregate(), + ) + .map((e) => flatten(e) as { date: string } & Record) + .limit(3000) + .toArray(); +} diff --git a/app/tasks/GithubActionUpdateTask/actions.tsx b/app/tasks/GithubActionUpdateTask/actions.tsx index 44542c7..419c903 100644 --- a/app/tasks/GithubActionUpdateTask/actions.tsx +++ b/app/tasks/GithubActionUpdateTask/actions.tsx @@ -1,6 +1,6 @@ "use server"; import { getAuthUser } from "@/app/api/auth/[...nextauth]/getAuthUser"; -import { GithubActionUpdateTask } from "@/src/2025-01-20-GithubActionUpdateTask/GithubActionUpdateTask"; +import { GithubActionUpdateTask } from "@/src/GithubActionUpdateTask/GithubActionUpdateTask"; import { z } from "zod"; export async function approveGithubActionUpdateTaskAction(prevState: { ok: boolean }, formData: FormData) { diff --git a/app/tasks/page.tsx b/app/tasks/page.tsx index 0a16f1a..0441600 100644 --- a/app/tasks/page.tsx +++ b/app/tasks/page.tsx @@ -1,4 +1,4 @@ -import { GithubActionUpdateTask } from "@/src/2025-01-20-GithubActionUpdateTask/GithubActionUpdateTask"; +import { GithubActionUpdateTask } from "@/src/GithubActionUpdateTask/GithubActionUpdateTask"; import Link from "next/link"; import pProps from "p-props"; diff --git a/src/2025-01-20-GithubActionUpdateTask/GithubActionUpdateTask.md b/src/GithubActionUpdateTask/GithubActionUpdateTask.md similarity index 100% rename from src/2025-01-20-GithubActionUpdateTask/GithubActionUpdateTask.md rename to src/GithubActionUpdateTask/GithubActionUpdateTask.md diff --git a/src/2025-01-20-GithubActionUpdateTask/GithubActionUpdateTask.ts b/src/GithubActionUpdateTask/GithubActionUpdateTask.ts similarity index 100% rename from src/2025-01-20-GithubActionUpdateTask/GithubActionUpdateTask.ts rename to src/GithubActionUpdateTask/GithubActionUpdateTask.ts diff --git a/src/2025-01-20-GithubActionUpdateTask/checkoutRepoOnBranch.ts b/src/GithubActionUpdateTask/checkoutRepoOnBranch.ts similarity index 100% rename from src/2025-01-20-GithubActionUpdateTask/checkoutRepoOnBranch.ts rename to src/GithubActionUpdateTask/checkoutRepoOnBranch.ts diff --git a/src/2025-01-20-GithubActionUpdateTask/gptWriter.ts b/src/GithubActionUpdateTask/gptWriter.ts similarity index 100% rename from src/2025-01-20-GithubActionUpdateTask/gptWriter.ts rename to src/GithubActionUpdateTask/gptWriter.ts diff --git a/src/2025-01-20-GithubActionUpdateTask/test-updated-publish.yml b/src/GithubActionUpdateTask/test-updated-publish.yml similarity index 100% rename from src/2025-01-20-GithubActionUpdateTask/test-updated-publish.yml rename to src/GithubActionUpdateTask/test-updated-publish.yml diff --git a/src/2025-01-20-GithubActionUpdateTask/updateGithubActionPrepareBranch.ts b/src/GithubActionUpdateTask/updateGithubActionPrepareBranch.ts similarity index 100% rename from src/2025-01-20-GithubActionUpdateTask/updateGithubActionPrepareBranch.ts rename to src/GithubActionUpdateTask/updateGithubActionPrepareBranch.ts diff --git a/src/2025-01-20-GithubActionUpdateTask/updateGithubActionTask.ts b/src/GithubActionUpdateTask/updateGithubActionTask.ts similarity index 90% rename from src/2025-01-20-GithubActionUpdateTask/updateGithubActionTask.ts rename to src/GithubActionUpdateTask/updateGithubActionTask.ts index c5a2a2d..da4e16b 100644 --- a/src/2025-01-20-GithubActionUpdateTask/updateGithubActionTask.ts +++ b/src/GithubActionUpdateTask/updateGithubActionTask.ts @@ -30,6 +30,10 @@ if (import.meta.main) { // await updateGithubActionTask(repo); // task list importer + await updateGithubActionTaskList(repo); +} + +async function updateGithubActionTaskList(repo: string) { await sflow(CRNodes.find().project({ repo: "$repository", _id: 0 })) .log() .map(({ repo }) => String(repo)) @@ -40,16 +44,15 @@ if (import.meta.main) { // task list scanner await sflow(GithubActionUpdateTask.find({ error: { $exists: false } }).project({ repo: 1 })) .pMap( - (e) => - updateGithubActionTask(e.repo).catch(async (e) => { - const error = String(e); - await GithubActionUpdateTask.updateOne( - { repo }, - { $set: { error, updatedAt: new Date() } }, - { upsert: true }, - ); - }), - { concurrency: 3 }, + (e) => updateGithubActionTask(e.repo).catch(async (e) => { + const error = String(e); + await GithubActionUpdateTask.updateOne( + { repo }, + { $set: { error, updatedAt: new Date() } }, + { upsert: true } + ); + }), + { concurrency: 3 } ) .run(); From b084b599d48b70ad4dc6fad675cc068a754d2135 Mon Sep 17 00:00:00 2001 From: snomiao Date: Wed, 22 Jan 2025 15:04:25 +0000 Subject: [PATCH 2/6] fix(GithubActionUpdateTask): auto exit auto exit --- src/GithubActionUpdateTask/updateGithubActionTask.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/GithubActionUpdateTask/updateGithubActionTask.ts b/src/GithubActionUpdateTask/updateGithubActionTask.ts index da4e16b..2b19418 100644 --- a/src/GithubActionUpdateTask/updateGithubActionTask.ts +++ b/src/GithubActionUpdateTask/updateGithubActionTask.ts @@ -8,6 +8,7 @@ import { CRNodes } from "../CRNodes"; import { yaml } from "../utils/yaml"; import { GithubActionUpdateTask } from "./GithubActionUpdateTask"; import { updateGithubActionPrepareBranch } from "./updateGithubActionPrepareBranch"; +import {isCI} from 'is-ci' console.log({ GithubActionUpdateTask: await GithubActionUpdateTask.find().toArray() }); const path = "./templates/publish.yaml"; @@ -17,6 +18,7 @@ export const testUpdatedPublishYaml = await readFile(import.meta.dir + "/test-up export const referenceActionContentHash = sha256(referenceActionContent); if (import.meta.main) { + // const repo = "https://github.com/54rt1n/ComfyUI-DareMerge"; const repo = "https://github.com/snomiao/ComfyUI-DareMerge-test"; @@ -31,6 +33,8 @@ if (import.meta.main) { // task list importer await updateGithubActionTaskList(repo); + + if(isCI) process.exit(0) } async function updateGithubActionTaskList(repo: string) { From db964afd4cc9ef69410780ccb5305e58a71655e9 Mon Sep 17 00:00:00 2001 From: snomiao Date: Thu, 23 Jan 2025 00:07:52 +0900 Subject: [PATCH 3/6] Update test.yaml --- .github/workflows/test.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a4195e1..ed03625 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -2,7 +2,8 @@ name: Run Comfy-PR Tests. on: push: - - main + branches: + - main jobs: run_comfy_pr: runs-on: ubuntu-latest @@ -27,4 +28,4 @@ jobs: - run: docker compose up mongodb -d # Run Comfy-PR Tests - run: bun i - - run: bun test \ No newline at end of file + - run: bun test From 585162eeac860fb509901888e4076868b0eded20 Mon Sep 17 00:00:00 2001 From: snomiao Date: Sat, 25 Jan 2025 04:52:06 +0000 Subject: [PATCH 4/6] fix(upgradeGithubActionTask): isci isci --- app/tasks/GithubActionUpdateTask/page.tsx | 11 ++++++++- .../updateGithubActionTask.ts | 24 +++++++++---------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/app/tasks/GithubActionUpdateTask/page.tsx b/app/tasks/GithubActionUpdateTask/page.tsx index 856f465..757f89f 100644 --- a/app/tasks/GithubActionUpdateTask/page.tsx +++ b/app/tasks/GithubActionUpdateTask/page.tsx @@ -30,14 +30,23 @@ export default async function GithubActionUpdateTaskPage() { return (

GithubActionUpdateTasks in Total x{data.length}

+
    -
  • 1. Drafting PRs x{processingData.length}
  • +
  • 1. Bot are Drafting PRs x{processingData.length}
  • 2. Pending Reviews x{pendingReviewsData.length}
  • 3. Pending Create Pull Request x{pendingCreatePRData.length}
  • 4. Pull Request Created x{prCreatedData.length}
  • 5. Errors x{errorData.length}
+ + Check Actions + +

1. Drafting PRs x{processingData.length}

diff --git a/src/GithubActionUpdateTask/updateGithubActionTask.ts b/src/GithubActionUpdateTask/updateGithubActionTask.ts index 2b19418..f5f710b 100644 --- a/src/GithubActionUpdateTask/updateGithubActionTask.ts +++ b/src/GithubActionUpdateTask/updateGithubActionTask.ts @@ -1,5 +1,6 @@ #!bun import { readFile } from "fs/promises"; +import isCI from "is-ci"; import DIE from "phpdie"; import sflow from "sflow"; import sha256 from "sha256"; @@ -8,7 +9,6 @@ import { CRNodes } from "../CRNodes"; import { yaml } from "../utils/yaml"; import { GithubActionUpdateTask } from "./GithubActionUpdateTask"; import { updateGithubActionPrepareBranch } from "./updateGithubActionPrepareBranch"; -import {isCI} from 'is-ci' console.log({ GithubActionUpdateTask: await GithubActionUpdateTask.find().toArray() }); const path = "./templates/publish.yaml"; @@ -18,7 +18,6 @@ export const testUpdatedPublishYaml = await readFile(import.meta.dir + "/test-up export const referenceActionContentHash = sha256(referenceActionContent); if (import.meta.main) { - // const repo = "https://github.com/54rt1n/ComfyUI-DareMerge"; const repo = "https://github.com/snomiao/ComfyUI-DareMerge-test"; @@ -34,7 +33,7 @@ if (import.meta.main) { // task list importer await updateGithubActionTaskList(repo); - if(isCI) process.exit(0) + if (isCI) process.exit(0); } async function updateGithubActionTaskList(repo: string) { @@ -48,15 +47,16 @@ async function updateGithubActionTaskList(repo: string) { // task list scanner await sflow(GithubActionUpdateTask.find({ error: { $exists: false } }).project({ repo: 1 })) .pMap( - (e) => updateGithubActionTask(e.repo).catch(async (e) => { - const error = String(e); - await GithubActionUpdateTask.updateOne( - { repo }, - { $set: { error, updatedAt: new Date() } }, - { upsert: true } - ); - }), - { concurrency: 3 } + (e) => + updateGithubActionTask(e.repo).catch(async (e) => { + const error = String(e); + await GithubActionUpdateTask.updateOne( + { repo }, + { $set: { error, updatedAt: new Date() } }, + { upsert: true }, + ); + }), + { concurrency: 3 }, ) .run(); From 47efb37b59c3a3f71aa2a946065d53fc5fe5494d Mon Sep 17 00:00:00 2001 From: snomiao Date: Sat, 25 Jan 2025 09:51:44 +0000 Subject: [PATCH 5/6] fix(mass-pr): loop loop --- app/api/router.ts | 14 +-- app/tasks-panel.css | 4 + .../ApprovePRButton.tsx | 28 ------ .../github-action-update/ApprovePRButton.tsx | 38 ++++++++ .../github-action-update/ProgressBarChart.tsx | 85 +++++++++++++++++ .../github-action-update/ResetTaskButton.tsx | 37 ++++++++ .../actions.tsx | 19 ++-- .../page.tsx | 95 ++++++++++--------- app/tasks/page.tsx | 2 +- package.json | 2 + .../checkoutRepoOnBranch.ts | 7 +- .../updateGithubActionPrepareBranch.ts | 5 +- .../updateGithubActionTask.ts | 41 ++++---- src/WorkerInstances.ts | 19 +++- src/createComfyRegistryPullRequests.ts | 4 +- src/createGithubForkForRepo.ts | 24 ++++- src/createGithubPullRequest.ts | 45 ++++----- src/makeUpdateTomlLicenseBranch.ts | 4 +- src/utils/createInstanceId.ts | 5 +- 19 files changed, 332 insertions(+), 146 deletions(-) delete mode 100644 app/tasks/GithubActionUpdateTask/ApprovePRButton.tsx create mode 100644 app/tasks/github-action-update/ApprovePRButton.tsx create mode 100644 app/tasks/github-action-update/ProgressBarChart.tsx create mode 100644 app/tasks/github-action-update/ResetTaskButton.tsx rename app/tasks/{GithubActionUpdateTask => github-action-update}/actions.tsx (77%) rename app/tasks/{GithubActionUpdateTask => github-action-update}/page.tsx (68%) diff --git a/app/api/router.ts b/app/api/router.ts index 2ffc5ee..c2a56fb 100644 --- a/app/api/router.ts +++ b/app/api/router.ts @@ -8,13 +8,13 @@ import { type OpenApiMeta } from "trpc-openapi"; import z from "zod"; export const t = initTRPC.meta().create(); /* 👈 */ export const router = t.router({ - // sayHello: t.procedure - // .meta({ openapi: { method: "GET", path: "/say-hello", description: "say hello" } }) - // .input(z.object({ name: z.string() })) - // .output(z.object({ greeting: z.string() })) - // .query(({ input }) => { - // return { greeting: `Hello ${input.name} 1!` }; - // }), + sayHello: t.procedure + .meta({ openapi: { method: "GET", path: "/say-hello", description: "say hello" } }) + .input(z.object({ name: z.string() })) + .output(z.object({ greeting: z.string() })) + .query(({ input }) => { + return { greeting: `Hello ${input.name} 1!` }; + }), version: t.procedure .meta({ openapi: { method: "GET", path: "/version", description: "Get version of ComfyPR" } }) .input(z.object({})) diff --git a/app/tasks-panel.css b/app/tasks-panel.css index 390af3b..6e6825c 100644 --- a/app/tasks-panel.css +++ b/app/tasks-panel.css @@ -16,3 +16,7 @@ .tasks-panel a:hover { @apply underline; } + +.btn[aria-busy=true] { + @apply loading; +} diff --git a/app/tasks/GithubActionUpdateTask/ApprovePRButton.tsx b/app/tasks/GithubActionUpdateTask/ApprovePRButton.tsx deleted file mode 100644 index 183fc4b..0000000 --- a/app/tasks/GithubActionUpdateTask/ApprovePRButton.tsx +++ /dev/null @@ -1,28 +0,0 @@ -"use client"; -import Router from "next/router"; -import { useActionState, useEffect } from "react"; -import { approveGithubActionUpdateTaskAction } from "./actions"; - -export function ApprovePRButton(e: { repo: string; branchVersionHash?: string }) { - const [state, formAction, pending] = useActionState(approveGithubActionUpdateTaskAction, { ok: false }); - useEffect(() => { - if (state.ok) Router.reload(); - }, [state.ok]); - return ( -
- - - - -
- ); -} diff --git a/app/tasks/github-action-update/ApprovePRButton.tsx b/app/tasks/github-action-update/ApprovePRButton.tsx new file mode 100644 index 0000000..3f333a6 --- /dev/null +++ b/app/tasks/github-action-update/ApprovePRButton.tsx @@ -0,0 +1,38 @@ +"use client"; +import "is-hotkey-esm"; +import { isHotkey } from "is-hotkey-esm"; +import { useRouter } from "next/navigation"; +import { useActionState, useEffect } from "react"; +import { approveGithubActionUpdateTaskAction } from "./actions"; +export function ApprovePRButton(e: { repo: string; branchVersionHash?: string }) { + const [state, formAction, pending] = useActionState(approveGithubActionUpdateTaskAction, { ok: false }); + const router = useRouter(); + useEffect(() => { + if (state.ok) router.refresh(); + }, [state.ok, router]); + return ( +
+ + + + +
+ ); +} diff --git a/app/tasks/github-action-update/ProgressBarChart.tsx b/app/tasks/github-action-update/ProgressBarChart.tsx new file mode 100644 index 0000000..cbdd036 --- /dev/null +++ b/app/tasks/github-action-update/ProgressBarChart.tsx @@ -0,0 +1,85 @@ +"use client"; + +import { EChart } from "@kbox-labs/react-echarts"; + +// import ReactECharts from "echarts-for-react"; // or var ReactECharts = require('echarts-for-react'); +/** + * + * @author: snomiao + */ +export default function ProgressBarChart({ data }: { data: readonly [string, number, string][] }) { + return ( + <> + Object.keys(omit("date", e)))).map((key) => ({ + // type: "line", + // data: totalsData.map((e) => [e.date, e[key] ?? null]), + // }))} + {...{ + tooltip: { + trigger: "axis", + axisPointer: { + type: "shadow", // 'shadow' as default; can also be 'line' or 'shadow' + }, + }, + legend: {}, + grid: { + left: "0", + right: "0", + bottom: "0", + containLabel: false, + }, + xAxis: { + type: "value", + }, + yAxis: { + type: "category", + data: ["Progress"], + }, + series: data.map(([name, value, color]) => ({ + name, + type: "bar", + stack: "total", + label: { + show: true, + }, + color, + emphasis: { + focus: "series", + }, + data: [value], + })), + }} + /> + {/* */} + + ); +} diff --git a/app/tasks/github-action-update/ResetTaskButton.tsx b/app/tasks/github-action-update/ResetTaskButton.tsx new file mode 100644 index 0000000..769684c --- /dev/null +++ b/app/tasks/github-action-update/ResetTaskButton.tsx @@ -0,0 +1,37 @@ +"use client"; +import "is-hotkey-esm"; +import { isHotkey } from "is-hotkey-esm"; +import { useRouter } from "next/navigation"; +import { useActionState, useEffect } from "react"; +import { resetGithubActionUpdateTaskAction } from "./actions"; +export function ResetTaskButton(e: { repo: string }) { + const [state, formAction, pending] = useActionState(resetGithubActionUpdateTaskAction, { ok: false }); + const router = useRouter(); + useEffect(() => { + if (state.ok) router.refresh(); + }, [state.ok, router]); + return ( +
+ + + +
+ ); +} diff --git a/app/tasks/GithubActionUpdateTask/actions.tsx b/app/tasks/github-action-update/actions.tsx similarity index 77% rename from app/tasks/GithubActionUpdateTask/actions.tsx rename to app/tasks/github-action-update/actions.tsx index 419c903..d41e1c0 100644 --- a/app/tasks/GithubActionUpdateTask/actions.tsx +++ b/app/tasks/github-action-update/actions.tsx @@ -3,6 +3,13 @@ import { getAuthUser } from "@/app/api/auth/[...nextauth]/getAuthUser"; import { GithubActionUpdateTask } from "@/src/GithubActionUpdateTask/GithubActionUpdateTask"; import { z } from "zod"; +export async function resetGithubActionUpdateTaskAction(prevState: { ok: boolean }, formData: FormData) { + "use server"; + await getAuthUser(); + const e = z.object({ repo: z.string() }).parse(Object.fromEntries(formData.entries())); + await resetErrorForGithubActionUpdateTask(e.repo); + return { ok: true }; +} export async function approveGithubActionUpdateTaskAction(prevState: { ok: boolean }, formData: FormData) { "use server"; await getAuthUser(); @@ -16,8 +23,8 @@ export async function approveGithubActionUpdateTaskAction(prevState: { ok: boole return { ok: true }; } export async function approveGithubActionUpdateTask(repo: string, approvedHash: string) { - "use server"; - await getAuthUser(); + // "use server"; + // await getAuthUser(); await GithubActionUpdateTask.findOneAndUpdate( { repo }, { $set: { approvedBranchVersionHash: approvedHash, updatedAt: new Date() } }, @@ -25,8 +32,8 @@ export async function approveGithubActionUpdateTask(repo: string, approvedHash: ); } export async function resetErrorForGithubActionUpdateTask(repo: string) { - "use server"; - await getAuthUser(); + // "use server"; + // await getAuthUser(); await GithubActionUpdateTask.findOneAndDelete({ repo }); await GithubActionUpdateTask.findOneAndUpdate( { repo }, @@ -35,8 +42,8 @@ export async function resetErrorForGithubActionUpdateTask(repo: string) { ); } export async function listGithubActionUpdateTask() { - "use server"; - await getAuthUser(); + // "use server"; + // await getAuthUser(); return (await GithubActionUpdateTask.find({}).toArray()).map(({ _id, ...e }) => ({ ...e, updatedAt: +(e.updatedAt ?? 0), diff --git a/app/tasks/GithubActionUpdateTask/page.tsx b/app/tasks/github-action-update/page.tsx similarity index 68% rename from app/tasks/GithubActionUpdateTask/page.tsx rename to app/tasks/github-action-update/page.tsx index 757f89f..f99f465 100644 --- a/app/tasks/GithubActionUpdateTask/page.tsx +++ b/app/tasks/github-action-update/page.tsx @@ -3,11 +3,19 @@ import "@/app/markdown.css"; import "@/app/tasks-panel.css"; import { parseTitleBodyOfMarkdown } from "@/src/parseTitleBodyOfMarkdown"; import { yaml } from "@/src/utils/yaml"; +import type { Metadata } from "next"; import { forbidden } from "next/navigation"; import Markdown from "react-markdown"; import remarkGfm from "remark-gfm"; +import { listGithubActionUpdateTask } from "./actions"; import { ApprovePRButton } from "./ApprovePRButton"; -import { listGithubActionUpdateTask, resetErrorForGithubActionUpdateTask } from "./actions"; +import ProgressBarChart from "./ProgressBarChart"; +import { ResetTaskButton } from "./ResetTaskButton"; + +export const metadata: Metadata = { + title: `GithubActionUpdateTaskPage - ComfyPR`, +}; + /** * * @author: snomiao @@ -15,29 +23,42 @@ import { listGithubActionUpdateTask, resetErrorForGithubActionUpdateTask } from export default async function GithubActionUpdateTaskPage() { const user = await getAuthUser(); if (!user.admin) return forbidden(); - const data = await listGithubActionUpdateTask(); + const errorData = data.filter((e) => e.error); - const processingData = data.filter((e) => !e.pullRequestMessage); - const pendingReviewsData = data.filter( - (e) => e.branchVersionHash && e.branchVersionHash !== e.approvedBranchVersionHash, - ); - const pendingCreatePRData = data.filter( - (e) => e.approvedBranchVersionHash && e.approvedBranchVersionHash !== e.pullRequestVersionHash, - ); - const prCreatedData = data.filter((e) => e.pullRequestUrl); + const processingData = data.filter((e) => !errorData.includes(e)).filter((e) => !e.pullRequestMessage); + const pendingReviewsData = data + .filter((e) => !errorData.includes(e)) + .filter((e) => e.branchVersionHash && e.branchVersionHash !== e.approvedBranchVersionHash); + const pendingCreatePRData = data + .filter((e) => !errorData.includes(e)) + .filter((e) => e.approvedBranchVersionHash && e.approvedBranchVersionHash !== e.pullRequestVersionHash); + const prCreatedData = data.filter((e) => !errorData.includes(e)).filter((e) => e.pullRequestUrl); + const chartData = { + data: [ + ["Processing", processingData.length, "oklch(0.8 0.180 136)"], // A greenish color + ["Pending Reviews", pendingReviewsData.length, "oklch(0.7 0.15 72)"], // A yellowish color + ["Pending Create PR", pendingCreatePRData.length, "oklch(0.75 0.150 198)"], // A bluish color + ["PR Created", prCreatedData.length, "oklch(0.8 0.125 320)"], // A purple color + ["Error", errorData.length, "oklch(0.6 0.179 29)"], // A reddish color + ] as readonly [string, number, string][], + }; return ( -
+

GithubActionUpdateTasks in Total x{data.length}

-
    -
  • 1. Bot are Drafting PRs x{processingData.length}
  • -
  • 2. Pending Reviews x{pendingReviewsData.length}
  • -
  • 3. Pending Create Pull Request x{pendingCreatePRData.length}
  • -
  • 4. Pull Request Created x{prCreatedData.length}
  • -
  • 5. Errors x{errorData.length}
  • -
+
+ +
+ +
    +
  1. Bot are Drafting PRs x{processingData.length}
  2. +
  3. Pending Reviews x{pendingReviewsData.length}
  4. +
  5. Pending Create Pull Request x{pendingCreatePRData.length}
  6. +
  7. Pull Request Created x{prCreatedData.length}
  8. +
  9. Errors x{errorData.length}
  10. +
-

1. Drafting PRs x{processingData.length}

+

Drafting PRs x{processingData.length}

    {processingData.map((e, i, a) => { @@ -65,9 +86,9 @@ export default async function GithubActionUpdateTaskPage() {
-
+
-

2. Pending Reviews x{pendingReviewsData.length}

+

Pending Reviews x{pendingReviewsData.length}

    {pendingReviewsData.map((e, i) => ( @@ -113,9 +134,9 @@ export default async function GithubActionUpdateTaskPage() {
-
+
-

3. Pending Create Pull Request x{pendingCreatePRData.length}

+

Pending Create Pull Request x{pendingCreatePRData.length}

    {pendingCreatePRData.map((e, i) => { @@ -126,24 +147,16 @@ export default async function GithubActionUpdateTaskPage() { {e.repo} {" "} - Creating PR [{parseTitleBodyOfMarkdown(e.pullRequestMessage!).title}]... - + ); })}
-
+
-

4. Pull Request Created x{prCreatedData.length}

+

Pull Request Created x{prCreatedData.length}

    @@ -163,9 +176,9 @@ export default async function GithubActionUpdateTaskPage() { })}
-
+
-

5. Errors x{errorData.length}

+

Errors x{errorData.length}

    {errorData.map((e, i, a) => { @@ -178,15 +191,7 @@ export default async function GithubActionUpdateTaskPage() { {e.repo} - +
{yaml.stringify(e)}
diff --git a/app/tasks/page.tsx b/app/tasks/page.tsx index 0441600..7d51b95 100644 --- a/app/tasks/page.tsx +++ b/app/tasks/page.tsx @@ -14,7 +14,7 @@ export default async function TasksIndexPage() { return (
  1. - GithubActionUpdateTask x {counts.GithubActionUpdateTask} + GithubActionUpdateTask x {counts.GithubActionUpdateTask}
); diff --git a/package.json b/package.json index ed0c4b6..cd76aa6 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "googleapis": "^140.0.1", "googleapis-common": "^7.2.0", "is-ci": "^4.1.0", + "is-hotkey-esm": "^1.0.0", "js-yaml": "^4.1.0", "json-stable-stringify": "^1.1.1", "keyv": "^4.5.4", @@ -83,6 +84,7 @@ "pretty-ms": "^9.1.0", "promise-all-properties": "^4.0.4", "rambda": "^9.2.1", + "random-word-slugs": "^0.1.7", "react-api-doc": "^0.0.9", "react-hook-form": "^7.52.1", "react-hot-toast": "^2.4.1", diff --git a/src/GithubActionUpdateTask/checkoutRepoOnBranch.ts b/src/GithubActionUpdateTask/checkoutRepoOnBranch.ts index feb0733..a3c2981 100644 --- a/src/GithubActionUpdateTask/checkoutRepoOnBranch.ts +++ b/src/GithubActionUpdateTask/checkoutRepoOnBranch.ts @@ -1,11 +1,12 @@ import { $ } from "../cli/echoBunShell"; -import { createGithubForkForRepo } from "../createGithubForkForRepo"; +import { createGithubForkForRepoEx } from "../createGithubForkForRepo"; import { getBranchWorkingDir } from "../getBranchWorkingDir"; import { GIT_USEREMAIL, GIT_USERNAME } from "../ghUser"; export async function checkoutRepoOnBranch(upstreamUrl: string, branch: string) { console.log("==== CHECKOUT " + upstreamUrl); - const forkedRepo = await createGithubForkForRepo(upstreamUrl); + const forkedRepo = await createGithubForkForRepoEx(upstreamUrl); + const forkedHtmlUrl = forkedRepo.html_url; const cwd = await getBranchWorkingDir(upstreamUrl, forkedRepo.html_url, branch); await $` git clone ${upstreamUrl} ${cwd} @@ -14,5 +15,5 @@ git config user.name ${GIT_USERNAME} && \ git config user.email ${GIT_USEREMAIL} && \ git checkout -b ${branch} `; - return { cwd, ...forkedRepo }; + return { cwd, html_url: forkedHtmlUrl }; } diff --git a/src/GithubActionUpdateTask/updateGithubActionPrepareBranch.ts b/src/GithubActionUpdateTask/updateGithubActionPrepareBranch.ts index 04b7ce1..2cb6f94 100644 --- a/src/GithubActionUpdateTask/updateGithubActionPrepareBranch.ts +++ b/src/GithubActionUpdateTask/updateGithubActionPrepareBranch.ts @@ -20,10 +20,9 @@ export async function updateGithubActionPrepareBranch(repo: string) { const branch = "update-publish-yaml"; const { cwd, html_url } = await checkoutRepoOnBranch(repo, branch); - const files = await globby(cwd + "/.github/workflows/{publish,publish_action}.{yaml,yml}"); + const files = await globby(`${cwd}/.github/workflows/{publish,publish_action}.{yaml,yml}`); console.assert( - files.length === 1 || - DIE("expected exactly 1 publish.yaml file, but got " + files.length + " " + JSON.stringify(files)), + files.length === 1 || DIE(`expected exactly 1 publish.yaml file, but got ${files.length} ${JSON.stringify(files)}`), ); const file = files[0]; const currentContent = await readFile(file, "utf8"); diff --git a/src/GithubActionUpdateTask/updateGithubActionTask.ts b/src/GithubActionUpdateTask/updateGithubActionTask.ts index f5f710b..45600db 100644 --- a/src/GithubActionUpdateTask/updateGithubActionTask.ts +++ b/src/GithubActionUpdateTask/updateGithubActionTask.ts @@ -1,4 +1,5 @@ #!bun +import { $pipeline } from "@/packages/mongodb-pipeline-ts/$pipeline"; import { readFile } from "fs/promises"; import isCI from "is-ci"; import DIE from "phpdie"; @@ -7,6 +8,7 @@ import sha256 from "sha256"; import { createPR } from "../createGithubPullRequest"; import { CRNodes } from "../CRNodes"; import { yaml } from "../utils/yaml"; +import { getWorkerInstance } from "../WorkerInstances"; import { GithubActionUpdateTask } from "./GithubActionUpdateTask"; import { updateGithubActionPrepareBranch } from "./updateGithubActionPrepareBranch"; console.log({ GithubActionUpdateTask: await GithubActionUpdateTask.find().toArray() }); @@ -20,7 +22,6 @@ export const referenceActionContentHash = sha256(referenceActionContent); if (import.meta.main) { // const repo = "https://github.com/54rt1n/ComfyUI-DareMerge"; const repo = "https://github.com/snomiao/ComfyUI-DareMerge-test"; - // await GithubActionUpdateTask.findOneAndDelete({ repo }); // aprove test @@ -31,33 +32,31 @@ if (import.meta.main) { // await updateGithubActionTask(repo); // task list importer - await updateGithubActionTaskList(repo); + await updateGithubActionTaskList(); if (isCI) process.exit(0); } -async function updateGithubActionTaskList(repo: string) { - await sflow(CRNodes.find().project({ repo: "$repository", _id: 0 })) - .log() - .map(({ repo }) => String(repo)) - .filter((e) => e.startsWith("https://github.com")) - .pMap((repo) => GithubActionUpdateTask.updateOne({ repo }, { $set: { updatedAt: new Date() } }, { upsert: true })) - .run(); +async function updateGithubActionTaskList() { + await getWorkerInstance("updateGithubActionTaskList"); + await GithubActionUpdateTask.createIndex({ repo: 1 }, { unique: true }); + await $pipeline(CRNodes) + .project({ repo: "$repository", _id: 0 }) + .match({ repo: /^https:\/\/github\.com/ }) + .merge({ into: GithubActionUpdateTask.collectionName, on: "repo", whenMatched: "merge" }) + .aggregate() + .next(); // task list scanner await sflow(GithubActionUpdateTask.find({ error: { $exists: false } }).project({ repo: 1 })) - .pMap( - (e) => - updateGithubActionTask(e.repo).catch(async (e) => { - const error = String(e); - await GithubActionUpdateTask.updateOne( - { repo }, - { $set: { error, updatedAt: new Date() } }, - { upsert: true }, - ); - }), - { concurrency: 3 }, - ) + .map(async ({ repo }) => { + console.log("-"); + return await updateGithubActionTask(repo).catch(async (err) => { + console.error(err); + const error = String(err); + await GithubActionUpdateTask.updateOne({ repo }, { $set: { error, updatedAt: new Date() } }, { upsert: true }); + }); + }) .run(); // console.log(yaml.stringify({ GithubActionUpdateTask: await GithubActionUpdateTask.find().toArray() })); diff --git a/src/WorkerInstances.ts b/src/WorkerInstances.ts index 9ee3fc1..cfad2d4 100644 --- a/src/WorkerInstances.ts +++ b/src/WorkerInstances.ts @@ -2,9 +2,12 @@ import { getMAC } from "@ctrl/mac-address"; import { defer } from "lodash-es"; import md5 from "md5"; import type { WithId } from "mongodb"; -import { db } from "./db"; +import sflow from "sflow"; +import { $fresh, db } from "./db"; import { fetchCurrentGeoInfo } from "./fetchCurrentGeoInfo"; import { createInstanceId } from "./utils/createInstanceId"; +import { yaml } from "./utils/yaml"; + export type GeoInfo = Awaited>; export type WorkerInstance = { /** id: rand */ @@ -14,6 +17,7 @@ export type WorkerInstance = { geo: GeoInfo; workerId: string; task?: string; + tasks?: string[]; }; const k = "COMFY_PR_WorkerInstanceKey"; @@ -28,12 +32,18 @@ function getWorkerInstanceId() { return instanceId; } export const WorkerInstances = db.collection("WorkerInstances"); -await WorkerInstances.createIndex({ id: 1 }, { unique: true }); -await WorkerInstances.createIndex({ ip: 1 }); export const _geoPromise = fetchCurrentGeoInfo(); // in background if (import.meta.main) { + await WorkerInstances.createIndex({ id: 1 }, { unique: true }); + await WorkerInstances.createIndex({ ip: 1 }); console.log(await getWorkerInstance()); + console.log( + await sflow(WorkerInstances.watch([{ $match: { up: $fresh("5min") } }], { fullDocument: "whenAvailable" })) + .map((e) => yaml.stringify(e)) + .log() + .run(), + ); } async function postWorkerHeartBeatLoop() { @@ -78,6 +88,9 @@ export async function getWorkerInstance(task?: string) { geo: await _geoPromise, ...(task && { task }), }, + $addToSet: { + ...(task && { tasks: task }), + }, $setOnInsert: { up: new Date() }, }, { upsert: true, returnDocument: "after" }, diff --git a/src/createComfyRegistryPullRequests.ts b/src/createComfyRegistryPullRequests.ts index a0a5f6e..2eb70e7 100644 --- a/src/createComfyRegistryPullRequests.ts +++ b/src/createComfyRegistryPullRequests.ts @@ -1,6 +1,6 @@ import minimist from "minimist"; import pMap from "p-map"; -import { createGithubForkForRepo } from "./createGithubForkForRepo"; +import { createGithubForkForRepoEx } from "./createGithubForkForRepo"; import { createGithubPullRequest } from "./createGithubPullRequest"; import type { GithubPull } from "./gh/GithubPull"; import { makePublishcrBranch } from "./makePublishBranch"; @@ -15,7 +15,7 @@ if (import.meta.main) { export async function createComfyRegistryPullRequests(upstreamRepoUrl: string) { console.log("forking " + upstreamRepoUrl); - const forkedRepo = await createGithubForkForRepo(upstreamRepoUrl); + const forkedRepo = await createGithubForkForRepoEx(upstreamRepoUrl); console.log("modifing " + forkedRepo.html_url); const PR_REQUESTS = await clone_modify_push_Branches(upstreamRepoUrl, forkedRepo.html_url); diff --git a/src/createGithubForkForRepo.ts b/src/createGithubForkForRepo.ts index 93a663e..af3d4d9 100644 --- a/src/createGithubForkForRepo.ts +++ b/src/createGithubForkForRepo.ts @@ -1,14 +1,18 @@ import DIE from "@snomiao/die"; import md5 from "md5"; import minimist from "minimist"; +import { db } from "./db"; import { FORK_OWNER } from "./FORK_OWNER"; import { FORK_PREFIX } from "./FORK_PREFIX"; import { createGithubFork } from "./gh/createGithubFork"; import { ghUser } from "./ghUser"; import { parseUrlRepoOwner } from "./parseOwnerRepo"; +/** for cache */ +const ForkedRepo = db.collection<{ repo: string; forkedRepo: string; updatedAt: Date }>("ForkedRepo"); + if (import.meta.main) { - console.log(await createGithubForkForRepo("https://github.com/comfyanonymous/ComfyUI_TensorRT")); + console.log(await createGithubForkForRepoEx("https://github.com/comfyanonymous/ComfyUI_TensorRT")); } /** @@ -22,10 +26,21 @@ if (import.meta.main) { * @param upstreamRepoUrl * @returns forked repo info */ -export async function createGithubForkForRepo( +export async function createGithubForkForRepoEx( upstreamRepoUrl: string, { forkUrl = createGithubForkUrlForRepo(upstreamRepoUrl) } = {}, ) { + const alreadyForked = await ForkedRepo.findOne({ repo: upstreamRepoUrl, forkedRepo: forkUrl }); + if (alreadyForked) { + console.debug( + ` +Forked ${upstreamRepoUrl} + into ${forkUrl} +`.trim(), + ); + return { html_url: forkUrl }; + } + console.debug( ` Forking ${upstreamRepoUrl} @@ -39,6 +54,11 @@ Forking ${upstreamRepoUrl} "forked url not expected, it's likely you already forked this repo in your account before, and now trying to fork it again with different salt. To recovery you could delete that repo forked before by manual. (the repo forked before is listed in FORK OK: .....)", ), ); + await ForkedRepo.updateOne( + { repo: upstreamRepoUrl, forkedRepo: forkUrl }, + { $set: { updatedAt: new Date() } }, + { upsert: true }, + ); return forked; } export function createGithubForkUrlForRepo(upstreamRepoUrl: string) { diff --git a/src/createGithubPullRequest.ts b/src/createGithubPullRequest.ts index 9afe32d..03e144a 100644 --- a/src/createGithubPullRequest.ts +++ b/src/createGithubPullRequest.ts @@ -81,28 +81,29 @@ export async function createGithubPullRequest({ const src = parseUrlRepoOwner(srcUrl); const repo = (await gh.repos.get({ ...dst })).data; - // TODO: seems has bugs on head_repo - const existedList = ( - await gh.pulls.list({ - // source repo - state: "open", - head: encodeURIComponent(`${src.owner}:${branch}`), - // pr will merge into - owner: dst.owner, - repo: dst.repo, - base: repo.default_branch, - }) - ).data; - if (existedList.length > 1) - DIE( - new Error(`expect only 1 pr, but got ${existedList.length}`, { - cause: { existed: existedList.map((e) => ({ url: e.html_url, title: e.title })) }, - }), - ); + // // TODO: seems has bugs on head_repo + // const existedList = ( + // await gh.pulls.list({ + // // source repo + // state: "open", + // head: encodeURIComponent(`${src.owner}:${branch}`), + // // pr will merge into + // owner: dst.owner, + // repo: dst.repo, + // base: repo.default_branch, + // }) + // ).data; + + // existedList.length <= 1 || + // DIE( + // new Error(`expect <= 1 pr, but got ${existedList.length}`, { + // cause: { existed: existedList.map((e) => ({ url: e.html_url, title: e.title })) }, + // }), + // ); const pr_result = - existedList[0] ?? - (await ghPR() + // existedList[0] ?? + await ghPR() .pulls.create({ // pr info title, @@ -137,7 +138,7 @@ export async function createGithubPullRequest({ }) ).data; // .filter(existed => existed.title === title); - if (existedList.length !== 1) + existedList.length === 1 || DIE( new Error("expect only 1 pr, but got " + existedList.length, { cause: { @@ -158,7 +159,7 @@ export async function createGithubPullRequest({ ); return existedList[0]; - })); + }); console.log("PR OK", pr_result.html_url); const mismatch = pr_result.title !== title || pr_result.body !== body; diff --git a/src/makeUpdateTomlLicenseBranch.ts b/src/makeUpdateTomlLicenseBranch.ts index 80f461d..13f9cc0 100644 --- a/src/makeUpdateTomlLicenseBranch.ts +++ b/src/makeUpdateTomlLicenseBranch.ts @@ -9,7 +9,7 @@ import sflow, { nil } from "sflow"; import { isRepoBypassed } from "./bypassRepos"; import { $ } from "./cli/echoBunShell"; import { CNRepos } from "./CNRepos"; -import { createGithubForkForRepo } from "./createGithubForkForRepo"; +import { createGithubForkForRepoEx } from "./createGithubForkForRepo"; import { createGithubPullRequest } from "./createGithubPullRequest"; import { $filaten, $stale, db } from "./db"; import { getBranchWorkingDir } from "./getBranchWorkingDir"; @@ -107,7 +107,7 @@ async function _testMakeUpdateTomlLicenseBranch() { } async function createTomlLicensePR(upstreamUrl: string): Promise { - const { html_url: forkUrl } = await createGithubForkForRepo(upstreamUrl); + const { html_url: forkUrl } = await createGithubForkForRepoEx(upstreamUrl); const branchInfo = await makeUpdateTomlLicenseBranch(upstreamUrl, forkUrl); // console.log(forkUrl); // note: this forkUrl may not be final forked url console.log({ branchInfo }); diff --git a/src/utils/createInstanceId.ts b/src/utils/createInstanceId.ts index e8d26a7..cd65ab6 100644 --- a/src/utils/createInstanceId.ts +++ b/src/utils/createInstanceId.ts @@ -1,3 +1,6 @@ +import { generateSlug } from "random-word-slugs"; + export function createInstanceId() { - return Math.random().toString(36).slice(2, 10).toUpperCase(); + return generateSlug(2); + // return Math.random().toString(36).slice(2, 10).toUpperCase(); } From 287580eadf89921c52d95660071a4a0b85149f2d Mon Sep 17 00:00:00 2001 From: snomiao Date: Sat, 25 Jan 2025 09:55:49 +0000 Subject: [PATCH 6/6] refactor(updateGithubActionTask): move into fn move into fn --- src/GithubActionUpdateTask/updateGithubActionTask.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/GithubActionUpdateTask/updateGithubActionTask.ts b/src/GithubActionUpdateTask/updateGithubActionTask.ts index 45600db..e4b0777 100644 --- a/src/GithubActionUpdateTask/updateGithubActionTask.ts +++ b/src/GithubActionUpdateTask/updateGithubActionTask.ts @@ -11,7 +11,6 @@ import { yaml } from "../utils/yaml"; import { getWorkerInstance } from "../WorkerInstances"; import { GithubActionUpdateTask } from "./GithubActionUpdateTask"; import { updateGithubActionPrepareBranch } from "./updateGithubActionPrepareBranch"; -console.log({ GithubActionUpdateTask: await GithubActionUpdateTask.find().toArray() }); const path = "./templates/publish.yaml"; export const referenceActionContent = await readFile(path, "utf8"); @@ -31,7 +30,6 @@ if (import.meta.main) { // test on single repo // await updateGithubActionTask(repo); - // task list importer await updateGithubActionTaskList(); if (isCI) process.exit(0); @@ -39,6 +37,8 @@ if (import.meta.main) { async function updateGithubActionTaskList() { await getWorkerInstance("updateGithubActionTaskList"); + + // task list importer await GithubActionUpdateTask.createIndex({ repo: 1 }, { unique: true }); await $pipeline(CRNodes) .project({ repo: "$repository", _id: 0 }) @@ -46,6 +46,11 @@ async function updateGithubActionTaskList() { .merge({ into: GithubActionUpdateTask.collectionName, on: "repo", whenMatched: "merge" }) .aggregate() .next(); + + // reset network error + await GithubActionUpdateTask.findOneAndDelete({ error: /was submitted too quickly/ }); + + console.log({ GithubActionUpdateTask: await GithubActionUpdateTask.find().toArray() }); // task list scanner await sflow(GithubActionUpdateTask.find({ error: { $exists: false } }).project({ repo: 1 }))