
{% render "scripts/helper/templates/copyright-liquid.yml" %}

{% if platforms == "all" -%}
  {% assign platforms = "linux-x64,linux-arm64,linux-arm,darwin-x64,darwin-arm64,win32-x64" -%}
{% endif -%}
{% assign platforms = platforms | split: "," -%}

name: 'Test xPack {{ APP_NAME }} on supported platforms'

on:
  workflow_dispatch:
    inputs:
      base_url:
        description: 'The folder part of the URL where binaries are stored'
        required: false
        default: 'release'
      version:
        description: 'The semver of the release'
        required: false
        default: 'current'

jobs:
{% for platform in platforms -%}
  {% case platform -%}
  {% when "linux-x64" %}
  linux-x64:
    name: 'Linux x64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test'
    runs-on: ubuntu-latest
    steps:
      - name: 'Machine'
        run: uname -a
      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true
      - name: 'Run {% raw %}${{ github.event.inputs.version }}{% endraw %} native test'
        run: bash scripts/helper/tests/native-test.sh --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}

  {% when "linux-ia32" %}
  linux-ia32:
    name: 'Linux ia32 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test'
    runs-on: ubuntu-latest
    steps:
      - name: 'Machine'
        run: uname -a
      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true
      - name: 'Run {% raw %}${{ github.event.inputs.version }}{% endraw %} docker test'
        uses: docker://i386/debian:buster
        with:
          entrypoint: /usr/bin/linux32
          args: /bin/bash /github/workspace/scripts/helper/tests/native-test.sh --image i386/debian:buster --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}

  {% when "linux-arm64" %}
  linux-arm64:
    name: 'Linux arm64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test'
    runs-on: [self-hosted, linux, arm64, xbbla]
    steps:
      - name: 'Machine'
        run: uname -a
      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true
      - name: 'Run {% raw %}${{ github.event.inputs.version }}{% endraw %} native test'
        uses: docker://debian:buster
        with:
          entrypoint: /bin/bash
          args: /github/workspace/scripts/helper/tests/native-test.sh --image debian:buster --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}

  {% when "linux-arm" %}
  linux-arm32:
    name: 'Linux arm32 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test'
    runs-on: [self-hosted, linux, arm64, xbbla]
    steps:
      - name: 'Machine'
        run: uname -a
      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true
      - name: 'Run {% raw %}${{ github.event.inputs.version }}{% endraw %} docker test'
        uses: docker://arm32v7/debian:buster
        with:
          entrypoint: /usr/bin/linux32
          args: /bin/bash /github/workspace/scripts/helper/tests/native-test.sh --image arm32v7/debian:buster --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}

  {% when "darwin-x64" %}
  macos-x64:
    name: 'macOS x64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test'
    runs-on: macos-latest
    steps:
      - name: 'Machine'
        run: uname -a
      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true
      - name: 'Run {% raw %}${{ github.event.inputs.version }}{% endraw %} native test'
        run: bash scripts/helper/tests/native-test.sh --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}

  {% when "darwin-arm64" %}
  macos-arm64:
    name: 'macOS arm64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test'
    runs-on: [self-hosted, macos, apple]
    defaults:
      run:
        shell: "/usr/bin/arch -arch arm64e /bin/bash -l {0}"

    steps:
      - name: 'Machine'
        run: uname -a
      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true
      - name: 'Run {% raw %}${{ github.event.inputs.version }}{% endraw %} native test'
        run: bash scripts/helper/tests/native-test.sh --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}

  {% when "win32-x64" %}
  windows-x64:
    name: 'Windows x64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test'
    runs-on: windows-latest
    steps:
      - name: 'Machine'
        run: uname -a
      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true
      - name: 'Run {% raw %}${{ github.event.inputs.version }}{% endraw %} native test'
        run: bash scripts/helper/tests/native-test.sh --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}

  {% when "win32-ia32" %}
  windows-ia32:
    name: 'Windows ia32 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test'
    runs-on: windows-latest
    steps:
      - name: 'Machine'
        run: uname -a
      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true
      - name: 'Run {% raw %}${{ github.event.inputs.version }}{% endraw %} native test'
        run: bash scripts/helper/tests/native-test.sh --32 --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}
  {% endcase -%}
{% endfor %}

# -----------------------------------------------------------------------------
