Skip to content

Commit 88a8654

Browse files
feat: add comprehensive Bun package manager support (#257)
* feat: add comprehensive Bun package manager support This commit introduces full Bun package manager integration to the CircleCI Node orb, adding Bun as a first-class supported package manager alongside npm, yarn, yarn-berry, and pnpm. ## Core Installation Infrastructure - Add install-bun command with version management and retry logic - Add Bun installation script with automatic version detection - Integrate bun-version parameter into main install command - Support for both specific versions and latest stable releases ## Package Management Integration - Add 'bun' to pkg-manager enum across all commands and jobs - Implement bun-install.sh with frozen lockfile default for reproducible builds - Add support for both bun.lock (text) and bun.lockb (binary) lockfiles - Configure cache support via BUN_INSTALL_CACHE_DIR environment variable - Default cache path: ~/.bun/install/cache with override capability ## Job Execution Support - Add bun-run parameter to run job for script execution - Integrate Bun command execution in run-commands-with.sh - Add Bun test runner support with native JUnit XML output - Support Jest and Mocha test frameworks via Bun's built-in test runner ## Testing & CI Integration - Add comprehensive integration tests for all Bun functionality: - Installation (specific versions and latest) - Package installation with caching - Test execution (Jest/Mocha compatibility) - Script execution via bun run - Cross-platform support (Linux, macOS, machine) - Multi-architecture support (ARM64, x86_64) ## Documentation & Examples - Create three example configurations: - bun_install.yml: Basic Bun installation and package management - node_bun_run.yml: Script execution with Bun - run_tests_with_bun.yml: Test runner integration - Update orb description to include Bun in supported package managers ## Key Features & Benefits - Frozen lockfile by default (--frozen-lockfile) ensures reproducible builds - Network retry logic (--retry 5) for robust CI installations - Native test runner with built-in JUnit XML output (no additional dependencies) - Automatic lockfile detection for both text (.lock) and binary (.lockb) formats - Seamless integration with existing orb caching mechanisms - Full compatibility with CircleCI's artifact and test result collection This enhancement maintains backward compatibility while extending the orb's package manager support to include Bun's fast JavaScript runtime and toolkit. The implementation follows existing patterns for consistency and includes comprehensive test coverage across all supported platforms and architectures. * fix: replace GitHub API call with redirect method for Bun version detection Replace api.github.com usage with github.com redirect approach to avoid rate limiting issues. This follows the same pattern used for other tools in the orb (e.g., Dockerize). Changed from parsing JSON API response to extracting version from the redirect URL of the releases/latest endpoint. * Add new line at the end * fix: address typo in path segment that blocked bun installation * Add new line at the end * fix: remove integration-test-install-bun-latest job from workflow The job definition was deleted but references to it remained in the workflow, causing CI failures. This removes the job from both the workflow jobs list and the orb publish requirements. * chore: update Bun version from 1.2.21 to 1.2.22 Updates all references to Bun version 1.2.21 to use version 1.2.22 across: - CI test configurations in .circleci/test-deploy.yml - Documentation examples in src/examples/ * fix: correct Bun test runner integration - Fix Bun+Jest to run Jest via 'bun run' instead of native 'bun test' - Fix Bun+Mocha to check dependencies properly - Add 'bun' as test-results-for option for native Bun test runner - Add examples showing both native and Jest/Mocha usage * fix: add automatic test result collection for native Bun tests * improve: simplify Bun cache configuration and add lockfile warnings - Remove explicit cache-path from examples (orb defaults work correctly) - Add warning when both bun.lock and bun.lockb are present - Set explicit BUN_INSTALL_CACHE_DIR default for consistency - Clarify in examples that cache path is automatically configured * fix: use npm global install for Bun to ensure PATH availability Switch from Bun's official installer to npm global install method, following the same pattern as pnpm. This ensures Bun is properly available in PATH for subsequent CircleCI steps without requiring manual PATH manipulation or BASH_ENV exports. * test: add Bun native test runner coverage and lockfile consistency Completes the Bun integration by adding test coverage for Bun's native test runner and ensuring lockfile handling consistency across all package managers. Changes: - Add node-bun-native-test-job to test Bun's built-in test runner with JUnit output verification - Create minimal test file at sample/bun-tests/simple.test.js for native test runner validation - Generate and commit bun.lock file to match the pattern of having all package manager lockfiles in the repository - Update non-Bun package manager tests to remove bun.lock, ensuring clean test isolation * Fix linter * fix: patch sec vulnerability * fix: resolve Bun test runner issues in CircleCI orb - Fix Jest/Bun haste map collisions by adding modulePathIgnorePatterns to exclude Bun cache - Fix Bun native test runner by specifying bun-tests directory for test discovery These changes address pipeline failures in the node-bun-jest-test-job and node-bun-native-test-job by preventing Jest from scanning Bun's package cache and ensuring the native runner finds test files correctly. * update lock files * fix: resolve Bun test runner issues in CircleCI orb - Fix Bun native test runner to output JUnit results to junit.xml - Fix Bun + Jest mode to look for results at junit.xml instead of test-results - Add test case for Bun native runner with custom test-results-path - Remove incorrect post_install_steps verification from Bun native test job * fix: linter errors, rm trailing spaces --------- Co-authored-by: Mateo Arboleda <[email protected]>
1 parent 49e8134 commit 88a8654

23 files changed

+1662
-58
lines changed

.circleci/test-deploy.yml

Lines changed: 172 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,23 @@ jobs:
6464
echo "pnpm version 9.7.1 not found"
6565
exit 1
6666
fi
67+
integration-test-install-bun-specified:
68+
parameters:
69+
os:
70+
type: executor
71+
executor: <<parameters.os>>
72+
steps:
73+
- checkout
74+
- node/install:
75+
nvm-cache-key: v2
76+
- node/install-bun:
77+
version: "1.2.22"
78+
- run:
79+
command: |
80+
if ! bun --version | grep -q "1.2.22"; then
81+
echo "Bun version 1.2.22 not found"
82+
exit 1
83+
fi
6784
integration-test-reinstall-yarn:
6885
machine:
6986
image: ubuntu-2004:current
@@ -95,7 +112,7 @@ jobs:
95112
docker:
96113
- image: cimg/ruby:3.3.5-browsers
97114
steps:
98-
- node/install:
115+
- node/install:
99116
install-yarn: true
100117
node-version: '22.11.0'
101118

@@ -192,13 +209,43 @@ jobs:
192209
command: |
193210
rm ~/project/sample/package-lock.json
194211
rm ~/project/sample/yarn.lock
212+
rm ~/project/sample/bun.lock
195213
- node/install-pnpm:
196214
version: "9.12.3"
197215
- node/install-packages:
198216
pkg-manager: pnpm
199217
cache-version: pnpm-v1
200218
app-dir: "~/project/sample"
201219
- run: cd ~/project/sample && pnpm test
220+
integration-test-bun:
221+
parameters:
222+
resource_class:
223+
type: enum
224+
default: medium
225+
description: Configure the executor resource class
226+
enum:
227+
- medium
228+
- arm.medium
229+
executor:
230+
name: node/default
231+
resource_class: <<parameters.resource_class>>
232+
steps:
233+
- checkout
234+
- run:
235+
name: Remove other lock files and create bun lockfile
236+
command: |
237+
rm ~/project/sample/package-lock.json
238+
rm ~/project/sample/yarn.lock
239+
rm ~/project/sample/pnpm-lock.yaml
240+
rm ~/project/sample/yarn-berry.lock
241+
- node/install-bun:
242+
version: "1.2.22"
243+
- node/install-packages:
244+
pkg-manager: bun
245+
cache-path: ~/.bun/install/cache
246+
cache-version: bun-v1
247+
app-dir: "~/project/sample"
248+
- run: cd ~/project/sample && bun test
202249
integration-test-yarn:
203250
parameters:
204251
resource_class:
@@ -274,6 +321,11 @@ workflows:
274321
matrix:
275322
parameters:
276323
os: [ linux, macos, machine ]
324+
- integration-test-install-bun-specified:
325+
filters: *filters
326+
matrix:
327+
parameters:
328+
os: [ linux, macos, machine ]
277329
- integration-test-install-latest:
278330
filters: *filters
279331
matrix:
@@ -297,6 +349,7 @@ workflows:
297349
rm ~/project/sample/pnpm-lock.yaml
298350
rm ~/project/sample/yarn.lock
299351
rm ~/project/sample/yarn-berry.lock
352+
rm ~/project/sample/bun.lock
300353
- node/test:
301354
filters: *filters
302355
name: node-yarn-jest-test-job
@@ -311,6 +364,7 @@ workflows:
311364
rm ~/project/sample/package-lock.json
312365
rm ~/project/sample/pnpm-lock.yaml
313366
rm ~/project/sample/yarn-berry.lock
367+
rm ~/project/sample/bun.lock
314368
- node/test:
315369
filters: *filters
316370
name: node-pnpm-jest-test-job
@@ -325,6 +379,7 @@ workflows:
325379
rm ~/project/sample/package-lock.json
326380
rm ~/project/sample/yarn.lock
327381
rm ~/project/sample/yarn-berry.lock
382+
rm ~/project/sample/bun.lock
328383
- node/test:
329384
filters: *filters
330385
name: node-npm-mocha-test-job
@@ -339,6 +394,7 @@ workflows:
339394
rm ~/project/sample/pnpm-lock.yaml
340395
rm ~/project/sample/yarn.lock
341396
rm ~/project/sample/yarn-berry.lock
397+
rm ~/project/sample/bun.lock
342398
- node/test:
343399
filters: *filters
344400
name: node-yarn-mocha-test-job
@@ -354,6 +410,7 @@ workflows:
354410
rm ~/project/sample/package-lock.json
355411
rm ~/project/sample/pnpm-lock.yaml
356412
rm ~/project/sample/yarn-berry.lock
413+
rm ~/project/sample/bun.lock
357414
- node/test:
358415
filters: *filters
359416
name: node-yarn-berry-mocha-test-job
@@ -369,6 +426,7 @@ workflows:
369426
rm ~/project/sample/package-lock.json
370427
rm ~/project/sample/pnpm-lock.yaml
371428
rm ~/project/sample/yarn.lock
429+
rm ~/project/sample/bun.lock
372430
rm ~/project/sample/package.json
373431
mv ~/project/sample/yarn-berry.lock ~/project/sample/yarn.lock
374432
mv ~/project/sample/package-berry.json ~/project/sample/package.json
@@ -387,6 +445,81 @@ workflows:
387445
rm ~/project/sample/package-lock.json
388446
rm ~/project/sample/yarn.lock
389447
rm ~/project/sample/yarn-berry.lock
448+
rm ~/project/sample/bun.lock
449+
- node/test:
450+
filters: *filters
451+
name: node-bun-jest-test-job
452+
app-dir: "~/project/sample"
453+
cache-version: v2
454+
test-results-for: jest
455+
pkg-manager: bun
456+
cache-path: ~/.bun/install/cache
457+
setup:
458+
- node/install-bun:
459+
version: "1.2.22"
460+
- run:
461+
name: Remove other lock files
462+
command: |
463+
rm ~/project/sample/package-lock.json
464+
rm ~/project/sample/yarn.lock
465+
rm ~/project/sample/pnpm-lock.yaml
466+
rm ~/project/sample/yarn-berry.lock
467+
- node/test:
468+
filters: *filters
469+
name: node-bun-mocha-test-job
470+
app-dir: "~/project/sample"
471+
cache-version: v2
472+
test-results-for: mocha
473+
pkg-manager: bun
474+
cache-path: ~/.bun/install/cache
475+
run-command: testmocha
476+
setup:
477+
- node/install-bun:
478+
version: "1.2.22"
479+
- run:
480+
name: Remove other lock files
481+
command: |
482+
rm ~/project/sample/package-lock.json
483+
rm ~/project/sample/yarn.lock
484+
rm ~/project/sample/pnpm-lock.yaml
485+
rm ~/project/sample/yarn-berry.lock
486+
- node/test:
487+
filters: *filters
488+
name: node-bun-native-test-job
489+
app-dir: "~/project/sample"
490+
cache-version: v2
491+
test-results-for: bun
492+
pkg-manager: bun
493+
cache-path: ~/.bun/install/cache
494+
setup:
495+
- node/install-bun:
496+
version: "1.2.22"
497+
- run:
498+
name: Remove other lock files
499+
command: |
500+
rm ~/project/sample/package-lock.json
501+
rm ~/project/sample/yarn.lock
502+
rm ~/project/sample/pnpm-lock.yaml
503+
rm ~/project/sample/yarn-berry.lock
504+
- node/test:
505+
filters: *filters
506+
name: node-bun-native-with-test-result-path-job
507+
app-dir: "~/project/sample"
508+
cache-version: v2
509+
test-results-for: bun
510+
pkg-manager: bun
511+
cache-path: ~/.bun/install/cache
512+
test-results-path: sample/bun-junit.xml
513+
setup:
514+
- node/install-bun:
515+
version: "1.2.22"
516+
- run:
517+
name: Remove other lock files
518+
command: |
519+
rm ~/project/sample/package-lock.json
520+
rm ~/project/sample/yarn.lock
521+
rm ~/project/sample/pnpm-lock.yaml
522+
rm ~/project/sample/yarn-berry.lock
390523
- node/test:
391524
filters: *filters
392525
name: node-yarn-mocha-with-test-result-path-job
@@ -403,6 +536,7 @@ workflows:
403536
rm ~/project/sample/package-lock.json
404537
rm ~/project/sample/pnpm-lock.yaml
405538
rm ~/project/sample/yarn-berry.lock
539+
rm ~/project/sample/bun.lock
406540
- node/test:
407541
filters: *filters
408542
name: node-test-results-file-job
@@ -416,6 +550,7 @@ workflows:
416550
rm ~/project/sample/pnpm-lock.yaml
417551
rm ~/project/sample/yarn.lock
418552
rm ~/project/sample/yarn-berry.lock
553+
rm ~/project/sample/bun.lock
419554
- node/test:
420555
filters: *filters
421556
name: node-test-no-junit
@@ -428,6 +563,7 @@ workflows:
428563
rm ~/project/sample/pnpm-lock.yaml
429564
rm ~/project/sample/yarn.lock
430565
rm ~/project/sample/yarn-berry.lock
566+
rm ~/project/sample/bun.lock
431567
- node/test:
432568
filters: *filters
433569
name: node-test-no-junit-new-features
@@ -445,6 +581,7 @@ workflows:
445581
rm ~/project/sample/pnpm-lock.yaml
446582
rm ~/project/sample/yarn.lock
447583
rm ~/project/sample/yarn-berry.lock
584+
rm ~/project/sample/bun.lock
448585
- node/test:
449586
filters: *filters
450587
name: node-test-with-coverage
@@ -465,6 +602,7 @@ workflows:
465602
rm ~/project/sample/pnpm-lock.yaml
466603
rm ~/project/sample/yarn.lock
467604
rm ~/project/sample/yarn-berry.lock
605+
rm ~/project/sample/bun.lock
468606
- node/run:
469607
filters: *filters
470608
name: node-run-yarn-job
@@ -479,6 +617,7 @@ workflows:
479617
rm ~/project/sample/package-lock.json
480618
rm ~/project/sample/pnpm-lock.yaml
481619
rm ~/project/sample/yarn-berry.lock
620+
rm ~/project/sample/bun.lock
482621
- node/run:
483622
filters: *filters
484623
name: node-run-upload-artifacts
@@ -500,6 +639,25 @@ workflows:
500639
rm ~/project/sample/package-lock.json
501640
rm ~/project/sample/yarn.lock
502641
rm ~/project/sample/yarn-berry.lock
642+
rm ~/project/sample/bun.lock
643+
- node/run:
644+
filters: *filters
645+
name: node-run-bun-job
646+
app-dir: "~/project/sample"
647+
cache-version: v3
648+
pkg-manager: bun
649+
bun-run: build
650+
cache-path: ~/.bun/install/cache
651+
setup:
652+
- node/install-bun:
653+
version: "1.2.22"
654+
- run:
655+
name: Remove other lock files
656+
command: |
657+
rm ~/project/sample/package-lock.json
658+
rm ~/project/sample/yarn.lock
659+
rm ~/project/sample/pnpm-lock.yaml
660+
rm ~/project/sample/yarn-berry.lock
503661
- integration-test-override-ci:
504662
matrix:
505663
alias: integration-test-override-ci
@@ -512,6 +670,12 @@ workflows:
512670
parameters:
513671
resource_class: [arm.medium, medium]
514672
filters: *filters
673+
- integration-test-bun:
674+
matrix:
675+
alias: integration-test-bun
676+
parameters:
677+
resource_class: [arm.medium, medium]
678+
filters: *filters
515679
- integration-test-override-ci-windows:
516680
filters: *filters
517681
- integration-test-yarn:
@@ -545,9 +709,12 @@ workflows:
545709
- integration-test-install-latest
546710
- integration-test-install-lts
547711
- integration-test-install-pnpm
712+
- integration-test-install-bun-specified
548713
- integration-test-pnpm
714+
- integration-test-bun
549715
- integration-test-reinstall-yarn
550716
- node-yarn-mocha-with-test-result-path-job
717+
- node-bun-native-with-test-result-path-job
551718
- integration-test-override-yarn
552719
- node-yarn-mocha-test-job
553720
- node-yarn-jest-test-job
@@ -556,10 +723,14 @@ workflows:
556723
- node-test-with-coverage
557724
- node-run-npm-job
558725
- node-pnpm-mocha-test-job
726+
- node-bun-jest-test-job
727+
- node-bun-mocha-test-job
728+
- node-bun-native-test-job
559729
- node-test-no-junit
560730
- node-pnpm-jest-test-job
561731
- node-run-yarn-job
562732
- node-run-pnpm-job
733+
- node-run-bun-job
563734
- node-run-upload-artifacts
564735
github_token: GHI_TOKEN
565736
context: orb-publisher

sample/bun-tests/simple.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { expect, test } from "bun:test";
2+
3+
test("2 + 2", () => {
4+
expect(2 + 2).toBe(4);
5+
});

0 commit comments

Comments
 (0)