name: run smoke tests

on:
  push:
    branches:
      - master
      - v2
      - v3
  pull_request:

env:
  DISABLE_GA: "true"

jobs:
  smoke-test-httprunner:

    name: smoketest - httprunner - ${{ matrix.python-version }} on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    services:
      service-httpbin:
        image: kennethreitz/httpbin
        ports:
           - 80:80
    strategy:
      fail-fast: false
      max-parallel: 6
      matrix:
        python-version: ['3.7', '3.8', '3.9', '3.10']
        os: [ubuntu-latest]  # FIXME: docker services are not supported on macos-latest, windows-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}
        architecture: x64
    - name: Install dependencies
      run: |
        pip install poetry
        poetry --version
        poetry install -vv -E upload
    - name: Test build package
      run: |
        poetry build
        ls -l dist/
    - name: Test commands
      run: |
        poetry run hrun -V
        poetry run httprunner run -h
    - name: Run smoketest - postman echo
      run: |
        poetry run hrun examples/postman_echo/request_methods
    - name: Run smoketest - httpbin
      run: |
        poetry run hrun examples/httpbin/

  smoke-test-hrp:
    name: smoketest - hrp - ${{ matrix.go-version }} on ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        go-version:
          - 1.18.x
        os: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - name: Install Go
        uses: actions/setup-go@v2
        with:
          go-version: ${{ matrix.go-version }}
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Build hrp binary
        run: make build
      - name: Run smoketest - run with parameters
        run: ./output/hrp run examples/hrp/parameters_test.json
      - name: Run smoketest - boom with parameters
        run: ./output/hrp boom examples/hrp/parameters_test.json --spawn-count 10 --spawn-rate 10 --loop-count 10
      - name: Run smoketest - boom with rendezvous
        run: |
          ./output/hrp boom examples/hrp/rendezvous_test.json --spawn-count 10 --spawn-rate 10 --loop-count 10
      - name: Run hrp convert --pytest
        run: ./output/hrp convert examples/postman_echo/request_methods/
      - name: Run hrp pytest
        run: ./output/hrp pytest examples/postman_echo/request_methods/
