
{% 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: "," -%}

# https://github.com/docker-library/official-images#architectures-other-than-amd64

# Debian versions:
# - 8 jessie
# - 9 stretch
# - 10 buster

# Ubuntu releases
# - 12.04 LTS (Precise Pangolin)
# - 14.04 LTS (Trusty Tahr)
# - 16.04 LTS (Xenial Xerus)
# - 18.04 LTS (Bionic Beaver)
# - 20.04 LTS (Focal Fossa)
# - 22.04 LTS (Jammy Jellyfish)

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

name: 'Test xPack {{ APP_NAME }} on Arm Docker 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'

# The scripts are executed in the Docker context by GitHub Actions,
# so `native-test.sh` should be fine, it already takes care of updates.
jobs:
{% for platform in platforms -%}
  {% case platform -%}
  {% when "linux-arm64" %}
  # https://en.wikipedia.org/wiki/Ubuntu_version_history
  # https://hub.docker.com/_/ubuntu
  # The ubuntu:12.04 image fails to update.
  ubuntu-arm64:
    name: 'arm64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on Ubuntu stable'
    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: 'Ubuntu 22.04 arm64'
        uses: docker://ubuntu:22.04
        with:
          entrypoint: /bin/bash
          args: /github/workspace/scripts/helper/tests/native-test.sh --image ubuntu:22.04 --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}
      - name: 'Ubuntu 20.04 arm64'
        uses: docker://ubuntu:20.04
        with:
          entrypoint: /bin/bash
          args: /github/workspace/scripts/helper/tests/native-test.sh --image ubuntu:20.04 --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}
      - name: 'Ubuntu 18.04 arm64'
        uses: docker://ubuntu:18.04
        with:
          entrypoint: /bin/bash
          args: /github/workspace/scripts/helper/tests/native-test.sh --image ubuntu:18.04 --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}

  # https://en.wikipedia.org/wiki/Debian_version_history
  # https://hub.docker.com/_/debian
  debian-arm64:
    name: 'arm64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on Debian stable'
    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: 'Debian 11 arm64'
        uses: docker://debian:bullseye
        with:
          entrypoint: /bin/bash
          args: /github/workspace/scripts/helper/tests/native-test.sh --image debian:bullseye --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}
      - name: 'Debian 10 arm64'
        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 %}


  # https://hub.docker.com/r/redhat/ubi8
  # `-static` disabled, there is no static libc.a.
  redhat-arm64:
    name: 'arm64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on RedHat stable'
    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: 'RedHat 8 arm64'
        uses: docker://redhat/ubi8
        with:
          entrypoint: /bin/bash
          args: /github/workspace/scripts/helper/tests/native-test.sh --image redhat/ubi8 --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}

  # https://en.wikipedia.org/wiki/Fedora_version_history
  # https://hub.docker.com/_/fedora
  # `-static` disabled, there is no static libc.a.
  fedora-arm64:
    name: 'arm64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on Fedora stable'
    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: 'Fedora 36 arm64'
        uses: docker://fedora:36
        with:
          entrypoint: /bin/bash
          args: /github/workspace/scripts/helper/tests/native-test.sh --image fedora:36 --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}
      - name: 'Fedora 35 arm64'
        uses: docker://fedora:35
        with:
          entrypoint: /bin/bash
          args: /github/workspace/scripts/helper/tests/native-test.sh --image fedora:35 --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}
      - name: 'Fedora 33 arm64'
        uses: docker://fedora:33
        with:
          entrypoint: /bin/bash
          args: /github/workspace/scripts/helper/tests/native-test.sh --image fedora:33 --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}
      - name: 'Fedora 29 arm64'
        uses: docker://fedora:29
        with:
          entrypoint: /bin/bash
          args: /github/workspace/scripts/helper/tests/native-test.sh --image fedora:29 --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}

  # https://en.wikipedia.org/wiki/OpenSUSE#Releases
  # https://hub.docker.com/u/opensuse
  # `-static` disabled, there is no static libc.a.
  opensuse-arm64:
    name: 'arm64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on OpenSUSE stable'
    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: 'OpenSUSE 15.4 arm64'
        uses: docker://opensuse/leap:15.4
        with:
          entrypoint: /bin/bash
          args: /github/workspace/scripts/helper/tests/native-test.sh --image opensuse/leap:15.4 --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}
      - name: 'OpenSUSE 15.3 arm64'
        uses: docker://opensuse/leap:15.3
        with:
          entrypoint: /bin/bash
          args: /github/workspace/scripts/helper/tests/native-test.sh --image opensuse/leap:15.3 --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}

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

  ubuntu-arm64-latest:
    name: 'arm64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on Ubuntu latest'
    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: 'Ubuntu latest arm64'
        uses: docker://ubuntu:latest
        with:
          entrypoint: /bin/bash
          args: /github/workspace/scripts/helper/tests/native-test.sh --image ubuntu:latest --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}
      # ubuntu:rolling fails during update

  debian-arm64-latest:
    name: 'arm64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on Debian latest'
    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: 'Debian testing arm64'
        uses: docker://debian:testing
        with:
          entrypoint: /bin/bash
          args: /github/workspace/scripts/helper/tests/native-test.sh --image debian:testing --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}
      - name: 'Debian latest arm64'
        uses: docker://debian:latest
        with:
          entrypoint: /bin/bash
          args: /github/workspace/scripts/helper/tests/native-test.sh --image debian:latest --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}


  # - https://hub.docker.com/r/opensuse/tumbleweed
  opensuse-arm64-latest:
    name: 'arm64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on OpenSUSE latest'
    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: 'OpenSUSE tumbleweed arm64'
        uses: docker://opensuse/tumbleweed
        with:
          entrypoint: /bin/bash
          args: /github/workspace/scripts/helper/tests/native-test.sh --image opensuse/tumbleweed --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}

  {% when "linux-arm" %}
  # https://hub.docker.com/r/arm32v7/ubuntu/
  ubuntu-arm:
    name: 'arm {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on Ubuntu stable'
    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
      # docker://arm32v7/ubuntu:20.04 - fails to update
      - name: 'Ubuntu 18.04 arm'
        uses: docker://arm32v7/ubuntu:18.04
        with:
          entrypoint: /usr/bin/linux32
          args: /bin/bash /github/workspace/scripts/helper/tests/native-test.sh --image arm32v7/ubuntu:18.04 --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}

  # https://hub.docker.com/r/arm32v7/debian
  debian-arm:
    name: 'arm {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on Debian stable'
    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: 'Debian 10 arm'
        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 %}

  {% endcase -%}
{% endfor %}

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