name: ci-dgraph-ldbc-tests

on:
  pull_request:
    paths:
      - "**/*.go"
      - "**/go.mod"
    types:
      - opened
      - reopened
      - synchronize
      - ready_for_review
    branches:
      - main
      - release/**

permissions:
  contents: read

jobs:
  dgraph-ldbc-tests:
    if: github.event.pull_request.draft == false
    runs-on: warp-ubuntu-latest-x64-4x
    timeout-minutes: 10
    steps:
      - name: Checkout Dgraph
        uses: actions/checkout@v4
      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version-file: go.mod
      - name: Make Linux Build and Docker Image
        run: make docker-image
      - name: Install gotestsum
        run: go install gotest.tools/gotestsum@latest
      - name: Build Test Binary
        run: |
          #!/bin/bash
          # build the test binary
          cd t; go build .
      - name: Clean Up Environment
        run: |
          #!/bin/bash
          # clean cache
          go clean -testcache
          # clean up docker containers before test execution
          cd t; ./t -r
      - name: Run LDBC Tests
        run: |
          #!/bin/bash
          # go env settings
          export GOPATH=~/go
          # move the binary
          cp dgraph/dgraph ~/go/bin/dgraph
          # run the ldbc tests
          cd t; ./t --suite=ldbc
          # clean up docker containers after test execution
          ./t -r