Преглед изворни кода

ci: centralize bun setup to reduce duplication and improve caching

Dax Raad пре 6 месеци
родитељ
комит
3ad6f84adb

+ 20 - 0
.github/actions/setup-bun/action.yml

@@ -0,0 +1,20 @@
+name: "Setup Bun"
+description: "Setup Bun with caching and install dependencies"
+runs:
+  using: "composite"
+  steps:
+    - name: Setup Bun
+      uses: oven-sh/setup-bun@v2
+
+    - name: Cache ~/.bun
+      id: cache-bun
+      uses: actions/cache@v4
+      with:
+        path: ~/.bun
+        key: ${{ runner.os }}-bun-${{ hashFiles('bun.lockb', 'bun.lock') }}
+        restore-keys: |
+          ${{ runner.os }}-bun-
+
+    - name: Install dependencies
+      run: bun install
+      shell: bash

+ 1 - 5
.github/workflows/deploy.yml

@@ -15,11 +15,7 @@ jobs:
     steps:
     steps:
       - uses: actions/checkout@v3
       - uses: actions/checkout@v3
 
 
-      - uses: oven-sh/setup-bun@v1
-        with:
-          bun-version: 1.3.0
-
-      - run: bun install
+      - uses: ./.github/actions/setup-bun
 
 
       - run: bun sst deploy --stage=${{ github.ref_name }}
       - run: bun sst deploy --stage=${{ github.ref_name }}
         env:
         env:

+ 1 - 4
.github/workflows/format.yml

@@ -20,13 +20,10 @@ jobs:
           token: ${{ secrets.GITHUB_TOKEN }}
           token: ${{ secrets.GITHUB_TOKEN }}
 
 
       - name: Setup Bun
       - name: Setup Bun
-        uses: oven-sh/setup-bun@v1
-        with:
-          bun-version: 1.3.0
+        uses: ./.github/actions/setup-bun
 
 
       - name: run
       - name: run
         run: |
         run: |
-          bun install
           ./script/format.ts
           ./script/format.ts
         env:
         env:
           CI: true
           CI: true

+ 1 - 4
.github/workflows/publish-vscode.yml

@@ -19,16 +19,13 @@ jobs:
         with:
         with:
           fetch-depth: 0
           fetch-depth: 0
 
 
-      - uses: oven-sh/setup-bun@v2
-        with:
-          bun-version: 1.3.0
+      - uses: ./.github/actions/setup-bun
 
 
       - run: git fetch --force --tags
       - run: git fetch --force --tags
       - run: bun install -g @vscode/vsce
       - run: bun install -g @vscode/vsce
 
 
       - name: Publish
       - name: Publish
         run: |
         run: |
-          bun install
           ./script/publish
           ./script/publish
         working-directory: ./sdks/vscode
         working-directory: ./sdks/vscode
         env:
         env:

+ 1 - 14
.github/workflows/publish.yml

@@ -35,18 +35,7 @@ jobs:
           cache: true
           cache: true
           cache-dependency-path: go.sum
           cache-dependency-path: go.sum
 
 
-      - uses: oven-sh/setup-bun@v2
-        with:
-          bun-version: 1.3.0
-
-      - name: Cache ~/.bun
-        id: cache-bun
-        uses: actions/cache@v3
-        with:
-          path: ~/.bun
-          key: ${{ runner.os }}-bun-1-3-0-${{ hashFiles('bun.lock') }}
-          restore-keys: |
-            ${{ runner.os }}-bun-1-3-0-
+      - uses: ./.github/actions/setup-bun
 
 
       - name: Install makepkg
       - name: Install makepkg
         run: |
         run: |
@@ -60,8 +49,6 @@ jobs:
           git config --global user.email "[email protected]"
           git config --global user.email "[email protected]"
           git config --global user.name "opencode"
           git config --global user.name "opencode"
           ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts || true
           ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts || true
-      - name: Install dependencies
-        run: bun install
 
 
       - name: Install OpenCode
       - name: Install OpenCode
         run: curl -fsSL https://opencode.ai/install | bash
         run: curl -fsSL https://opencode.ai/install | bash

+ 1 - 15
.github/workflows/snapshot.yml

@@ -24,21 +24,7 @@ jobs:
           cache: true
           cache: true
           cache-dependency-path: go.sum
           cache-dependency-path: go.sum
 
 
-      - uses: oven-sh/setup-bun@v2
-        with:
-          bun-version: 1.3.0
-
-      - name: Cache ~/.bun
-        id: cache-bun
-        uses: actions/cache@v3
-        with:
-          path: ~/.bun
-          key: ${{ runner.os }}-bun-1-3-0-${{ hashFiles('bun.lock') }}
-          restore-keys: |
-            ${{ runner.os }}-bun-1-3-0-
-
-      - name: Install dependencies
-        run: bun install
+      - uses: ./.github/actions/setup-bun
 
 
       - name: Publish
       - name: Publish
         run: |
         run: |

+ 1 - 3
.github/workflows/stats.yml

@@ -16,9 +16,7 @@ jobs:
         uses: actions/checkout@v4
         uses: actions/checkout@v4
 
 
       - name: Setup Bun
       - name: Setup Bun
-        uses: oven-sh/setup-bun@v2
-        with:
-          bun-version: latest
+        uses: ./.github/actions/setup-bun
 
 
       - name: Run stats script
       - name: Run stats script
         run: bun script/stats.ts
         run: bun script/stats.ts

+ 1 - 4
.github/workflows/test.yml

@@ -18,15 +18,12 @@ jobs:
           token: ${{ secrets.GITHUB_TOKEN }}
           token: ${{ secrets.GITHUB_TOKEN }}
 
 
       - name: Setup Bun
       - name: Setup Bun
-        uses: oven-sh/setup-bun@v1
-        with:
-          bun-version: 1.3.0
+        uses: ./.github/actions/setup-bun
 
 
       - name: run
       - name: run
         run: |
         run: |
           git config --global user.email "[email protected]"
           git config --global user.email "[email protected]"
           git config --global user.name "opencode"
           git config --global user.name "opencode"
-          bun install
           bun turbo test
           bun turbo test
         env:
         env:
           CI: true
           CI: true

+ 1 - 6
.github/workflows/typecheck.yml

@@ -13,12 +13,7 @@ jobs:
         uses: actions/checkout@v4
         uses: actions/checkout@v4
 
 
       - name: Setup Bun
       - name: Setup Bun
-        uses: oven-sh/setup-bun@v1
-        with:
-          bun-version: 1.3.0
-
-      - name: Install dependencies
-        run: bun install
+        uses: ./.github/actions/setup-bun
 
 
       - name: Run typecheck
       - name: Run typecheck
         run: bun typecheck
         run: bun typecheck