aboutsummaryrefslogtreecommitdiffhomepage
path: root/.github/workflows/linux.yml
blob: 562de7bb6c440dd60e5a3ecb2d86913761a7746c (plain)
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
name: Linux

on:
  pull_request:
  push:
    branches:
      - dev
      - release

jobs:
  build-linux:
    # Build Linux binaries, ready for release.
    # This intentionally uses an older Linux image, so that we compile against
    # an older glibc version and therefore are compatible with a wide range of
    # Linux distributions.
    runs-on: ubuntu-18.04
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          submodules: true
      - name: Install apt dependencies
        run: |
          sudo apt-get install --no-install-recommends \
              ninja-build
      - name: Install Go
        uses: actions/setup-go@v2
        with:
          go-version: '1.18'
      - name: Cache Go
        uses: actions/cache@v2
        with:
          key: go-cache-linux-v1-${{ hashFiles('go.mod') }}
          path: |
            ~/.cache/go-build
            ~/go/pkg/mod
      - name: Cache LLVM source
        uses: actions/cache@v2
        id: cache-llvm-source
        with:
          key: llvm-source-13-linux-v2
          path: |
            llvm-project/clang/lib/Headers
            llvm-project/clang/include
            llvm-project/compiler-rt
            llvm-project/lld/include
            llvm-project/llvm/include
      - name: Download LLVM source
        if: steps.cache-llvm-source.outputs.cache-hit != 'true'
        run: make llvm-source
      - name: Cache LLVM build
        uses: actions/cache@v2
        id: cache-llvm-build
        with:
          key: llvm-build-13-linux-v2
          path: llvm-build
      - name: Build LLVM
        if: steps.cache-llvm-build.outputs.cache-hit != 'true'
        run: |
          # fetch LLVM source
          rm -rf llvm-project
          make llvm-source
          # build!
          make llvm-build
          # Remove unnecessary object files (to reduce cache size).
          find llvm-build -name CMakeFiles -prune -exec rm -r '{}' \;
      - name: Cache Binaryen
        uses: actions/cache@v2
        id: cache-binaryen
        with:
          key: binaryen-linux-v1
          path: build/wasm-opt
      - name: Build Binaryen
        if: steps.cache-binaryen.outputs.cache-hit != 'true'
        run: make binaryen
      - name: Cache wasi-libc
        uses: actions/cache@v2
        id: cache-wasi-libc
        with:
          key: wasi-libc-sysroot-linux-asserts-v3
          path: lib/wasi-libc/sysroot
      - name: Build wasi-libc
        if: steps.cache-wasi-libc.outputs.cache-hit != 'true'
        run: make wasi-libc
      - name: Install fpm
        run: |
          sudo apt-get install ruby ruby-dev
          sudo gem install --no-document fpm
      - name: Build TinyGo release
        run: |
          make release deb -j3
          cp -p build/release.tar.gz /tmp/tinygo.linux-amd64.tar.gz
          cp -p build/release.deb    /tmp/tinygo_amd64.deb
      - name: Publish release artifact
        uses: actions/upload-artifact@v2
        with:
          name: release-double-zipped
          path: |
            /tmp/tinygo.linux-amd64.tar.gz
            /tmp/tinygo_amd64.deb
  test-linux-build:
    # Test the binaries built in the build-linux job by running the smoke tests.
    runs-on: ubuntu-latest
    needs: build-linux
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Install Go
        uses: actions/setup-go@v2
        with:
          go-version: '1.18'
      - name: Install wasmtime
        run: |
          curl https://wasmtime.dev/install.sh -sSf | bash
          echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH
      - name: Download release artifact
        uses: actions/download-artifact@v2
        with:
          name: release-double-zipped
      - name: Extract release tarball
        run: |
          mkdir -p ~/lib
          tar -C ~/lib -xf tinygo.linux-amd64.tar.gz
          ln -s ~/lib/tinygo/bin/tinygo ~/go/bin/tinygo
      - name: Install apt dependencies
        run: |
          sudo apt-get install --no-install-recommends \
              gcc-avr \
              avr-libc
      - name: "Install Xtensa toolchain"
        run: |
          curl -L https://github.com/espressif/crosstool-NG/releases/download/esp-2020r2/xtensa-esp32-elf-gcc8_2_0-esp-2020r2-linux-amd64.tar.gz -o xtensa-esp32-elf-gcc8_2_0-esp-2020r2-linux-amd64.tar.gz
          sudo tar -C /usr/local -xf xtensa-esp32-elf-gcc8_2_0-esp-2020r2-linux-amd64.tar.gz
          sudo ln -s /usr/local/xtensa-esp32-elf/bin/xtensa-esp32-elf-ld /usr/local/bin/xtensa-esp32-elf-ld
          rm xtensa-esp32-elf-gcc8_2_0-esp-2020r2-linux-amd64.tar.gz
      - run: make tinygo-test-wasi-fast
      - run: make smoketest
  assert-test-linux:
    # Run all tests that can run on Linux, with LLVM assertions enabled to catch
    # potential bugs.
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          submodules: true
      - name: Install apt dependencies
        run: |
          echo "Show cpuinfo; sometimes useful when troubleshooting"
          cat /proc/cpuinfo
          sudo apt-get update
          sudo apt-get install --no-install-recommends \
              qemu-system-arm \
              qemu-system-riscv32 \
              qemu-user \
              gcc-avr \
              avr-libc \
              simavr \
              ninja-build
      - name: Install Go
        uses: actions/setup-go@v2
        with:
          go-version: '1.18'
      - name: Install Node.js
        uses: actions/setup-node@v2
        with:
          node-version: '12'
      - name: Install wasmtime
        run: |
          curl https://wasmtime.dev/install.sh -sSf | bash
          echo "$HOME/.wasmtime/bin" >> $GITHUB_PATH
      - name: Cache Go
        uses: actions/cache@v2
        with:
          key: go-cache-linux-asserts-v1-${{ hashFiles('go.mod') }}
          path: |
            ~/.cache/go-build
            ~/go/pkg/mod
      - name: Cache LLVM source
        uses: actions/cache@v2
        id: cache-llvm-source
        with:
          key: llvm-source-13-linux-asserts-v2
          path: |
            llvm-project/clang/lib/Headers
            llvm-project/clang/include
            llvm-project/compiler-rt
            llvm-project/lld/include
            llvm-project/llvm/include
      - name: Download LLVM source
        if: steps.cache-llvm-source.outputs.cache-hit != 'true'
        run: make llvm-source
      - name: Cache LLVM build
        uses: actions/cache@v2
        id: cache-llvm-build
        with:
          key: llvm-build-13-linux-asserts-v2
          path: llvm-build
      - name: Build LLVM
        if: steps.cache-llvm-build.outputs.cache-hit != 'true'
        run: |
          # fetch LLVM source
          rm -rf llvm-project
          make llvm-source
          # build!
          make llvm-build ASSERT=1
          # Remove unnecessary object files (to reduce cache size).
          find llvm-build -name CMakeFiles -prune -exec rm -r '{}' \;
      - name: Cache Binaryen
        uses: actions/cache@v2
        id: cache-binaryen
        with:
          key: binaryen-linux-asserts-v1
          path: build/wasm-opt
      - name: Build Binaryen
        if: steps.cache-binaryen.outputs.cache-hit != 'true'
        run: make binaryen
      - name: Cache wasi-libc
        uses: actions/cache@v2
        id: cache-wasi-libc
        with:
          key: wasi-libc-sysroot-linux-asserts-v3
          path: lib/wasi-libc/sysroot
      - name: Build wasi-libc
        if: steps.cache-wasi-libc.outputs.cache-hit != 'true'
        run: make wasi-libc
      - run: make gen-device -j4
      - name: Test TinyGo
        run: make ASSERT=1 test
      - name: Build TinyGo
        run: |
          make ASSERT=1
          echo "$(pwd)/build" >> $GITHUB_PATH
      - name: Test stdlib packages
        run: make tinygo-test
      - name: Install Xtensa toolchain
        run: |
          curl -L https://github.com/espressif/crosstool-NG/releases/download/esp-2020r2/xtensa-esp32-elf-gcc8_2_0-esp-2020r2-linux-amd64.tar.gz -o xtensa-esp32-elf-gcc8_2_0-esp-2020r2-linux-amd64.tar.gz
          sudo tar -C /usr/local -xf xtensa-esp32-elf-gcc8_2_0-esp-2020r2-linux-amd64.tar.gz
          sudo ln -s /usr/local/xtensa-esp32-elf/bin/xtensa-esp32-elf-ld /usr/local/bin/xtensa-esp32-elf-ld
          rm xtensa-esp32-elf-gcc8_2_0-esp-2020r2-linux-amd64.tar.gz
      - run: make smoketest
      - run: make wasmtest
      - run: make tinygo-baremetal