Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support cache type bun #1035

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ See [action.yml](action.yml)
node-version: ''

# File containing the version Spec of the version to use. Examples: package.json, .nvmrc, .node-version, .tool-versions.
# If node-version and node-version-file are both provided the action will use version from node-version.
# If node-version and node-version-file are both provided the action will use version from node-version.
node-version-file: ''

# Set this option if you want the action to check for the latest available version
# Set this option if you want the action to check for the latest available version
# that satisfies the version spec.
# It will only get affect for lts Nodejs versions (12.x, >=10.15.0, lts/Hydrogen).
# It will only get affect for lts Nodejs versions (12.x, >=10.15.0, lts/Hydrogen).
# Default: false
check-latest: false

# Target architecture for Node to use. Examples: x86, x64. Will use system architecture by default.
# Default: ''. The action use system architecture by default
# Default: ''. The action use system architecture by default
architecture: ''

# Used to pull node distributions from https://github.com/actions/node-versions.
# Since there's a default, this is typically not supplied by the user.
# When running this action on github.com, the default value is sufficient.
# Used to pull node distributions from https://github.com/actions/node-versions.
# Since there's a default, this is typically not supplied by the user.
# When running this action on github.com, the default value is sufficient.
# When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting.
#
# We recommend using a service account with the least permissions necessary. Also
Expand All @@ -52,23 +52,23 @@ See [action.yml](action.yml)
# Default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
token: ''

# Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm.
# Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm, bun.
# Package manager should be pre-installed
# Default: ''
cache: ''

# Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc.
# It will generate hash from the target file for primary key. It works only If cache is specified.
# Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc.
# It will generate hash from the target file for primary key. It works only If cache is specified.
# Supports wildcards or a list of file names for caching multiple dependencies.
# Default: ''
cache-dependency-path: ''

# Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file,
# Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file,
# and set up auth to read in from env.NODE_AUTH_TOKEN.
# Default: ''
registry-url: ''

# Optional scope for authenticating against scoped registries.
# Optional scope for authenticating against scoped registries.
# Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/).
# Default: ''
scope: ''
Expand Down Expand Up @@ -120,7 +120,7 @@ It's **always** recommended to commit the lockfile of your package manager for s

## Caching global packages data

The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under the hood for caching global packages data but requires less configuration settings. Supported package managers are `npm`, `yarn`, `pnpm` (v6.10+). The `cache` input is optional, and caching is turned off by default.
The action has a built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/cache) under the hood for caching global packages data but requires less configuration settings. Supported package managers are `npm`, `yarn`, `pnpm` (v6.10+), `bun`. The `cache` input is optional, and caching is turned off by default.

The action defaults to search for the dependency file (`package-lock.json`, `npm-shrinkwrap.json` or `yarn.lock`) in the repository root, and uses its hash as a part of the cache key. Use `cache-dependency-path` for cases when multiple dependency files are used, or they are located in different subdirectories.

Expand Down
1 change: 1 addition & 0 deletions __tests__/cache-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ describe('cache-utils', () => {
['npm', utils.supportedPackageManagers.npm],
['pnpm', utils.supportedPackageManagers.pnpm],
['yarn', utils.supportedPackageManagers.yarn],
['bun', utils.supportedPackageManagers.bun],
['yarn1', null],
['yarn2', null],
['npm7', null]
Expand Down
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ inputs:
description: Used to pull node distributions from node-versions. Since there's a default, this is typically not supplied by the user. When running this action on github.com, the default value is sufficient. When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting.
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
cache:
description: 'Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm.'
description: 'Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm, bun.'
cache-dependency-path:
description: 'Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies.'
description: 'Used to specify the path to a dependency file: package-lock.json, yarn.lock, bun.lockb, etc. Supports wildcards or a list of file names for caching multiple dependencies.'
# TODO: add input to control forcing to pull from cloud or dist.
# escape valve for someone having issues or needing the absolute latest which isn't cached yet
outputs:
cache-hit:
cache-hit:
description: 'A boolean value to indicate if a cache was hit.'
node-version:
description: 'The installed node version.'
Expand Down
9 changes: 9 additions & 0 deletions dist/cache-save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83594,6 +83594,11 @@ exports.supportedPackageManagers = {
}
return stdOut;
})
},
bun: {
name: 'bun',
lockFilePatterns: ['bun.lockb'],
getCacheFolderPath: () => (0, exports.getCommandOutputNotEmpty)('bun pm cache', 'Could not get bun cache folder path')
}
};
const getCommandOutput = (toolCommand, cwd) => __awaiter(void 0, void 0, void 0, function* () {
Expand Down Expand Up @@ -83625,6 +83630,9 @@ const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void
else if (packageManager === 'yarn') {
return exports.supportedPackageManagers.yarn;
}
else if (packageManager === 'bun') {
return exports.supportedPackageManagers.bun;
}
else {
return null;
}
Expand Down Expand Up @@ -83792,6 +83800,7 @@ var LockType;
LockType["Npm"] = "npm";
LockType["Pnpm"] = "pnpm";
LockType["Yarn"] = "yarn";
LockType["Bun"] = "bun";
})(LockType || (exports.LockType = LockType = {}));
var State;
(function (State) {
Expand Down
Loading