aboutsummaryrefslogtreecommitdiffhomepage
path: root/.circleci/config.yml
blob: de75739b70f4dcc7a3d85d1fcdcd4598b30e623d (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
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
version: 2.1

commands:
  submodules:
    steps:
      - run:
          name: "Pull submodules"
          command: git submodule update --init
  apt-dependencies:
    parameters:
      llvm:
        type: string
    steps:
      - run:
          name: "Install apt dependencies"
          command: |
            echo 'deb https://apt.llvm.org/buster/ llvm-toolchain-buster-<<parameters.llvm>> main' | sudo tee /etc/apt/sources.list.d/llvm.list
            wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
            sudo apt-get update
            sudo apt-get install --no-install-recommends \
                llvm-<<parameters.llvm>>-dev \
                clang-<<parameters.llvm>> \
                libclang-<<parameters.llvm>>-dev \
                lld-<<parameters.llvm>> \
                qemu-system-arm \
                qemu-user \
                gcc-avr \
                avr-libc
  install-node:
    steps:
      - run:
          name: "Install node.js"
          command: |
            wget https://nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.xz
            sudo tar -C /usr/local -xf node-v10.15.1-linux-x64.tar.xz
            sudo ln -s /usr/local/node-v10.15.1-linux-x64/bin/node /usr/bin/node
            rm node-v10.15.1-linux-x64.tar.xz
  install-chrome:
    steps:
      - run:
          name: "Install Chrome"
          command: |
            wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
            sudo apt install ./google-chrome-stable_current_amd64.deb
  install-wasmtime:
    steps:
      - run:
          name: "Install wasmtime"
          command: |
            curl https://wasmtime.dev/install.sh -sSf | bash
            sudo ln -s ~/.wasmtime/bin/wasmtime /usr/local/bin/wasmtime
  install-xtensa-toolchain:
    parameters:
      variant:
        type: string
    steps:
      - run:
          name: "Install Xtensa toolchain"
          command: |
            curl -L https://github.com/espressif/crosstool-NG/releases/download/esp-2020r2/xtensa-esp32-elf-gcc8_2_0-esp-2020r2-<<parameters.variant>>.tar.gz -o xtensa-esp32-elf-gcc8_2_0-esp-2020r2-<<parameters.variant>>.tar.gz
            sudo tar -C /usr/local -xf xtensa-esp32-elf-gcc8_2_0-esp-2020r2-<<parameters.variant>>.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-<<parameters.variant>>.tar.gz
  llvm-source-linux:
    steps:
      - restore_cache:
          keys:
            - llvm-source-11-v2
      - run:
          name: "Fetch LLVM source"
          command: make llvm-source
      - save_cache:
          key: llvm-source-11-v2
          paths:
            - llvm-project/clang/lib/Headers
            - llvm-project/clang/include
            - llvm-project/lld/include
            - llvm-project/llvm/include
  build-wasi-libc:
    steps:
      - restore_cache:
          keys:
            - wasi-libc-sysroot-v4
      - run:
          name: "Build wasi-libc"
          command: make wasi-libc
      - save_cache:
          key: wasi-libc-sysroot-v4
          paths:
            - lib/wasi-libc/sysroot
  test-linux:
    parameters:
      llvm:
        type: string
    steps:
      - checkout
      - submodules
      - apt-dependencies:
          llvm: "<<parameters.llvm>>"
      - install-node
      - install-chrome
      - install-wasmtime
      - restore_cache:
          keys:
            - go-cache-v2-{{ checksum "go.mod" }}-{{ .Environment.CIRCLE_PREVIOUS_BUILD_NUM }}
            - go-cache-v2-{{ checksum "go.mod" }}
      - llvm-source-linux
      - run: go install -tags=llvm<<parameters.llvm>> .
      - restore_cache:
          keys:
            - wasi-libc-sysroot-systemclang-v3
      - run: make wasi-libc
      - save_cache:
          key: wasi-libc-sysroot-systemclang-v3
          paths:
            - lib/wasi-libc/sysroot
      - run:
          name: "Test TinyGo"
          command: go test -v -timeout=20m -tags=llvm<<parameters.llvm>> ./builder ./cgo ./compileopts ./compiler ./interp ./transform .
          no_output_timeout: 20m
      - run: make gen-device -j4
      - run: make smoketest XTENSA=0
      - run: make tinygo-test
      - run: make wasmtest
      - save_cache:
          key: go-cache-v2-{{ checksum "go.mod" }}-{{ .Environment.CIRCLE_BUILD_NUM }}
          paths:
            - ~/.cache/go-build
            - /go/pkg/mod
      - run: make fmt-check
  assert-test-linux:
    steps:
      - checkout
      - submodules
      - run:
          name: "Install apt dependencies"
          command: |
            sudo apt-get update
            sudo apt-get install --no-install-recommends \
                libgnutls30 libssl1.0.2 \
                qemu-system-arm \
                qemu-user \
                gcc-avr \
                avr-libc
      - install-node
      - install-wasmtime
      - install-xtensa-toolchain:
          variant: "linux-amd64"
      - restore_cache:
          keys:
            - go-cache-v2-{{ checksum "go.mod" }}-{{ .Environment.CIRCLE_PREVIOUS_BUILD_NUM }}
            - go-cache-v2-{{ checksum "go.mod" }}
      - llvm-source-linux
      - restore_cache:
          keys:
            - llvm-build-11-linux-v4-assert
      - run:
          name: "Build LLVM"
          command: |
            if [ ! -f llvm-build/lib/liblldELF.a ]
            then
              # fetch LLVM source
              rm -rf llvm-project
              make llvm-source
              # install dependencies
              sudo apt-get install cmake ninja-build
              # hack ninja to use less jobs
              echo -e '#!/bin/sh\n/usr/bin/ninja -j3 "$@"' > /go/bin/ninja
              chmod +x /go/bin/ninja
              # build!
              make ASSERT=1 llvm-build
              find llvm-build -name CMakeFiles -prune -exec rm -r '{}' \;
            fi
      - save_cache:
          key: llvm-build-11-linux-v4-assert
          paths:
            llvm-build
      - run: make ASSERT=1
      - build-wasi-libc
      - run:
          name: "Test TinyGo"
          command: make ASSERT=1 test
          no_output_timeout: 20m
          environment:
            # Note: -p=2 limits parallelism to two jobs at a time, which is
            # necessary to keep memory consumption down and avoid OOM (for a
            # 2CPU/4GB executor).
            GOFLAGS: -p=2
      - save_cache:
          key: go-cache-v2-{{ checksum "go.mod" }}-{{ .Environment.CIRCLE_BUILD_NUM }}
          paths:
            - ~/.cache/go-build
            - /go/pkg/mod
      - run: make gen-device -j4
      - run: make smoketest TINYGO=build/tinygo
  build-linux:
    steps:
      - checkout
      - submodules
      - run:
          name: "Install apt dependencies"
          command: |
            sudo apt-get update
            sudo apt-get install --no-install-recommends \
                libgnutls30 libssl1.0.2 \
                qemu-system-arm \
                qemu-user \
                gcc-avr \
                avr-libc
      - install-node
      - install-wasmtime
      - install-xtensa-toolchain:
          variant: "linux-amd64"
      - restore_cache:
          keys:
            - go-cache-v2-{{ checksum "go.mod" }}-{{ .Environment.CIRCLE_PREVIOUS_BUILD_NUM }}
            - go-cache-v2-{{ checksum "go.mod" }}
      - llvm-source-linux
      - restore_cache:
          keys:
            - llvm-build-11-linux-v4-noassert
      - run:
          name: "Build LLVM"
          command: |
            if [ ! -f llvm-build/lib/liblldELF.a ]
            then
              # fetch LLVM source
              rm -rf llvm-project
              make llvm-source
              # install dependencies
              sudo apt-get install cmake ninja-build
              # hack ninja to use less jobs
              echo -e '#!/bin/sh\n/usr/bin/ninja -j3 "$@"' > /go/bin/ninja
              chmod +x /go/bin/ninja
              # build!
              make llvm-build
              find llvm-build -name CMakeFiles -prune -exec rm -r '{}' \;
            fi
      - save_cache:
          key: llvm-build-11-linux-v4-noassert
          paths:
            llvm-build
      - build-wasi-libc
      - run:
          name: "Test TinyGo"
          command: make test
          no_output_timeout: 20m
      - run:
          name: "Install fpm"
          command: |
            sudo apt-get install ruby ruby-dev
            sudo gem install --no-document fpm
      - run:
          name: "Build TinyGo release"
          command: |
            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
      - store_artifacts:
          path: /tmp/tinygo.linux-amd64.tar.gz
      - store_artifacts:
          path: /tmp/tinygo_amd64.deb
      - save_cache:
          key: go-cache-v2-{{ checksum "go.mod" }}-{{ .Environment.CIRCLE_BUILD_NUM }}
          paths:
            - ~/.cache/go-build
            - /go/pkg/mod
      - run:
          name: "Extract release tarball"
          command: |
            mkdir -p ~/lib
            tar -C ~/lib -xf /tmp/tinygo.linux-amd64.tar.gz
            ln -s ~/lib/tinygo/bin/tinygo /go/bin/tinygo
            tinygo version
      - run: make smoketest
  build-macos:
    steps:
      - checkout
      - submodules
      - run:
          name: "Install dependencies"
          command: |
            curl https://dl.google.com/go/go1.17.darwin-amd64.tar.gz -o go1.17.darwin-amd64.tar.gz
            sudo tar -C /usr/local -xzf go1.17.darwin-amd64.tar.gz
            ln -s /usr/local/go/bin/go /usr/local/bin/go
            HOMEBREW_NO_AUTO_UPDATE=1 brew install qemu
      - install-xtensa-toolchain:
          variant: "macos"
      - restore_cache:
          keys:
            - go-cache-macos-v3-{{ checksum "go.mod" }}-{{ .Environment.CIRCLE_PREVIOUS_BUILD_NUM }}
            - go-cache-macos-v3-{{ checksum "go.mod" }}
      - restore_cache:
          keys:
            - llvm-source-11-macos-v3
      - run:
          name: "Fetch LLVM source"
          command: make llvm-source
      - save_cache:
          key: llvm-source-11-macos-v3
          paths:
            - llvm-project/clang/lib/Headers
            - llvm-project/clang/include
            - llvm-project/lld/include
            - llvm-project/llvm/include
      - restore_cache:
          keys:
            - llvm-build-11-macos-v5
      - run:
          name: "Build LLVM"
          command: |
            if [ ! -f llvm-build/lib/liblldELF.a ]
            then
              # fetch LLVM source
              rm -rf llvm-project
              make llvm-source
              # install dependencies
              HOMEBREW_NO_AUTO_UPDATE=1 brew install cmake ninja
              # build!
              make llvm-build
              find llvm-build -name CMakeFiles -prune -exec rm -r '{}' \;
            fi
      - save_cache:
          key: llvm-build-11-macos-v5
          paths:
            llvm-build
      - restore_cache:
          keys:
            - wasi-libc-sysroot-macos-v4
      - run:
          name: "Build wasi-libc"
          command: make wasi-libc
      - save_cache:
          key: wasi-libc-sysroot-macos-v4
          paths:
            - lib/wasi-libc/sysroot
      - run:
          name: "Test TinyGo"
          command: make test
          no_output_timeout: 20m
      - run:
          name: "Build TinyGo release"
          command: |
            make release -j3
            cp -p build/release.tar.gz /tmp/tinygo.darwin-amd64.tar.gz
      - store_artifacts:
          path: /tmp/tinygo.darwin-amd64.tar.gz
      - run:
          name: "Extract release tarball"
          command: |
            mkdir -p ~/lib
            tar -C /usr/local/opt -xf /tmp/tinygo.darwin-amd64.tar.gz
            ln -s /usr/local/opt/tinygo/bin/tinygo /usr/local/bin/tinygo
            tinygo version
      - run: make smoketest AVR=0
      - save_cache:
          key: go-cache-macos-v3-{{ checksum "go.mod" }}-{{ .Environment.CIRCLE_BUILD_NUM }}
          paths:
            - ~/.cache/go-build
            - /go/pkg/mod

jobs:
  test-llvm11-go115:
    docker:
      - image: circleci/golang:1.15-buster
    steps:
      - test-linux:
          llvm: "11"
  test-llvm11-go116:
    docker:
      - image: circleci/golang:1.16-buster
    steps:
      - test-linux:
          llvm: "11"
  assert-test-linux:
    docker:
      - image: circleci/golang:1.17-stretch
    steps:
      - assert-test-linux
  build-linux:
    docker:
      - image: circleci/golang:1.17-stretch
    steps:
      - build-linux
  build-macos:
    macos:
      xcode: "11.1.0" # macOS 10.14
    steps:
      - build-macos



workflows:
  test-all:
    jobs:
      - test-llvm11-go115
      - test-llvm11-go116
      - build-linux
      - build-macos
      - assert-test-linux