github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/.github/workflows/build-macos.yml (about) 1 name: macOS 2 3 on: 4 pull_request: 5 push: 6 branches: 7 - dev 8 - release 9 10 concurrency: 11 group: ${{ github.workflow }}-${{ github.ref }} 12 cancel-in-progress: true 13 14 jobs: 15 build-macos: 16 name: build-macos 17 strategy: 18 matrix: 19 # macos-12: amd64 (oldest supported version as of 05-02-2024) 20 # macos-14: arm64 (oldest arm64 version) 21 os: [macos-12, macos-14] 22 include: 23 - os: macos-12 24 goarch: amd64 25 - os: macos-14 26 goarch: arm64 27 runs-on: ${{ matrix.os }} 28 steps: 29 - name: Install Dependencies 30 shell: bash 31 run: | 32 HOMEBREW_NO_AUTO_UPDATE=1 brew install qemu binaryen 33 - name: Checkout 34 uses: actions/checkout@v4 35 with: 36 submodules: true 37 - name: Install Go 38 uses: actions/setup-go@v5 39 with: 40 go-version: '1.22' 41 cache: true 42 - name: Restore LLVM source cache 43 uses: actions/cache/restore@v4 44 id: cache-llvm-source 45 with: 46 key: llvm-source-17-${{ matrix.os }}-v1 47 path: | 48 llvm-project/clang/lib/Headers 49 llvm-project/clang/include 50 llvm-project/compiler-rt 51 llvm-project/lld/include 52 llvm-project/llvm/include 53 - name: Download LLVM source 54 if: steps.cache-llvm-source.outputs.cache-hit != 'true' 55 run: make llvm-source 56 - name: Save LLVM source cache 57 uses: actions/cache/save@v4 58 if: steps.cache-llvm-source.outputs.cache-hit != 'true' 59 with: 60 key: ${{ steps.cache-llvm-source.outputs.cache-primary-key }} 61 path: | 62 llvm-project/clang/lib/Headers 63 llvm-project/clang/include 64 llvm-project/compiler-rt 65 llvm-project/lld/include 66 llvm-project/llvm/include 67 - name: Restore LLVM build cache 68 uses: actions/cache/restore@v4 69 id: cache-llvm-build 70 with: 71 key: llvm-build-17-${{ matrix.os }}-v1 72 path: llvm-build 73 - name: Build LLVM 74 if: steps.cache-llvm-build.outputs.cache-hit != 'true' 75 shell: bash 76 run: | 77 # fetch LLVM source 78 rm -rf llvm-project 79 make llvm-source 80 # install dependencies 81 HOMEBREW_NO_AUTO_UPDATE=1 brew install cmake ninja 82 # build! 83 make llvm-build 84 find llvm-build -name CMakeFiles -prune -exec rm -r '{}' \; 85 - name: Save LLVM build cache 86 uses: actions/cache/save@v4 87 if: steps.cache-llvm-build.outputs.cache-hit != 'true' 88 with: 89 key: ${{ steps.cache-llvm-build.outputs.cache-primary-key }} 90 path: llvm-build 91 - name: Cache wasi-libc sysroot 92 uses: actions/cache@v4 93 id: cache-wasi-libc 94 with: 95 key: wasi-libc-sysroot-${{ matrix.os }}-v1 96 path: lib/wasi-libc/sysroot 97 - name: Build wasi-libc 98 if: steps.cache-wasi-libc.outputs.cache-hit != 'true' 99 run: make wasi-libc 100 - name: make gen-device 101 run: make -j3 gen-device 102 - name: Test TinyGo 103 shell: bash 104 run: make test GOTESTFLAGS="-short" 105 - name: Build TinyGo release tarball 106 run: make release -j3 107 - name: Test stdlib packages 108 run: make tinygo-test 109 - name: Make release artifact 110 shell: bash 111 run: cp -p build/release.tar.gz build/tinygo.darwin-${{ matrix.goarch }}.tar.gz 112 - name: Publish release artifact 113 # Note: this release artifact is double-zipped, see: 114 # https://github.com/actions/upload-artifact/issues/39 115 # We can essentially pick one of these: 116 # - have a double-zipped artifact when downloaded from the UI 117 # - have a very slow artifact upload 118 # We're doing the former here, to keep artifact uploads fast. 119 uses: actions/upload-artifact@v4 120 with: 121 name: darwin-${{ matrix.goarch }}-double-zipped 122 path: build/tinygo.darwin-${{ matrix.goarch }}.tar.gz 123 - name: Smoke tests 124 shell: bash 125 run: make smoketest TINYGO=$(PWD)/build/tinygo 126 test-macos-homebrew: 127 name: homebrew-install 128 runs-on: macos-latest 129 strategy: 130 matrix: 131 version: [16, 17] 132 steps: 133 - name: Set up Homebrew 134 uses: Homebrew/actions/setup-homebrew@master 135 - name: Fix Python symlinks 136 run: | 137 # Github runners have broken symlinks, so relink 138 # see: https://github.com/actions/setup-python/issues/577 139 brew list -1 | grep python | while read formula; do brew unlink $formula; brew link --overwrite $formula; done 140 - name: Install LLVM 141 run: | 142 brew install llvm@${{ matrix.version }} 143 - name: Checkout 144 uses: actions/checkout@v4 145 - name: Install Go 146 uses: actions/setup-go@v5 147 with: 148 go-version: '1.22' 149 cache: true 150 - name: Build TinyGo (LLVM ${{ matrix.version }}) 151 run: go install -tags=llvm${{ matrix.version }} 152 - name: Check binary 153 run: tinygo version 154 - name: Build TinyGo (default LLVM) 155 if: matrix.version == 17 156 run: go install 157 - name: Check binary 158 if: matrix.version == 17 159 run: tinygo version