name: Build and test

on: [pull_request]

jobs:
  build:
    name: Run docker build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Run docker build
        run: docker build -t vulcanize/go-ethereum .

  geth-unit-test:
    name: Run geth unit test
    strategy:
      matrix:
        go-version: [ 1.16.x]
        platform: [ubuntu-latest]
    runs-on: ${{ matrix.platform }}
    env:
      GO111MODULE: on
      GOPATH: /tmp/go
    steps:
      - name: Create GOPATH
        run: mkdir -p /tmp/go

      - name: Install Go
        uses: actions/setup-go@v2
        with:
          go-version: ${{ matrix.go-version }}

      - name: Checkout code
        uses: actions/checkout@v2

      - name: Run unit tests
        run: |
          make test

  statediff-unit-test:
    name: Run state diff unit test
    env:
      GOPATH: /tmp/go
    strategy:
      matrix:
        go-version: [ 1.16.x]
        platform: [ubuntu-latest]
    runs-on: ${{ matrix.platform }}
    steps:
      - name: Create GOPATH
        run: mkdir -p /tmp/go

      - name: Install Go
        uses: actions/setup-go@v2
        with:
          go-version: ${{ matrix.go-version }}

      - name: Checkout code
        uses: actions/checkout@v2

      - name: Start database
        run:  docker-compose -f docker-compose.yml up -d ipld-eth-db

      - name: Run unit tests
        run:
          make statedifftest