Skip to content

Commit f332137

Browse files
authored
Merge branch 'main' into main
2 parents 8cbf237 + e79f888 commit f332137

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

.github/workflows/main.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,15 @@ jobs:
265265
build-cli-pr:
266266
if: github.event_name == 'pull_request'
267267
needs: [release-test]
268-
runs-on: ubuntu-latest
268+
runs-on: namespace-profile-linux-amd64-16gb
269269
steps:
270270
- uses: actions/checkout@v4
271271
- uses: ./.github/actions/setup-mise
272272
- run: mise run codegen
273273
- run: deno task pack
274274
working-directory: ${{ github.workspace }}/packages/cli/
275+
env:
276+
CONCURRENCY: "3"
275277
- uses: actions/upload-artifact@v4
276278
with:
277279
name: cli-pr-${{ github.event.pull_request.number }}
@@ -322,14 +324,16 @@ jobs:
322324
build-cli:
323325
if: github.event_name == 'push'
324326
needs: [test, test-node, test-bun, test-cfworkers, lint, release-test, determine-version]
325-
runs-on: ubuntu-latest
327+
runs-on: namespace-profile-linux-amd64-16gb
326328
steps:
327329
- uses: actions/checkout@v4
328330
- uses: ./.github/actions/setup-mise
329331
- uses: ./.github/actions/determine-version
330332
- run: mise run codegen
331333
- run: deno task pack
332334
working-directory: ${{ github.workspace }}/packages/cli/
335+
env:
336+
CONCURRENCY: "3"
333337
- uses: actions/upload-artifact@v4
334338
with:
335339
name: cli

packages/cli/scripts/pack.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,28 @@ async function pack(os: OS, arch: Arch): Promise<void> {
5656
const osFilter = Deno.env.get("OS")?.toLowerCase();
5757
const archFilter = Deno.env.get("ARCH")?.toLowerCase();
5858

59-
const promises: Promise<void>[] = [];
59+
const tasks: Array<() => Promise<void>> = [];
6060
for (const osKey in triplets) {
6161
const os = osKey as OS;
6262
if (osFilter != null && osFilter !== os) continue;
6363
for (const arch in triplets[os]) {
6464
if (archFilter != null && archFilter !== arch) continue;
65-
const promise = pack(os, arch as Arch);
66-
promises.push(promise);
65+
tasks.push(() => pack(os, arch as Arch));
6766
}
6867
}
69-
await Promise.all(promises);
68+
const maxConcurrency = parseInt(
69+
Deno.env.get("CONCURRENCY") ?? `${tasks.length}`,
70+
);
71+
const executing = new Set<Promise<void>>();
72+
for (const task of tasks) {
73+
const p = task().then(() => {
74+
executing.delete(p);
75+
});
76+
executing.add(p);
77+
if (executing.size >= maxConcurrency) {
78+
await Promise.race(executing);
79+
}
80+
}
81+
await Promise.all(executing);
7082

7183
// cSpell: ignore cfvz

0 commit comments

Comments
 (0)