Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c5077e514 | ||
|
|
1255e43b02 | ||
|
|
61861d1f6a | ||
|
|
6f5bd063f5 | ||
|
|
e3914758a4 | ||
|
|
ecf28ddc73 | ||
|
|
95edc153a3 | ||
|
|
4c32875876 | ||
|
|
0ff83bfc51 | ||
|
|
ab8cb4e8f8 | ||
|
|
196aaa2bd2 | ||
|
|
3d267786b1 | ||
|
|
db6bcf6eb8 | ||
|
|
4a638a4fad | ||
|
|
563911925f | ||
|
|
b02f8a8a6e | ||
|
|
8c296f9cb7 | ||
|
|
b7a1c7ccf2 | ||
|
|
ad1208bf19 | ||
|
|
bc6f04ce3b | ||
|
|
1dbab0699e | ||
|
|
635640504f | ||
|
|
22457c87c1 | ||
|
|
237a6a77d8 | ||
|
|
53e6487b6e | ||
|
|
68643ea879 | ||
|
|
56169ab7b0 | ||
|
|
34f777aec1 | ||
|
|
7c641390eb | ||
|
|
735343b667 | ||
|
|
27ecfffdee | ||
|
|
fcc30ed971 | ||
|
|
56408e9a3f | ||
|
|
85cb7f6e7e | ||
|
|
54cb141c5c | ||
|
|
6fb6603cc1 | ||
|
|
9bdeab4320 | ||
|
|
f09eb1edd0 | ||
|
|
8f1bc2eeb3 | ||
|
|
a8913c42f4 | ||
|
|
b9d34de66d | ||
|
|
1e54087d4f | ||
|
|
4bc047ad25 | ||
|
|
f43b443c1c | ||
|
|
339e277e69 | ||
|
|
e20a54d1da | ||
|
|
3fcae870de | ||
|
|
123c6c4e2f | ||
|
|
ef00e4ac8e | ||
|
|
43b2dc9ae8 | ||
|
|
45d2c09359 | ||
|
|
6ef34ab578 | ||
|
|
f4d14e03ff | ||
|
|
8f24390df0 | ||
|
|
932c3b236c | ||
|
|
9e6479509b | ||
|
|
194c60efc3 | ||
|
|
d3603274ac | ||
|
|
0f37bd8169 | ||
|
|
12944059f7 | ||
|
|
8642d99a51 | ||
|
|
40646b1808 | ||
|
|
94177e527c | ||
|
|
9b21598af8 | ||
|
|
c7420ae597 | ||
|
|
c0059f0222 | ||
|
|
e900e6b108 | ||
|
|
a93230df19 | ||
|
|
830e319e28 | ||
|
|
6be87460e3 | ||
|
|
bd26ebd2c7 | ||
|
|
a1800f471a | ||
|
|
5da0b0b067 | ||
|
|
c34bee2511 | ||
|
|
67e559db2c | ||
|
|
4573031972 | ||
|
|
1c8c9a7615 | ||
|
|
13974bf408 | ||
|
|
157143337b | ||
|
|
c7179230d0 | ||
|
|
15050a7632 | ||
|
|
a730821cf4 | ||
|
|
8c368db359 | ||
|
|
41bc2e859b | ||
|
|
3c2d6a32bd | ||
|
|
3f252a86a6 | ||
|
|
9c14b74b45 | ||
|
|
ed9eb0969c | ||
|
|
91e57dc649 | ||
|
|
37c5fa5bfd | ||
|
|
29cb413d63 | ||
|
|
0ec953ee6d | ||
|
|
21ca0e24af | ||
|
|
673843c5ea | ||
|
|
38a9038faf | ||
|
|
1e0686b2cc | ||
|
|
a11484a419 | ||
|
|
fe160cf381 | ||
|
|
dbb8e61d45 | ||
|
|
a99ac77932 | ||
|
|
fe4b2b1cd6 | ||
|
|
10e847eceb | ||
|
|
b3fb4f3421 | ||
|
|
f5a14b237f | ||
|
|
e2c23afd2e | ||
|
|
befdce7132 | ||
|
|
3c39374369 | ||
|
|
3e21e45aa4 | ||
|
|
3b03c8d63a | ||
|
|
bc3424761e | ||
|
|
962df21a50 | ||
|
|
c3404c3d6b | ||
|
|
f391a17228 | ||
|
|
24c8fd036a | ||
|
|
89f6825456 | ||
|
|
079e10bfd6 | ||
|
|
3532147424 | ||
|
|
e6a8865f72 | ||
|
|
27a94d6f80 | ||
|
|
b0a04f5fb3 | ||
|
|
ddba6331f8 | ||
|
|
99221c1ae0 | ||
|
|
13923243f4 | ||
|
|
a9318b00d5 | ||
|
|
bf40fde936 | ||
|
|
92c5bc2cef | ||
|
|
37397a08ec | ||
|
|
a0f9c413e5 | ||
|
|
d744239ce1 | ||
|
|
bfac95679f | ||
|
|
640630d09e | ||
|
|
70b6cfe9d1 | ||
|
|
933334b350 | ||
|
|
c52f1f18be | ||
|
|
08cc23c06e | ||
|
|
baf23f03bc | ||
|
|
3868f53a52 | ||
|
|
627e67fd7b | ||
|
|
62d40e4bee | ||
|
|
e838800258 | ||
|
|
37657f4f9f | ||
|
|
633e7abe1e | ||
|
|
4e76ddea17 | ||
|
|
5a78c10e01 | ||
|
|
6dae544af4 | ||
|
|
054bb2f631 | ||
|
|
9f7c2a5c23 | ||
|
|
81ecfb54f4 |
@@ -0,0 +1 @@
|
||||
dist/**/* linguist-generated=true
|
||||
@@ -0,0 +1,86 @@
|
||||
name: ⚖️ Compare Bun Version
|
||||
description: Compare the installed Bun version against a version specification.
|
||||
|
||||
inputs:
|
||||
bun-version:
|
||||
description: The version spec to compare against (e.g., '1.1.0', 'canary', '>1.2.0', '1.x').
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: 🛠️ Get installed Bun version and revision
|
||||
id: bun
|
||||
shell: bash
|
||||
run: |
|
||||
echo "version=$(bun --version | tr -d '\r\n')" >> $GITHUB_OUTPUT
|
||||
echo "revision=$(bun --revision 2>/dev/null || true)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: ⚖️ Compare versions
|
||||
shell: bash
|
||||
env:
|
||||
REQUESTED_SPEC: ${{ inputs.bun-version }}
|
||||
ACTUAL_VERSION: ${{ steps.bun.outputs.version }}
|
||||
ACTUAL_REVISION: ${{ steps.bun.outputs.revision }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
# Function to compare two semantic versions (e.g., version_compare 1.2.3 1.10.0)
|
||||
# Returns: 0 if v1 == v2, 1 if v1 > v2, 2 if v1 < v2
|
||||
version_compare() {
|
||||
if [[ "$1" == "$2" ]]; then return 0; fi
|
||||
local lowest=$(printf '%s\n' "$1" "$2" | sort -V | head -n1)
|
||||
if [[ "$1" == "$lowest" ]]; then return 2; else return 1; fi
|
||||
}
|
||||
|
||||
echo "Requested spec: ${REQUESTED_SPEC}"
|
||||
echo "Actual version: ${ACTUAL_VERSION}"
|
||||
|
||||
# Case 1: 'latest' - always passes
|
||||
if [[ "${REQUESTED_SPEC}" == "latest" ]]; then
|
||||
echo "OK: Skipping explicit version check for 'latest'."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Case 2: 'canary' - check for 'canary' in revision or version string
|
||||
if [[ "${REQUESTED_SPEC}" == "canary" ]]; then
|
||||
if [[ "${ACTUAL_REVISION}" == *canary* ]] || [[ "${ACTUAL_VERSION}" == *canary* ]]; then
|
||||
echo "OK: Detected canary build (version: ${ACTUAL_VERSION}, revision: ${ACTUAL_REVISION:-n/a})."
|
||||
exit 0
|
||||
else
|
||||
echo "Error: Expected a canary build, but got ${ACTUAL_VERSION} (revision: ${ACTUAL_REVISION:-n/a})."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Case 3: Semver ranges (e.g., >1.0.0, <2, 1.x, 1.1.0)
|
||||
op_part=$(echo "${REQUESTED_SPEC}" | sed -E 's/^([><=]*).*/\1/')
|
||||
version_part=$(echo "${REQUESTED_SPEC}" | sed -E 's/^[><= ]*//')
|
||||
|
||||
op="${op_part:-==}"
|
||||
version_base="${version_part//.x/}"
|
||||
|
||||
# Handle wildcards like '1.x' or '1'
|
||||
if [[ "${version_part}" == *.x* ]] || { [[ ! "${version_part}" == *.* ]] && [[ "${op}" == "==" ]]; }; then
|
||||
if [[ "${ACTUAL_VERSION}" == "${version_base}" || "${ACTUAL_VERSION}" == "${version_base}".* ]]; then
|
||||
echo "OK: Version ${ACTUAL_VERSION} matches wildcard spec '${REQUESTED_SPEC}'."
|
||||
exit 0
|
||||
else
|
||||
echo "Error: Version ${ACTUAL_VERSION} does not match wildcard spec '${REQUESTED_SPEC}'."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Perform comparison for >, <, >=, <=, ==
|
||||
version_compare "${ACTUAL_VERSION}" "${version_part}" && result=0 || result=$?
|
||||
|
||||
case "${op}" in
|
||||
'==') if [[ ${result} -ne 0 ]]; then echo "Error: Expected version ${version_part}, but got ${ACTUAL_VERSION}." && exit 1; fi ;;
|
||||
'>') if [[ ${result} -ne 1 ]]; then echo "Error: Expected version > ${version_part}, but got ${ACTUAL_VERSION}." && exit 1; fi ;;
|
||||
'<') if [[ ${result} -ne 2 ]]; then echo "Error: Expected version < ${version_part}, but got ${ACTUAL_VERSION}." && exit 1; fi ;;
|
||||
'>=') if [[ ${result} -eq 2 ]]; then echo "Error: Expected version >= ${version_part}, but got ${ACTUAL_VERSION}." && exit 1; fi ;;
|
||||
'<=') if [[ ${result} -eq 1 ]]; then echo "Error: Expected version <= ${version_part}, but got ${ACTUAL_VERSION}." && exit 1; fi ;;
|
||||
*) echo "Error: Unsupported operator '${op}' in spec '${REQUESTED_SPEC}'." && exit 1 ;;
|
||||
esac
|
||||
|
||||
echo "OK: Version ${ACTUAL_VERSION} satisfies spec '${REQUESTED_SPEC}'."
|
||||
@@ -0,0 +1,32 @@
|
||||
name: autofix.ci # Must be named this for autofix.ci to work
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
format:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 📥 Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: 🛠️ Setup Bun
|
||||
uses: ./
|
||||
|
||||
- name: 📦 Install Dependencies
|
||||
run: bun install
|
||||
|
||||
- name: 🧹 Format
|
||||
run: |
|
||||
bun run format
|
||||
bun run build
|
||||
|
||||
- name: 💾 Commit
|
||||
uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 # v1.3.2
|
||||
@@ -0,0 +1,27 @@
|
||||
name: 🚀 Release new action version
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [released]
|
||||
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
TAG_NAME:
|
||||
description: Tag name that the major tag will point to
|
||||
required: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
update_tag:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- uses: actions/publish-action@23f4c6f12633a2da8f44938b71fde9afec138fb4 # v0.4.0
|
||||
env:
|
||||
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
|
||||
with:
|
||||
source-tag: ${{ env.TAG_NAME }}
|
||||
+273
-18
@@ -1,29 +1,284 @@
|
||||
name: test
|
||||
name: 🧪 Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
bun-version:
|
||||
["latest", "0.1.3"]
|
||||
|
||||
remove-cache:
|
||||
runs-on: ubuntu-latest
|
||||
permissions: write-all
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: 📥 Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: 🗑️ Remove cache
|
||||
run: gh cache delete --all || true
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
tests:
|
||||
name: Tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Setup Bun
|
||||
uses: ./
|
||||
with:
|
||||
bun-version: ${{ matrix.bun-version }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
no-cache: true
|
||||
|
||||
- name: Try bun
|
||||
run: bun --version
|
||||
- name: Install dependencies
|
||||
run: bun install
|
||||
|
||||
- name: Run tests
|
||||
run: bun test --coverage
|
||||
|
||||
setup-bun:
|
||||
runs-on: ${{ matrix.os }}
|
||||
continue-on-error: true
|
||||
needs: [remove-cache, tests]
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macos-latest
|
||||
- windows-latest
|
||||
- windows-11-arm
|
||||
bun-version:
|
||||
- latest
|
||||
- canary
|
||||
- "1.1.0"
|
||||
- "1.3.10"
|
||||
- "1.x"
|
||||
- "1"
|
||||
- "> 1.0.0"
|
||||
- "< 2"
|
||||
# https://github.com/oven-sh/setup-bun/issues/37
|
||||
# - "1.x"
|
||||
# - "1"
|
||||
# - "> 1.0.0"
|
||||
# - "< 2"
|
||||
# Disable <sha> support for now. This is because Github Artifacts
|
||||
# expire after 90 days, and we don't have another source of truth yet.
|
||||
# - "822a00c4d508b54f650933a73ca5f4a3af9a7983" # 1.0.0 commit
|
||||
|
||||
steps:
|
||||
- name: 📥 Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: 🛠️ Setup Bun
|
||||
uses: ./
|
||||
id: setup_bun
|
||||
with:
|
||||
bun-version: ${{ matrix.bun-version }}
|
||||
no-cache: true
|
||||
|
||||
- name: ▶️ Run Bun
|
||||
id: run_bun
|
||||
run: |
|
||||
bun --version
|
||||
|
||||
- name: ⚖️ Verify Bun version
|
||||
uses: ./.github/actions/compare-bun-version
|
||||
with:
|
||||
bun-version: ${{ matrix.bun-version }}
|
||||
|
||||
setup-bun-from-file:
|
||||
name: setup-bun from (${{ matrix.os }}, ${{ matrix.file.name }})
|
||||
runs-on: ${{ matrix.os }}
|
||||
continue-on-error: true
|
||||
needs: [remove-cache, tests]
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macos-latest
|
||||
- windows-latest
|
||||
- windows-11-arm
|
||||
|
||||
file:
|
||||
- name: package.json (packageManager [email protected])
|
||||
file: package.json
|
||||
run: |
|
||||
echo "$(jq '. += {"packageManager": "[email protected]"}' package.json)" > package.json
|
||||
|
||||
- name: foo/package.json (packageManager [email protected])
|
||||
file: foo/package.json
|
||||
run: |
|
||||
mkdir -p foo
|
||||
echo "$(jq '. += {"packageManager": "[email protected]"}' package.json)" > foo/package.json
|
||||
|
||||
- name: package.json (packageManager yarn@[email protected])
|
||||
file: package.json
|
||||
run: |
|
||||
echo "$(jq '. += {"packageManager": "yarn@[email protected]"}' package.json)" > package.json
|
||||
|
||||
- name: package.json (engines [email protected])
|
||||
file: package.json
|
||||
run: |
|
||||
echo "$(jq '.engines = {"bun": "1.1.0"}' package.json)" > package.json
|
||||
|
||||
- name: .tool-versions (bun 1.1.0)
|
||||
file: .tool-versions
|
||||
run: echo "bun 1.1.0" > .tool-versions
|
||||
|
||||
- name: .tool-versions (bun1.1.0)
|
||||
file: .tool-versions
|
||||
run: echo "bun1.1.0" > .tool-versions
|
||||
|
||||
- name: .tool-versions (bun 1.1.0)
|
||||
file: .tool-versions
|
||||
run: echo "bun 1.1.0" > .tool-versions
|
||||
|
||||
- name: .bumrc (1.1.0)
|
||||
file: .bumrc
|
||||
run: echo "1.1.0" > .bumrc
|
||||
|
||||
- name: .bun-version (1.1.0)
|
||||
file: .bun-version
|
||||
run: echo "1.1.0" > .bun-version
|
||||
|
||||
steps:
|
||||
- name: 📥 Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: 📄 Setup file
|
||||
run: ${{ matrix.file.run }}
|
||||
|
||||
- name: 🛠️ Setup Bun
|
||||
uses: ./
|
||||
with:
|
||||
bun-version-file: ${{ matrix.file.file }}
|
||||
no-cache: true
|
||||
|
||||
- name: ⚖️ Compare versions
|
||||
uses: ./.github/actions/compare-bun-version
|
||||
with:
|
||||
bun-version: "1.1.0"
|
||||
|
||||
setup-bun-from-package-json-without-specified-field:
|
||||
name: setup-bun from (${{ matrix.os }}, ${{ matrix.file.name }}) without specified field
|
||||
runs-on: ${{ matrix.os }}
|
||||
continue-on-error: true
|
||||
needs: [remove-cache, tests]
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macos-latest
|
||||
- windows-latest
|
||||
- windows-11-arm
|
||||
|
||||
file:
|
||||
- name: package.json (packageManager [email protected])
|
||||
file: package.json
|
||||
run: |
|
||||
echo "$(jq '. += {"packageManager": "[email protected]"}' package.json)" > package.json
|
||||
|
||||
- name: package.json (packageManager yarn@[email protected])
|
||||
file: package.json
|
||||
run: |
|
||||
echo "$(jq '. += {"packageManager": "yarn@[email protected]"}' package.json)" > package.json
|
||||
|
||||
- name: package.json (engines [email protected])
|
||||
file: package.json
|
||||
run: |
|
||||
echo "$(jq '.engines = {"bun": "1.1.0"}' package.json)" > package.json
|
||||
|
||||
steps:
|
||||
- name: 📥 Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: 📄 Setup file
|
||||
run: ${{ matrix.file.run }}
|
||||
|
||||
- name: 🛠️ Setup Bun
|
||||
uses: ./
|
||||
with:
|
||||
no-cache: true
|
||||
|
||||
- name: ⚖️ Compare versions
|
||||
uses: ./.github/actions/compare-bun-version
|
||||
with:
|
||||
bun-version: "1.1.0"
|
||||
|
||||
setup-bun-download-url:
|
||||
name: setup-bun from (${{ matrix.os }}, download url)
|
||||
runs-on: ${{ matrix.os }}
|
||||
continue-on-error: true
|
||||
needs: [remove-cache, tests]
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
- macos-latest
|
||||
- windows-latest
|
||||
|
||||
steps:
|
||||
- name: 📥 Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: 🛠️ Setup Bun
|
||||
uses: ./
|
||||
id: setup_bun
|
||||
with:
|
||||
bun-download-url: "https://github.com/oven-sh/bun/releases/latest/download/bun-${{runner.os == 'macOS' && 'darwin' || runner.os}}-${{ runner.arch == 'X64' && 'x64' || 'aarch64' }}.zip"
|
||||
|
||||
- name: ▶️ Run Bun
|
||||
id: run_bun
|
||||
run: |
|
||||
bun --version
|
||||
|
||||
test-custom-registries:
|
||||
name: test installing deps from custom registries (${{ matrix.os }})
|
||||
runs-on: ${{ matrix.os }}
|
||||
continue-on-error: true
|
||||
needs: [remove-cache, tests]
|
||||
strategy:
|
||||
matrix:
|
||||
os:
|
||||
- ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: 📥 Checkout
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: 🛠️ Setup Bun
|
||||
uses: ./
|
||||
id: setup_bun
|
||||
with:
|
||||
registries: |
|
||||
https://registry.npmjs.org
|
||||
@types:https://registry.yarnpkg.com
|
||||
|
||||
- name: ▶️ Install from default registry
|
||||
run: |
|
||||
output=$(bun add is-odd --verbose --force 2>&1)
|
||||
|
||||
if echo "$output" | grep -q "HTTP/1.1 GET https://registry.npmjs.org/is-odd"; then
|
||||
echo "Successfully installed from default registry"
|
||||
else
|
||||
echo "Failed to install from default registry"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: ▶️ Install from @types registry
|
||||
run: |
|
||||
output=$(bun add @types/bun --verbose --force 2>&1)
|
||||
|
||||
if echo "$output" | grep -q "HTTP/1.1 GET https://registry.yarnpkg.com/@types%2fbun"; then
|
||||
echo "Successfully installed from @types registry"
|
||||
else
|
||||
echo "Failed to install from @types registry"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
.DS_Store
|
||||
node_modules/
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"semi": true,
|
||||
"quoteProps": "preserve"
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"recommendations": ["esbenp.prettier-vscode", "github.vscode-github-actions"]
|
||||
}
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"search.exclude": {
|
||||
"dist/**": true
|
||||
},
|
||||
// Lock changes to these files
|
||||
"files.readonlyInclude": {
|
||||
"dist/**": true,
|
||||
"bun.lock": true,
|
||||
"package-lock.json": true
|
||||
},
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Toru Nagashima
|
||||
Copyright (c) 2022 Jozef Steinhübl
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -1,22 +1,99 @@
|
||||
# setup-bun
|
||||
> Huge inspiration [setup-deno](https://github.com/denoland/setup-deno)
|
||||
|
||||
Set up your GitHub Actions workflow with a specific version of Bun.
|
||||
Download, install, and setup [Bun](https://bun.sh) in GitHub Actions.
|
||||
|
||||
## Usage
|
||||
|
||||
### Latest stable
|
||||
```yaml
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
```
|
||||
|
||||
By default, if no version is specified, the action will:
|
||||
|
||||
1. Check `package.json` for the `packageManager` field (e.g., `"packageManager": "[email protected]"`)
|
||||
2. If `packageManager` doesn't exist, check `package.json` for `engines.bun`
|
||||
3. If neither exists or `package.json` is not found, use `latest`
|
||||
|
||||
You can also explicitly specify a version:
|
||||
|
||||
```yaml
|
||||
- uses: xhyrom/setup-bun@v0.1.2
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: latest
|
||||
```
|
||||
|
||||
### Specific version
|
||||
## Using version file
|
||||
|
||||
```yaml
|
||||
- uses: xhyrom/setup-bun@v0.1.2
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: "0.1.3"
|
||||
bun-version-file: ".bun-version"
|
||||
```
|
||||
|
||||
## Using custom registries
|
||||
|
||||
You can configure multiple package registries using the `registries` input. This supports both default and scoped registries with various authentication methods.
|
||||
|
||||
### Registry configuration
|
||||
|
||||
```yaml
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
registries: |
|
||||
https://registry.npmjs.org/
|
||||
@myorg:https://npm.pkg.github.com/|$GITHUB_TOKEN
|
||||
@internal:https://username:[email protected]/
|
||||
|
||||
- name: Install dependencies
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
INTERNAL_PASSWORD: ${{ secrets.INTERNAL_PASSWORD }}
|
||||
run: bun install
|
||||
```
|
||||
|
||||
#### Registry format options
|
||||
|
||||
| Type | Format |
|
||||
| ------------------------------------ | --------------------------------------------------------- |
|
||||
| Default registry | `https://registry.example.com/` |
|
||||
| Default registry with token | `https://registry.example.com/\|$TOKEN` |
|
||||
| Scoped registry | `@scope:https://registry.example.com/` |
|
||||
| Scoped registry with token | `@scope:https://registry.example.com/\|$TOKEN` |
|
||||
| Scoped registry with URL credentials | `@scope:https://username:[email protected]/` |
|
||||
|
||||
> [!IMPORTANT]
|
||||
> When using authentication, make sure to set the corresponding environment variables in your workflow steps that need access to the registries.
|
||||
|
||||
For more information about configuring registries in Bun, see the [official documentation](https://bun.sh/docs/install/registries).
|
||||
|
||||
### Override download url
|
||||
|
||||
If you need to override the download URL, you can use the `bun-download-url` input.
|
||||
|
||||
```yaml
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-download-url: "https://github.com/oven-sh/bun/releases/latest/download/bun-linux-x64.zip"
|
||||
```
|
||||
|
||||
## Inputs
|
||||
|
||||
| Name | Description | Default | Examples |
|
||||
| ------------------ | --------------------------------------------------------------------------------- | ---------------------------------------- | ------------------------------------------------ |
|
||||
| `bun-version` | The version of Bun to download and install. | Version from `package.json`, or `latest` | `canary`, `1.0.0`, `1.0.x` |
|
||||
| `bun-version-file` | The version of Bun to download and install from file. | `undefined` | `package.json`, `.bun-version`, `.tool-versions` |
|
||||
| `bun-download-url` | URL to download .zip file for Bun release | | |
|
||||
| `registry-url` | Registry URL where some private package is stored. | `undefined` | `"https://npm.pkg.github.com/"` |
|
||||
| `scope` | Scope for private packages. | `undefined` | `"@foo"`, `"@orgname"` |
|
||||
| `no-cache` | Disable caching of the downloaded executable. | `false` | `true`, `false` |
|
||||
| `token` | Personal access token (PAT) used to fetch tags from the `oven-sh/bun` repository. | `${{ github.token }}` | `${{ secrets.GITHUB_TOKEN }}` |
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description | Example |
|
||||
| ------------------ | ------------------------------------------ | ------------------------------------------------------------------ |
|
||||
| `bun-version` | The output from `bun --version`. | `1.0.0` |
|
||||
| `bun-revision` | The output from `bun --revision`. | `1.0.0+822a00c4` |
|
||||
| `bun-path` | The path to the Bun executable. | `/path/to/bun` |
|
||||
| `bun-download-url` | The URL from which Bun was downloaded. | `https://bun.sh/download/latest/linux/x64?avx2=true&profile=false` |
|
||||
| `cache-hit` | If the Bun executable was read from cache. | `true` |
|
||||
|
||||
+53
-12
@@ -1,22 +1,63 @@
|
||||
name: "Setup Bun"
|
||||
description: "Setup Bun by installing, downloading, and adding it to the path"
|
||||
author: "xHyroM"
|
||||
name: Setup Bun
|
||||
description: Download, install, and setup Bun to your path.
|
||||
author: robobun
|
||||
|
||||
branding:
|
||||
icon: "play-circle"
|
||||
color: "white"
|
||||
icon: play-circle
|
||||
color: white
|
||||
|
||||
inputs:
|
||||
bun-version:
|
||||
description: "The Bun version to install."
|
||||
default: "latest"
|
||||
github-token:
|
||||
description: "The github token secret can be passed in using {{ secrets.GITHUB_TOKEN }}"
|
||||
description: The version of Bun to install. (e.g. "latest", "canary", "1.0.0", "1.0.x", <sha>)
|
||||
required: false
|
||||
bun-version-file:
|
||||
description: The version of Bun to install from file. (e.g. "package.json", ".bun-version", ".tool-versions")
|
||||
default: null
|
||||
required: false
|
||||
bun-download-url:
|
||||
description: Override the URL to download Bun from. This skips version resolution and verifying AVX2 support.
|
||||
required: false
|
||||
registries:
|
||||
description: |
|
||||
List of package registries with authentication support. Format:
|
||||
- Default registry: https://registry.npmjs.org/
|
||||
- Default with token: https://registry.npmjs.org/|token
|
||||
- Scoped registry: @scope:https://registry.example.com/
|
||||
- Scoped with token: @scope:https://registry.example.com/|token
|
||||
- Scoped with credentials: @scope:https://user:[email protected]/
|
||||
required: false
|
||||
registry-url:
|
||||
required: false
|
||||
description: The URL of the package registry to use for installing Bun. Set the $BUN_AUTH_TOKEN environment variable to authenticate with the registry.
|
||||
deprecationMessage: "Use 'registries' input instead."
|
||||
scope:
|
||||
required: false
|
||||
description: "The scope for authenticating with the package registry."
|
||||
deprecationMessage: "Use 'registries' input instead."
|
||||
no-cache:
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
description: Disable caching of bun executable.
|
||||
token:
|
||||
required: false
|
||||
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
|
||||
description: Personal access token (PAT) used to fetch tags from oven-sh/bun repository. Recommended for resolving wildcard/range versions to avoid GitHub API rate limiting. 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.
|
||||
|
||||
outputs:
|
||||
bun-version:
|
||||
description: "The Bun version that was installed."
|
||||
description: The version of Bun that was installed.
|
||||
bun-revision:
|
||||
description: The revision of Bun that was installed.
|
||||
bun-path:
|
||||
description: The path to the Bun executable.
|
||||
bun-download-url:
|
||||
description: The URL from which Bun was downloaded.
|
||||
cache-hit:
|
||||
description: If the version of Bun was cached.
|
||||
|
||||
runs:
|
||||
using: "node12"
|
||||
main: "dist/index.js"
|
||||
using: "node24"
|
||||
main: "dist/setup/index.js"
|
||||
post: "dist/cache-save/index.js"
|
||||
post-if: success()
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
[install]
|
||||
saveTextLockfile = true
|
||||
+123
File diff suppressed because one or more lines are too long
-25
@@ -1,25 +0,0 @@
|
||||
import { getInput, info, setFailed, setOutput } from '@actions/core';
|
||||
import getGithubRelease from './utils/getGithubRelease.js';
|
||||
import install from './utils/install.js';
|
||||
const exit = (error) => {
|
||||
setFailed(error);
|
||||
process.exit();
|
||||
};
|
||||
const main = async () => {
|
||||
try {
|
||||
const version = getInput('bun-version');
|
||||
const token = getInput('github-token');
|
||||
if (!version)
|
||||
return exit('Invalid bun version.');
|
||||
const release = await getGithubRelease(version, token);
|
||||
if ((release === null || release === void 0 ? void 0 : release.message) === 'Not Found')
|
||||
return exit('Invalid bun version.');
|
||||
info(`Going to install release ${release.version}`);
|
||||
await install(release);
|
||||
setOutput('bun-version', release.tag_name);
|
||||
}
|
||||
catch (e) {
|
||||
exit(e);
|
||||
}
|
||||
};
|
||||
main();
|
||||
+143
File diff suppressed because one or more lines are too long
-19
@@ -1,19 +0,0 @@
|
||||
export default (assets) => {
|
||||
let arch;
|
||||
switch (process.arch) {
|
||||
case 'arm64':
|
||||
arch = 'aarch64';
|
||||
break;
|
||||
case 'x64':
|
||||
arch = 'x64';
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unsupported architechture ${process.arch}.`);
|
||||
}
|
||||
if (!['linux', 'darwin'].some(platform => process.platform === platform))
|
||||
throw new Error(`Unsupported platform ${process.platform}.`);
|
||||
return {
|
||||
name: `bun-${process.platform}-${arch}`,
|
||||
asset: assets.find(asset => asset.name === `bun-${process.platform}-${arch}.zip`),
|
||||
};
|
||||
};
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
import fetch from 'node-fetch';
|
||||
export default async (version, token) => {
|
||||
let url;
|
||||
if (version === 'latest')
|
||||
url = 'https://api.github.com/repos/oven-sh/bun/releases/latest';
|
||||
else
|
||||
url = `https://api.github.com/repos/oven-sh/bun/releases/tags/bun-v${version}`;
|
||||
const release = await (await fetch(url, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'User-Agent': 'setup-bun-github-action',
|
||||
'Authorization': token
|
||||
}
|
||||
})).json();
|
||||
return {
|
||||
...release,
|
||||
version: release.tag_name.replace('bun-v', '')
|
||||
};
|
||||
};
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
export default () => {
|
||||
return process.env[process.platform == 'win32' ? 'USERPROFILE' : 'HOME'];
|
||||
};
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
import { cacheDir, downloadTool, extractZip, find } from '@actions/tool-cache';
|
||||
import { restoreCache, saveCache } from '@actions/cache';
|
||||
import { addPath, info } from '@actions/core';
|
||||
import getAsset from './getAsset.js';
|
||||
import { join } from 'path';
|
||||
import { homedir } from 'os';
|
||||
export default async (release) => {
|
||||
const asset = getAsset(release.assets);
|
||||
const path = join(homedir(), '.bun', 'bin', asset.name);
|
||||
const cache = find('bun', release.version) || await restoreCache([path], `bun-${process.platform}-${asset.name}-${release.version}`);
|
||||
if (cache) {
|
||||
info(`Using cached Bun installation from ${cache}.`);
|
||||
addPath(path);
|
||||
return;
|
||||
}
|
||||
info(`Downloading Bun from ${asset.asset.browser_download_url}.`);
|
||||
const zipPath = await downloadTool(asset.asset.browser_download_url);
|
||||
const extracted = await extractZip(zipPath, join(homedir(), '.bun', 'bin'));
|
||||
const newCache = await cacheDir(extracted, 'bun', release.version);
|
||||
await saveCache([
|
||||
join(extracted, asset.name)
|
||||
], `bun-${process.platform}-${asset.name}-${release.version}`);
|
||||
info(`Cached Bun to ${newCache}.`);
|
||||
addPath(newCache);
|
||||
const bunPath = join(homedir(), '.bun', 'bin', asset.name);
|
||||
addPath(bunPath);
|
||||
};
|
||||
-1
@@ -1 +0,0 @@
|
||||
../semver/bin/semver.js
|
||||
-1
@@ -1 +0,0 @@
|
||||
../typescript/bin/tsc
|
||||
-1
@@ -1 +0,0 @@
|
||||
../typescript/bin/tsserver
|
||||
-1
@@ -1 +0,0 @@
|
||||
../uuid/bin/uuid
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright 2019 GitHub
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
# `@actions/cache`
|
||||
|
||||
> Functions necessary for caching dependencies and build outputs to improve workflow execution time.
|
||||
|
||||
See ["Caching dependencies to speed up workflows"](https://help.github.com/github/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows) for how caching works.
|
||||
|
||||
Note that GitHub will remove any cache entries that have not been accessed in over 7 days. There is no limit on the number of caches you can store, but the total size of all caches in a repository is limited to 10 GB. If you exceed this limit, GitHub will save your cache but will begin evicting caches until the total size is less than 10 GB.
|
||||
|
||||
## Usage
|
||||
|
||||
This package is used by the v2+ versions of our first party cache action. You can find an example implementation in the cache repo [here](https://github.com/actions/cache).
|
||||
|
||||
#### Save Cache
|
||||
|
||||
Saves a cache containing the files in `paths` using the `key` provided. The files would be compressed using zstandard compression algorithm if zstd is installed, otherwise gzip is used. Function returns the cache id if the cache was saved succesfully and throws an error if cache upload fails.
|
||||
|
||||
```js
|
||||
const cache = require('@actions/cache');
|
||||
const paths = [
|
||||
'node_modules',
|
||||
'packages/*/node_modules/'
|
||||
]
|
||||
const key = 'npm-foobar-d5ea0750'
|
||||
const cacheId = await cache.saveCache(paths, key)
|
||||
```
|
||||
|
||||
#### Restore Cache
|
||||
|
||||
Restores a cache based on `key` and `restoreKeys` to the `paths` provided. Function returns the cache key for cache hit and returns undefined if cache not found.
|
||||
|
||||
```js
|
||||
const cache = require('@actions/cache');
|
||||
const paths = [
|
||||
'node_modules',
|
||||
'packages/*/node_modules/'
|
||||
]
|
||||
const key = 'npm-foobar-d5ea0750'
|
||||
const restoreKeys = [
|
||||
'npm-foobar-',
|
||||
'npm-'
|
||||
]
|
||||
const cacheKey = await cache.restoreCache(paths, key, restoreKeys)
|
||||
```
|
||||
|
||||
-32
@@ -1,32 +0,0 @@
|
||||
import { DownloadOptions, UploadOptions } from './options';
|
||||
export declare class ValidationError extends Error {
|
||||
constructor(message: string);
|
||||
}
|
||||
export declare class ReserveCacheError extends Error {
|
||||
constructor(message: string);
|
||||
}
|
||||
/**
|
||||
* isFeatureAvailable to check the presence of Actions cache service
|
||||
*
|
||||
* @returns boolean return true if Actions cache service feature is available, otherwise false
|
||||
*/
|
||||
export declare function isFeatureAvailable(): boolean;
|
||||
/**
|
||||
* Restores cache from keys
|
||||
*
|
||||
* @param paths a list of file paths to restore from the cache
|
||||
* @param primaryKey an explicit key for restoring the cache
|
||||
* @param restoreKeys an optional ordered list of keys to use for restoring the cache if no cache hit occurred for key
|
||||
* @param downloadOptions cache download options
|
||||
* @returns string returns the key for the cache hit, otherwise returns undefined
|
||||
*/
|
||||
export declare function restoreCache(paths: string[], primaryKey: string, restoreKeys?: string[], options?: DownloadOptions): Promise<string | undefined>;
|
||||
/**
|
||||
* Saves a list of files with the specified key
|
||||
*
|
||||
* @param paths a list of file paths to be cached
|
||||
* @param key an explicit key for restoring the cache
|
||||
* @param options cache upload options
|
||||
* @returns number returns cacheId if the cache was saved successfully and throws an error if save fails
|
||||
*/
|
||||
export declare function saveCache(paths: string[], key: string, options?: UploadOptions): Promise<number>;
|
||||
-210
@@ -1,210 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const path = __importStar(require("path"));
|
||||
const utils = __importStar(require("./internal/cacheUtils"));
|
||||
const cacheHttpClient = __importStar(require("./internal/cacheHttpClient"));
|
||||
const tar_1 = require("./internal/tar");
|
||||
class ValidationError extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
this.name = 'ValidationError';
|
||||
Object.setPrototypeOf(this, ValidationError.prototype);
|
||||
}
|
||||
}
|
||||
exports.ValidationError = ValidationError;
|
||||
class ReserveCacheError extends Error {
|
||||
constructor(message) {
|
||||
super(message);
|
||||
this.name = 'ReserveCacheError';
|
||||
Object.setPrototypeOf(this, ReserveCacheError.prototype);
|
||||
}
|
||||
}
|
||||
exports.ReserveCacheError = ReserveCacheError;
|
||||
function checkPaths(paths) {
|
||||
if (!paths || paths.length === 0) {
|
||||
throw new ValidationError(`Path Validation Error: At least one directory or file path is required`);
|
||||
}
|
||||
}
|
||||
function checkKey(key) {
|
||||
if (key.length > 512) {
|
||||
throw new ValidationError(`Key Validation Error: ${key} cannot be larger than 512 characters.`);
|
||||
}
|
||||
const regex = /^[^,]*$/;
|
||||
if (!regex.test(key)) {
|
||||
throw new ValidationError(`Key Validation Error: ${key} cannot contain commas.`);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* isFeatureAvailable to check the presence of Actions cache service
|
||||
*
|
||||
* @returns boolean return true if Actions cache service feature is available, otherwise false
|
||||
*/
|
||||
function isFeatureAvailable() {
|
||||
return !!process.env['ACTIONS_CACHE_URL'];
|
||||
}
|
||||
exports.isFeatureAvailable = isFeatureAvailable;
|
||||
/**
|
||||
* Restores cache from keys
|
||||
*
|
||||
* @param paths a list of file paths to restore from the cache
|
||||
* @param primaryKey an explicit key for restoring the cache
|
||||
* @param restoreKeys an optional ordered list of keys to use for restoring the cache if no cache hit occurred for key
|
||||
* @param downloadOptions cache download options
|
||||
* @returns string returns the key for the cache hit, otherwise returns undefined
|
||||
*/
|
||||
function restoreCache(paths, primaryKey, restoreKeys, options) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
checkPaths(paths);
|
||||
restoreKeys = restoreKeys || [];
|
||||
const keys = [primaryKey, ...restoreKeys];
|
||||
core.debug('Resolved Keys:');
|
||||
core.debug(JSON.stringify(keys));
|
||||
if (keys.length > 10) {
|
||||
throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`);
|
||||
}
|
||||
for (const key of keys) {
|
||||
checkKey(key);
|
||||
}
|
||||
const compressionMethod = yield utils.getCompressionMethod();
|
||||
let archivePath = '';
|
||||
try {
|
||||
// path are needed to compute version
|
||||
const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, {
|
||||
compressionMethod
|
||||
});
|
||||
if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) {
|
||||
// Cache not found
|
||||
return undefined;
|
||||
}
|
||||
archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod));
|
||||
core.debug(`Archive Path: ${archivePath}`);
|
||||
// Download the cache from the cache entry
|
||||
yield cacheHttpClient.downloadCache(cacheEntry.archiveLocation, archivePath, options);
|
||||
if (core.isDebug()) {
|
||||
yield tar_1.listTar(archivePath, compressionMethod);
|
||||
}
|
||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
|
||||
yield tar_1.extractTar(archivePath, compressionMethod);
|
||||
core.info('Cache restored successfully');
|
||||
return cacheEntry.cacheKey;
|
||||
}
|
||||
catch (error) {
|
||||
const typedError = error;
|
||||
if (typedError.name === ValidationError.name) {
|
||||
throw error;
|
||||
}
|
||||
else {
|
||||
// Supress all non-validation cache related errors because caching should be optional
|
||||
core.warning(`Failed to restore: ${error.message}`);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
// Try to delete the archive to save space
|
||||
try {
|
||||
yield utils.unlinkFile(archivePath);
|
||||
}
|
||||
catch (error) {
|
||||
core.debug(`Failed to delete archive: ${error}`);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
exports.restoreCache = restoreCache;
|
||||
/**
|
||||
* Saves a list of files with the specified key
|
||||
*
|
||||
* @param paths a list of file paths to be cached
|
||||
* @param key an explicit key for restoring the cache
|
||||
* @param options cache upload options
|
||||
* @returns number returns cacheId if the cache was saved successfully and throws an error if save fails
|
||||
*/
|
||||
function saveCache(paths, key, options) {
|
||||
var _a, _b, _c, _d, _e;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
checkPaths(paths);
|
||||
checkKey(key);
|
||||
const compressionMethod = yield utils.getCompressionMethod();
|
||||
let cacheId = -1;
|
||||
const cachePaths = yield utils.resolvePaths(paths);
|
||||
core.debug('Cache Paths:');
|
||||
core.debug(`${JSON.stringify(cachePaths)}`);
|
||||
if (cachePaths.length === 0) {
|
||||
throw new Error(`Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.`);
|
||||
}
|
||||
const archiveFolder = yield utils.createTempDirectory();
|
||||
const archivePath = path.join(archiveFolder, utils.getCacheFileName(compressionMethod));
|
||||
core.debug(`Archive Path: ${archivePath}`);
|
||||
try {
|
||||
yield tar_1.createTar(archiveFolder, cachePaths, compressionMethod);
|
||||
if (core.isDebug()) {
|
||||
yield tar_1.listTar(archivePath, compressionMethod);
|
||||
}
|
||||
const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit
|
||||
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
|
||||
core.debug(`File Size: ${archiveFileSize}`);
|
||||
// For GHES, this check will take place in ReserveCache API with enterprise file size limit
|
||||
if (archiveFileSize > fileSizeLimit && !utils.isGhes()) {
|
||||
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`);
|
||||
}
|
||||
core.debug('Reserving Cache');
|
||||
const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, {
|
||||
compressionMethod,
|
||||
cacheSize: archiveFileSize
|
||||
});
|
||||
if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) {
|
||||
cacheId = (_b = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _b === void 0 ? void 0 : _b.cacheId;
|
||||
}
|
||||
else if ((reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.statusCode) === 400) {
|
||||
throw new Error((_d = (_c = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : `Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the data cap limit, not saving cache.`);
|
||||
}
|
||||
else {
|
||||
throw new ReserveCacheError(`Unable to reserve cache with key ${key}, another job may be creating this cache. More details: ${(_e = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.error) === null || _e === void 0 ? void 0 : _e.message}`);
|
||||
}
|
||||
core.debug(`Saving Cache (ID: ${cacheId})`);
|
||||
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
|
||||
}
|
||||
catch (error) {
|
||||
const typedError = error;
|
||||
if (typedError.name === ValidationError.name) {
|
||||
throw error;
|
||||
}
|
||||
else if (typedError.name === ReserveCacheError.name) {
|
||||
core.info(`Failed to save: ${typedError.message}`);
|
||||
}
|
||||
else {
|
||||
core.warning(`Failed to save: ${typedError.message}`);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
// Try to delete the archive to save space
|
||||
try {
|
||||
yield utils.unlinkFile(archivePath);
|
||||
}
|
||||
catch (error) {
|
||||
core.debug(`Failed to delete archive: ${error}`);
|
||||
}
|
||||
}
|
||||
return cacheId;
|
||||
});
|
||||
}
|
||||
exports.saveCache = saveCache;
|
||||
//# sourceMappingURL=cache.js.map
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user