name: E2E
on: push

env:
  GOPATH: /home/runner/go
  AVAPATH: src/github.com/dcomm-tech
  ACTIONS_RUNTIME_URL: 
  ACTIONS_RUNTIME_TOKEN: 
  ACTIONS_CACHE_URL: 

jobs:
  e2e:
    runs-on: ubuntu-18.04
    steps:
      - name: Checkout DcommJS
        uses: actions/checkout@v2
        with: 
          repository: 'dcomm-tech/dcommjs'
      - name: Install dependencies
        run: sudo apt update && sudo apt install zstd git build-essential nodejs -y
      - name: Install NodeJS dependencies
        run: yarn install --frozen-lockfile
      - name: Setup GoLang Version
        uses: actions/setup-go@v1
        with:
          go-version: '1.17.9'
      - name: Setup GOPATH and AVAPATH
        run : |
          mkdir -p $GOPATH/$AVAPATH
      - name: Install autoremove
        run: sudo apt-get autoremove -y
      - name: Clone and Build DcommGo
        run : |
          cd $GOPATH/$AVAPATH
          git clone https://github.com/dcomm-tech/dcommgo
          cd dcommgo
          ./scripts/build.sh
      - name: Checkout ANR
        run : |
          cd $GOPATH/$AVAPATH
          git clone https://github.com/dcomm-tech/dcomm-network-runner
      - name: Starting ANR
        run: |
          cd $GOPATH/$AVAPATH
          cd dcomm-network-runner
          git checkout v1.0.12
          go run ./examples/local/fivenodenetwork/main.go &
      - name: DcommJS E2E Test
        env: 
          DCOMMGO_IP: localhost
          DCOMMGO_PORT: 9650
        run: sleep 60 && yarn test -i --roots e2e_tests