
{% 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 }} via xpm'

on:
  workflow_dispatch:
    inputs:
      version:
        description: 'The semver of the npm release'
        required: false
        default: 'latest'

jobs:
{% for platform in platforms -%}
  {% case platform -%}
  {% when "linux-x64" %}
  linux-x64:
    name: 'Linux Intel 64-bit {{ 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 %} xpm test'
        uses: docker://ilegeul/debian:amd64-10-npm-v1
        with:
          entrypoint: /bin/bash
          args: /github/workspace/scripts/helper/tests/xpm-test.sh --image debian:buster --version {% raw %}${{ github.event.inputs.version }}{% endraw %}

  {% when "linux-ia32" %}
  linux-ia32:
    name: 'Linux Intel 32-bit {{ 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 %} xpm docker test on Debian 10 i386'
        uses: docker://ilegeul/debian:i386-10-npm-v1
        with:
          entrypoint: /usr/bin/linux32
          args: /bin/bash scripts/helper/tests/xpm-test.sh --image ilegeul/debian:i386-10-npm-v1 --version {% raw %}${{ github.event.inputs.version }}{% endraw %}

  {% when "linux-arm64" %}
  linux-arm64:
    name: 'Linux Arm 64-bit {{ 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 %} xpm docker test on Debian 10 aarch64'
        uses: docker://ilegeul/debian:arm64v8-10-npm-v1
        with:
          entrypoint: /bin/bash
          args: scripts/helper/tests/xpm-test.sh --image ilegeul/debian:arm64v8-10-npm-v1 --version {% raw %}${{ github.event.inputs.version }}{% endraw %}

  {% when "linux-arm" %}
  linux-arm32:
    name: 'Linux Arm 32-bit {{ 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 %} xpm docker test on Debian 10 armhf'
        uses: docker://ilegeul/debian:arm32v7-10-npm-v1
        with:
          entrypoint: /usr/bin/linux32
          args: /bin/bash scripts/helper/tests/xpm-test.sh --image ilegeul/debian:arm32v7-10-npm-v1 --version {% raw %}${{ github.event.inputs.version }}{% endraw %}

  {% when "darwin-x64" %}
  macos-x64:
    name: 'macOS Intel 64-bit {{ 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 %} xpm test'
        run: bash scripts/helper/tests/xpm-test.sh --version {% raw %}${{ github.event.inputs.version }}{% endraw %}

  {% when "darwin-arm64" %}
  macos-arm64:
    name: 'macOS Arm 64-bit {{ 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 %} xpm test'
        run: bash scripts/helper/tests/xpm-test.sh --version {% raw %}${{ github.event.inputs.version }}{% endraw %}

  {% when "win32-x64" %}
  windows-x64:
    name: 'Windows 64-bit {{ 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 %} xpm test'
        run: bash scripts/helper/tests/xpm-test.sh --version {% raw %}${{ github.event.inputs.version }}{% endraw %}

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

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