
{% 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 Intel 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-x64" %}
  # https://en.wikipedia.org/wiki/Ubuntu_version_history
  # https://hub.docker.com/_/ubuntu
  # The ubuntu:12.04 image fails to update.
  ubuntu-x64:
    name: 'x64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on Ubuntu stable'
    runs-on: ubuntu-latest
    steps:
      - name: 'Machine'
        run: uname -a
      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true
      - name: 'Ubuntu 22.04 x64'
        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 x64'
        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 x64'
        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-x64:
    name: 'x64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on Debian stable'
    runs-on: ubuntu-latest
    steps:
      - name: 'Machine'
        run: uname -a
      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true
      - name: 'Debian 11 x64'
        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 x64'
        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-x64:
    name: 'x64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on RedHat stable'
    runs-on: ubuntu-latest
    steps:
      - name: 'Machine'
        run: uname -a
      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true
      - name: 'RedHat 8 x64'
        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-x64:
    name: 'x64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on Fedora stable'
    runs-on: ubuntu-latest
    steps:
      - name: 'Machine'
        run: uname -a
      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true
      - name: 'Fedora 36 x64'
        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 x64'
        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 x64'
        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 x64'
        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-x64:
    name: 'x64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on OpenSUSE stable'
    runs-on: ubuntu-latest
    steps:
      - name: 'Machine'
        run: uname -a
      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true
      - name: 'OpenSUSE 15.4 x64'
        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 x64'
        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-x64-latest:
    name: 'x64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on Ubuntu latest'
    runs-on: ubuntu-latest
    steps:
      - name: 'Machine'
        run: uname -a
      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true
      - name: 'Ubuntu latest x64'
        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-x64-latest:
    name: 'x64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on Debian latest'
    runs-on: ubuntu-latest
    steps:
      - name: 'Machine'
        run: uname -a
      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true
      - name: 'Debian testing x64'
        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 x64'
        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 %}

  # Fails during zypper in
  # docker://opensuse/tumbleweed

  # fedora:rawhide - Curl error (6): Couldn't resolve host name for https://mirrors.fedoraproject.org/...
  # docker://fedora:latest

  # - https://hub.docker.com/_/archlinux
  arch-x64-latest:
    name: 'x64 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on Arch latest'
    runs-on: ubuntu-latest
    steps:
      - name: 'Machine'
        run: uname -a
      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true
      - name: 'Arch latest x64'
        uses: docker://archlinux:latest
        with:
          entrypoint: /bin/bash
          args: /github/workspace/scripts/helper/tests/native-test.sh --image archlinux:latest --version {% raw %}${{ github.event.inputs.version }}{% endraw %} --base-url {% raw %}${{ github.event.inputs.base_url }}{% endraw %}

  # - https://hub.docker.com/u/manjarolinux
  # docker://manjarolinux/base - too slow

  # - https://hub.docker.com/r/gentoo/portage
  # docker://gentoo/portage - exec: "/bin/bash": stat /bin/bash: no such file or directory: unknown.

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

  # https://hub.docker.com/r/i386/debian
  debian-ia32:
    name: 'ia32 {{ APP_NAME }} {% raw %}${{ github.event.inputs.version }}{% endraw %} test on Debian stable'
    runs-on: ubuntu-latest
    steps:
      - name: 'Machine'
        run: uname -a
      - name: 'Checkout'
        uses: actions/checkout@v2
        with:
          fetch-depth: 3
          submodules: true
      - name: 'Debian 10 ia32'
        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 %}

  # docker://i386/ubuntu:latest is 18.04, no need to test

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

  # centos:latest outdated
  # docker://i386/centos:latest outdated

  {% endcase -%}
{% endfor %}

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