aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/bun-mac-aarch64.yml
blob: b4c148916d85d56baf99f3efa2fcdafc82541865 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
name: bun-macOS-aarch64

concurrency:
  group: bun-macOS-aarch64-${{ github.ref }}
  cancel-in-progress: true

env:
  REGISTRY: ghcr.io
  IMAGE_NAME: ${{ github.repository }}
  TEST_TAG: bun-test'

on:
  push:
    branches: [main]
    paths:
      - "src/**/*"
      - "test/**/*"
      - "build.zig"
      - "Makefile"
      - "Dockerfile"
  pull_request:
    branches: [main]
    paths:
      - "src/**/*"
      - "test/**/*"
      - "build.zig"
      - "Makefile"
      - "Dockerfile"
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

jobs:
  macos-object-files:
    name: macOS Object
    runs-on: med-ubuntu
    if: github.repository_owner == 'oven-sh'
    strategy:
      matrix:
        include:
          # - cpu: nehalem
          #   arch: x86_64
          #   tag: bun-obj-darwin-x64-baseline
          # - cpu: haswell
          #   arch: x86_64
          #   tag: bun-obj-darwin-x64
          - cpu: native
            arch: aarch64
            tag: bun-obj-darwin-aarch64
    steps:
      - uses: actions/checkout@v3
        with:
          submodules: recursive
      - uses: docker/setup-buildx-action@v2
        id: buildx
        with:
          install: true
      - name: Run
        run: |
          rm -rf ${{runner.temp}}/release
      - name: Login to GitHub Container Registry
        uses: docker/login-action@v2
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Build and push
        uses: docker/build-push-action@v3
        if: runner.arch == 'X64'
        with:
          context: .
          push: false
          cache-from: type=gha
          cache-to: type=gha,mode=min
          build-args: |
            ARCH=${{ matrix.arch }}
            BUILDARCH=amd64
            BUILD_MACHINE_ARCH=x86_64
            CPU_TARGET=${{ matrix.cpu }}
            TRIPLET=${{matrix.arch}}-macos-none
            GIT_SHA=${{github.sha}}
          platforms: linux/amd64
          target: build_release_obj
          outputs: type=local,dest=${{runner.temp}}/release
      - name: Build and push
        uses: docker/build-push-action@v3
        if: runner.arch == 'ARM64'
        with:
          context: .
          push: false
          cache-from: type=gha
          cache-to: type=gha,mode=min
          build-args: |
            ARCH=${{ matrix.arch }}
            BUILDARCH=arm64
            BUILD_MACHINE_ARCH=aarch64
            CPU_TARGET=${{ matrix.cpu }}
            TRIPLET=${{matrix.arch}}-macos-none
            GIT_SHA=${{github.sha}}
          platforms: linux/arm64
          target: build_release_obj
          outputs: type=local,dest=${{runner.temp}}/release
      - uses: actions/upload-artifact@v3
        with:
          name: ${{ matrix.tag }}
          path: ${{runner.temp}}/release/bun.o
  macOS-cpp:
    name: macOS C++
    runs-on: ${{ matrix.runner }}
    if: github.repository_owner == 'oven-sh'
    timeout-minutes: 90
    strategy:
      matrix:
        include:
          # - cpu: nehalem
          #   arch: x86_64
          #   tag: bun-darwin-x64-baseline
          #   obj: bun-obj-darwin-x64-baseline
          #   runner: macos-11
          #   artifact: bun-obj-darwin-x64-baseline
          #   webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
          #   dependencies: true
          #   compile_obj: false
          # - cpu: haswell
          #   arch: x86_64
          #   tag: bun-darwin-x64
          #   obj: bun-obj-darwin-x64
          #   runner: macos-11
          #   artifact: bun-obj-darwin-x64
          #   webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
          #   dependencies: true
          #   compile_obj: false
          # - cpu: nehalem
          #   arch: x86_64
          #   tag: bun-darwin-x64-baseline
          #   obj: bun-obj-darwin-x64-baseline
          #   runner: macos-11
          #   artifact: bun-obj-darwin-x64-baseline
          #   webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
          #   dependencies: false
          #   compile_obj: true
          # - cpu: haswell
          #   arch: x86_64
          #   tag: bun-darwin-x64
          #   obj: bun-obj-darwin-x64
          #   runner: macos-11
          #   artifact: bun-obj-darwin-x64
          #   webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
          #   dependencies: false
          #   compile_obj: true
          - cpu: native
            arch: aarch64
            tag: bun-darwin-aarch64
            obj: bun-obj-darwin-aarch64
            artifact: bun-obj-darwin-aarch64
            webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-arm64-lto.tar.gz"
            runner: macos-arm64
            dependencies: true
            compile_obj: true
    steps:
      - uses: actions/checkout@v3
      - name: Checkout submodules
        run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
      - name: Install dependencies
        env:
          CPU_TARGET: ${{ matrix.cpu }}
          JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
          JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
          HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
          HOMEBREW_NO_AUTO_UPDATE: 1
          HOMEBREW_NO_INSTALL_CLEANUP: 1
          BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
          OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
          BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
        run: |
          brew install ccache rust llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
          echo "export PATH=$(brew --prefix ccache)/bin:\$PATH" >> $GITHUB_ENV
          echo "export PATH=$(brew --prefix coreutils)/libexec/gnubin:\$PATH" >> $GITHUB_ENV
          echo "export PATH=$(brew --prefix llvm@15)/bin:\$PATH" >> $GITHUB_ENV
          brew link --overwrite llvm@15
      - name: ccache
        uses: hendrikmuhs/ccache-action@v1.2
        with:
          key: ${{ runner.os }}-ccache-${{ matrix.tag }}
          restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}
      - name: Download WebKit
        if: matrix.compile_obj
        env:
          CPU_TARGET: ${{ matrix.cpu }}
          JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
          JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
          BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
          OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
          BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
          BUN_RELEASE_DIR: ${{ runner.temp }}/release
          WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
          WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
        run: |
          rm -rf $JSC_BASE_DIR
          mkdir -p $JSC_BASE_DIR
          curl -L ${{ matrix.webkit_url }} | tar -xz -C $JSC_BASE_DIR --strip-components=1
      - name: Compile dependencies
        if: matrix.dependencies
        env:
          CPU_TARGET: ${{ matrix.cpu }}
          JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
          JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
          BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
          OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
          BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
          BUN_RELEASE_DIR: ${{ runner.temp }}/release
          WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
          WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
        run: |
          mkdir -p $BUN_DEPS_OUT_DIR
          make vendor-without-check
      - name: Compile C++
        if: matrix.compile_obj
        env:
          CPU_TARGET: ${{ matrix.cpu }}
          JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
          JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
          BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
          OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
          BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
          BUN_RELEASE_DIR: ${{ runner.temp }}/release
          WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
          WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
        run: |
          mkdir -p $OBJ_DIR $BUN_DEPS_OUT_DIR
          make clean-bindings
          make -j $(sysctl -n hw.ncpu) release-bindings
      - name: Upload C++
        if: matrix.compile_obj
        uses: actions/upload-artifact@v3
        with:
          name: ${{ matrix.tag }}-cpp
          path: ${{ runner.temp }}/bun-cpp-obj
      - name: Upload Dependencies
        if: matrix.dependencies
        uses: actions/upload-artifact@v3
        with:
          name: ${{ matrix.tag }}-deps
          path: ${{runner.temp}}/bun-deps
  macOS:
    name: macOS Link
    runs-on: ${{ matrix.runner }}
    if: github.repository_owner == 'oven-sh'
    needs: [macOS-cpp, macos-object-files]
    timeout-minutes: 90
    strategy:
      matrix:
        include:
          # - cpu: nehalem
          #   arch: x86_64
          #   tag: bun-darwin-x64-baseline
          #   obj: bun-obj-darwin-x64-baseline
          #   package: bun-darwin-x64
          #   runner: macos-11
          #   artifact: bun-obj-darwin-x64-baseline
          #   webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
          # - cpu: haswell
          #   arch: x86_64
          #   tag: bun-darwin-x64
          #   obj: bun-obj-darwin-x64
          #   package: bun-darwin-x64
          #   runner: macos-11
          #   artifact: bun-obj-darwin-x64
          #   webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-amd64-lto.tar.gz"
          - cpu: native
            arch: aarch64
            tag: bun-darwin-aarch64
            obj: bun-obj-darwin-aarch64
            package: bun-darwin-aarch64
            artifact: bun-obj-darwin-aarch64
            webkit_url: "https://github.com/oven-sh/WebKit/releases/download/may20/bun-webkit-macos-arm64-lto.tar.gz"
            runner: macos-arm64
    steps:
      - uses: actions/checkout@v3
      - name: Checkout submodules
        run: git submodule update --init --recursive --depth=1 --progress -j $(sysctl -n hw.ncpu)
      - name: Install dependencies
        env:
          CPU_TARGET: ${{ matrix.cpu }}
          JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
          JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
          HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
          HOMEBREW_NO_AUTO_UPDATE: 1
          HOMEBREW_NO_INSTALL_CLEANUP: 1
          BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
          OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
          BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
        run: |
          brew install rust ccache llvm@15 pkg-config coreutils libtool cmake libiconv automake openssl@1.1 ninja gnu-sed pkg-config esbuild --force
          echo "export PATH=$(brew --prefix coreutils)/libexec/gnubin:\$PATH" >> $GITHUB_ENV
          echo "export PATH=$(brew --prefix llvm@15)/bin:\$PATH" >> $GITHUB_ENV
          brew link --overwrite llvm@15
      - name: ccache
        uses: hendrikmuhs/ccache-action@v1.2
        with:
          key: ${{ runner.os }}-ccache-${{ matrix.tag }}-link
          restore-keys: ${{ runner.os }}-ccache-${{ matrix.tag }}-link
      - name: Download WebKit
        env:
          CPU_TARGET: ${{ matrix.cpu }}
          JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
          JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
          BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
          OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
          BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
        run: |
          rm -rf $JSC_BASE_DIR
          mkdir -p $JSC_BASE_DIR
          curl -L ${{ matrix.webkit_url }} | tar -xz -C $JSC_BASE_DIR --strip-components=1
      - name: Download C++
        uses: actions/download-artifact@v3
        with:
          name: ${{ matrix.tag }}-cpp
          path: ${{ runner.temp }}/bun-cpp-obj
      - name: Download Dependencies
        uses: actions/download-artifact@v3
        with:
          name: ${{ matrix.tag }}-deps
          path: ${{ runner.temp }}/bun-deps
      - name: Download Object
        uses: actions/download-artifact@v3
        with:
          name: ${{ matrix.obj }}
          path: ${{ runner.temp }}/release
      - name: Link
        env:
          CPU_TARGET: ${{ matrix.cpu }}
          JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
          JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
          BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
          OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
          BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
          BUN_RELEASE_DIR: ${{ runner.temp }}/release
          WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
          WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
        run: |
          rm -rf packages/${{ matrix.package }}
          mkdir -p packages/${{ matrix.package }}
          mv ${{ runner.temp }}/release/* packages/${{ matrix.package }}/
          make bun-link-lld-release copy-to-bun-release-dir-bin
      - name: Zip
        env:
          CPU_TARGET: ${{ matrix.cpu }}
          JSC_BASE_DIR: ${{ runner.temp }}/bun-webkit
          JSC_LIB: ${{ runner.temp }}/bun-webkit/lib
          BUN_DEPLOY_DIR: ${{ runner.temp }}/release/bun
          OBJ_DIR: ${{ runner.temp }}/bun-cpp-obj
          BUN_DEPS_OUT_DIR: ${{runner.temp}}/bun-deps
          BUN_RELEASE_DIR: ${{ runner.temp }}/release
          WEBKIT_RELEASE_DIR: ${{ runner.temp }}/bun-webkit
          WEBKIT_RELEASE_DIR_LTO: ${{ runner.temp }}/bun-webkit
        run: |
          cd ${{runner.temp}}/release
          chmod +x bun-profile bun

          mkdir ${{matrix.tag}}-profile
          mkdir ${{matrix.tag}}

          /usr/bin/strip -S bun

          mv bun-profile ${{matrix.tag}}-profile/bun-profile
          mv bun ${{matrix.tag}}/bun

          zip -r ${{matrix.tag}}-profile.zip ${{matrix.tag}}-profile
          zip -r ${{matrix.tag}}.zip ${{matrix.tag}}
      - uses: actions/upload-artifact@v3
        with:
          name: ${{matrix.tag}}-profile
          path: ${{runner.temp}}/release/${{matrix.tag}}-profile.zip
      - uses: actions/upload-artifact@v3
        with:
          name: ${{matrix.tag}}
          path: ${{runner.temp}}/release/${{matrix.tag}}.zip
      - name: Release
        id: release
        uses: ncipollo/release-action@v1
        if: |
          github.repository_owner == 'oven-sh'
          && github.ref == 'refs/heads/main'
        with:
          prerelease: true
          body: "This canary release of Bun corresponds to the commit [${{ github.sha }}]"
          allowUpdates: true
          replacesArtifacts: true
          generateReleaseNotes: true
          artifactErrorsFailBuild: true
          token: ${{ secrets.GITHUB_TOKEN }}
          name: "Canary (${{github.sha}})"
          tag: "canary"
          artifacts: "${{runner.temp}}/release/${{matrix.tag}}.zip,${{runner.temp}}/release/${{matrix.tag}}-profile.zip"
  macOS-test:
    name: Tests ${{matrix.tag}}
    runs-on: ${{ matrix.runner }}
    needs: [macOS]
    if: github.event_name == 'pull_request' && github.repository_owner == 'oven-sh'
    timeout-minutes: 10
    outputs:
      failing_tests: ${{ steps.test.outputs.failing_tests }}
      failing_tests_count: ${{ steps.test.outputs.failing_tests_count }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - tag: bun-darwin-aarch64
            runner: macos-arm64
    steps:
      - id: checkout
        name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: false
      - id: download
        name: Download
        uses: actions/download-artifact@v3
        with:
          name: ${{matrix.tag}}
          path: ${{runner.temp}}/release
      - id: install
        name: Install
        run: |
          cd ${{runner.temp}}/release
          unzip ${{matrix.tag}}.zip
          cd ${{matrix.tag}}
          chmod +x bun
          sudo mv bun /usr/local/bin/bun
          bun --version
      - id: test
        name: Test (node runner)
        # if: ${{github.event.inputs.use_bun == 'false'}}
        run: |
          bun install
          bun install --cwd test
          bun install --cwd packages/bun-internal-test
          node packages/bun-internal-test/src/runner.node.mjs || true
      - name: Comment on PR
        if: steps.test.outputs.failing_tests != '' && github.event_name == 'pull_request'
        uses: thollander/actions-comment-pull-request@v2
        with:
          comment_tag: test-failures-${{matrix.tag}}
          message: |
            ❌ @${{ github.actor }} ${{ steps.test.outputs.failing_tests_count }} files with test failures on ${{ matrix.tag }}:

            ${{ steps.test.outputs.failing_tests }}

            **[View test output](https://github.com/oven-sh/bun/actions/runs/${{github.run_id}})**

            <sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
      - name: Uncomment on PR
        if: steps.test.outputs.failing_tests == '' && github.event_name == 'pull_request'
        uses: thollander/actions-comment-pull-request@v2
        with:
          comment_tag: test-failures-${{matrix.tag}}
          mode: upsert
          create_if_not_exists: false
          message: |
            ✅ test failures on ${{ matrix.tag }} have been resolved.

            <sup>[#${{github.sha}}](https://github.com/oven-sh/bun/commits/${{github.sha}})</sup>
      - id: fail
        name: Fail the build
        if: steps.test.outputs.failing_tests != ''
        run: exit 1