version: v1.0
name: CI Build

agent:
  machine:
    type: e1-standard-2
    os_image: ubuntu1804

blocks:
  - name: Run tests
    task:
      prologue:
        commands:
          - checkout
          - sem-version go 1.14
          - go build ./...
          - sudo pip3 install https://github.com/amluto/virtme/archive/538f1e756139a6b57a4780e7ceb3ac6bcaa4fe6f.zip
          - sudo apt-get install -y qemu-system-x86
      env_vars:
        - name: TMPDIR
          value: /tmp
      jobs:
      - name: Test building on other OS and arch
        commands:
          - GOOS=darwin go build ./... && for p in $(go list ./...) ; do GOOS=darwin go test -c $p ; done
          - GOARCH=arm GOARM=6 go build ./... && for p in $(go list ./...) ; do GOARCH=arm GOARM=6 go test -c $p ; done
          - GOARCH=arm64 go build ./... && for p in $(go list ./...) ; do GOARCH=arm64 go test -c $p ; done
      - name: Run unit tests
        matrix:
          - env_var: GO_VERSION
            values: [ "1.13", "1.14" ]
          - env_var: KERNEL_VERSION
            values: ["5.4.5", "4.19.81", "4.9.198"]
        commands:
          - sem-version go $GO_VERSION
          - timeout -s KILL 90s ./run-tests.sh $KERNEL_VERSION
