on:
  pull_request:
    paths:
      - 'src/**'
      - 'e2e/**'
      - '.github/workflows/e2e.yml'

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

name: E2E Tests
jobs:
  linux:
    runs-on: ubuntu-latest
    env:
      NU_VERSION: "0.113.1"
      OMP_E2E_REQUIRE: bash,zsh,fish,pwsh,nu
    steps:
    - name: Checkout code
      uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
    - name: Install Go 🗳
      uses: ./.github/workflows/composite/bootstrap-go
    - name: Install zsh and fish
      run: |
        sudo apt-get update
        sudo apt-get install -y zsh fish
    - name: Install nushell
      run: |
        curl -sSL -o nu.tar.gz "https://github.com/nushell/nushell/releases/download/${NU_VERSION}/nu-${NU_VERSION}-x86_64-unknown-linux-musl.tar.gz"
        tar xzf nu.tar.gz
        echo "$PWD/nu-${NU_VERSION}-x86_64-unknown-linux-musl" >> "$GITHUB_PATH"
    - name: E2E tests
      working-directory: e2e
      run: go test -count=1 -v ./...

  windows:
    runs-on: windows-latest
    env:
      NU_VERSION: "0.113.1"
      OMP_E2E_REQUIRE: pwsh,nu
    steps:
    - name: Checkout code
      uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
    - name: Install Go 🗳
      uses: ./.github/workflows/composite/bootstrap-go
    - name: Install nushell
      shell: pwsh
      run: |
        Invoke-WebRequest -Uri "https://github.com/nushell/nushell/releases/download/$env:NU_VERSION/nu-$env:NU_VERSION-x86_64-pc-windows-msvc.zip" -OutFile nu.zip
        Expand-Archive -Path nu.zip -DestinationPath nu
        Add-Content -Path $env:GITHUB_PATH -Value "$PWD\nu"
    - name: E2E tests
      working-directory: e2e
      run: go test -count=1 -v ./...
