From ad97feaf6e59b7f44f665087f092cf160c1083c4 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Sat, 14 Mar 2026 19:25:40 +0000 Subject: [PATCH] Optimize CI matrix job to fetch composer.lock directly Replace paginated listFiles API call with targeted getContent calls to avoid timeouts on large PRs with thousands of changed files. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/workflows/ci.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e59b14e550..19cda9348c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -148,14 +148,22 @@ jobs: return; } - const files = await github.paginate(github.rest.pulls.listFiles, { + const getContent = (ref) => github.rest.repos.getContent({ owner: context.repo.owner, repo: context.repo.repo, - pull_number: pr.number, + path: 'composer.lock', + ref, }); - const lockFile = files.find(f => f.filename === 'composer.lock'); - const databaseChanged = lockFile?.patch?.includes('"name": "utopia-php/database"') ?? false; + const getDbVersion = (lock) => lock.packages?.find(p => p.name === 'utopia-php/database')?.version; + + const [{ data: base }, { data: head }] = await Promise.all([ + getContent(pr.base.sha), + getContent(pr.head.sha), + ]); + + const decode = (content) => JSON.parse(Buffer.from(content, 'base64').toString()); + const databaseChanged = getDbVersion(decode(base.content)) !== getDbVersion(decode(head.content)); core.setOutput('databases', JSON.stringify(databaseChanged ? allDatabases : defaultDatabases)); core.setOutput('modes', JSON.stringify(databaseChanged ? allModes : defaultModes));