diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 55b703b1e..eb59dff86 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -265,13 +265,15 @@ jobs: build-cli-pr: if: github.event_name == 'pull_request' needs: [release-test] - runs-on: ubuntu-latest + runs-on: namespace-profile-linux-amd64-16gb steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup-mise - run: mise run codegen - run: deno task pack working-directory: ${{ github.workspace }}/packages/cli/ + env: + CONCURRENCY: "3" - uses: actions/upload-artifact@v4 with: name: cli-pr-${{ github.event.pull_request.number }} @@ -322,7 +324,7 @@ jobs: build-cli: if: github.event_name == 'push' needs: [test, test-node, test-bun, test-cfworkers, lint, release-test, determine-version] - runs-on: ubuntu-latest + runs-on: namespace-profile-linux-amd64-16gb steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup-mise @@ -330,6 +332,8 @@ jobs: - run: mise run codegen - run: deno task pack working-directory: ${{ github.workspace }}/packages/cli/ + env: + CONCURRENCY: "3" - uses: actions/upload-artifact@v4 with: name: cli diff --git a/packages/cli/scripts/pack.ts b/packages/cli/scripts/pack.ts index f8ec1d2fe..96adecb62 100644 --- a/packages/cli/scripts/pack.ts +++ b/packages/cli/scripts/pack.ts @@ -56,16 +56,28 @@ async function pack(os: OS, arch: Arch): Promise { const osFilter = Deno.env.get("OS")?.toLowerCase(); const archFilter = Deno.env.get("ARCH")?.toLowerCase(); -const promises: Promise[] = []; +const tasks: Array<() => Promise> = []; for (const osKey in triplets) { const os = osKey as OS; if (osFilter != null && osFilter !== os) continue; for (const arch in triplets[os]) { if (archFilter != null && archFilter !== arch) continue; - const promise = pack(os, arch as Arch); - promises.push(promise); + tasks.push(() => pack(os, arch as Arch)); } } -await Promise.all(promises); +const maxConcurrency = parseInt( + Deno.env.get("CONCURRENCY") ?? `${tasks.length}`, +); +const executing = new Set>(); +for (const task of tasks) { + const p = task().then(() => { + executing.delete(p); + }); + executing.add(p); + if (executing.size >= maxConcurrency) { + await Promise.race(executing); + } +} +await Promise.all(executing); // cSpell: ignore cfvz