Skip to content

Commit 733a59b

Browse files
authored
Merge pull request #200 from dsm23/ci/update-bun-based-gh-actions
ci(bun setup): update bun-based gh actions
2 parents 8d1d54e + 5a8104c commit 733a59b

File tree

5 files changed

+51
-68
lines changed

5 files changed

+51
-68
lines changed

.github/actions/setup/action.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Setup bun action
2+
description: |
3+
Configures bun, cache, performs bun install
4+
5+
inputs:
6+
bun-run-install:
7+
description: Whether to run bun install
8+
required: false
9+
default: "true"
10+
bun-restore-cache:
11+
description: Whether to restore cache
12+
required: false
13+
default: "true"
14+
bun-install-cache-key:
15+
description: The cache key for the bun install cache
16+
required: false
17+
default: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
18+
19+
runs:
20+
using: composite
21+
steps:
22+
- name: Restore bun install cache
23+
if: ${{ inputs.bun-restore-cache == 'true' }}
24+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
25+
with:
26+
# See here for caching with `bun` https://github.com/actions/cache/blob/main/examples.md#bun
27+
path: |
28+
path: ~/.bun/install/cache
29+
# Generate a new cache whenever packages or source files change.
30+
key: ${{ inputs.bun-install-cache-key }}
31+
# If source files changed but packages didn't, rebuild from a prior cache.
32+
restore-keys: |
33+
${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}-
34+
35+
- name: Set up Bun
36+
uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
37+
with:
38+
bun-version-file: ".bun-version"
39+
40+
- name: Run bun install
41+
if: ${{ inputs.bun-run-install == 'true' }}
42+
shell: bash
43+
run: bun install --frozen-lockfile

.github/workflows/build.yml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,8 @@ jobs:
2626
with:
2727
persist-credentials: false
2828

29-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
30-
with:
31-
# See here for caching with `bun` https://github.com/actions/cache/blob/main/examples.md#bun
32-
path: .next/cache
33-
# Generate a new cache whenever packages or source files change.
34-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
35-
# If source files changed but packages didn't, rebuild from a prior cache.
36-
restore-keys: |
37-
${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}-
38-
39-
- name: Set up Bun
40-
uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
41-
with:
42-
bun-version-file: ".bun-version"
43-
44-
- name: Install dependencies
45-
run: bun install --frozen-lockfile
29+
- name: Bun setup
30+
uses: ./.github/actions/setup
4631

4732
- name: Build check
4833
run: bun run build

.github/workflows/format.yml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,8 @@ jobs:
2626
with:
2727
persist-credentials: false
2828

29-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
30-
with:
31-
# See here for caching with `bun` https://github.com/actions/cache/blob/main/examples.md#bun
32-
path: .next/cache
33-
# Generate a new cache whenever packages or source files change.
34-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
35-
# If source files changed but packages didn't, rebuild from a prior cache.
36-
restore-keys: |
37-
${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}-
38-
39-
- name: Set up Bun
40-
uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
41-
with:
42-
bun-version-file: ".bun-version"
43-
44-
- name: Install dependencies
45-
run: bun install --frozen-lockfile
29+
- name: Bun setup
30+
uses: ./.github/actions/setup
4631

4732
- name: Format check
4833
run: bun run fmt.check

.github/workflows/lint.yml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,8 @@ jobs:
2626
with:
2727
persist-credentials: false
2828

29-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
30-
with:
31-
# See here for caching with `bun` https://github.com/actions/cache/blob/main/examples.md#bun
32-
path: .next/cache
33-
# Generate a new cache whenever packages or source files change.
34-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
35-
# If source files changed but packages didn't, rebuild from a prior cache.
36-
restore-keys: |
37-
${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}-
38-
39-
- name: Set up Bun
40-
uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
41-
with:
42-
bun-version-file: ".bun-version"
43-
44-
- name: Install dependencies
45-
run: bun install --frozen-lockfile
29+
- name: Bun setup
30+
uses: ./.github/actions/setup
4631

4732
- name: Lint check
4833
run: bun run lint

.github/workflows/unit-testing.yml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,8 @@ jobs:
2626
with:
2727
persist-credentials: false
2828

29-
- uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
30-
with:
31-
# See here for caching with `bun` https://github.com/actions/cache/blob/main/examples.md#bun
32-
path: .next/cache
33-
# Generate a new cache whenever packages or source files change.
34-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }}
35-
# If source files changed but packages didn't, rebuild from a prior cache.
36-
restore-keys: |
37-
${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lockb') }}-
38-
39-
- name: Set up Bun
40-
uses: oven-sh/setup-bun@735343b667d3e6f658f44d0eca948eb6282f2b76 # v2.0.2
41-
with:
42-
bun-version-file: ".bun-version"
43-
44-
- name: Install dependencies
45-
run: bun install --frozen-lockfile
29+
- name: Bun setup
30+
uses: ./.github/actions/setup
4631

4732
- name: Unit & Integration tests
4833
run: bun run test --coverage

0 commit comments

Comments
 (0)