- name: Setup Haxe
  run: |
    # mkdir ./linuxBinaries
    # curl -sSL https://build.haxe.org/builds/haxe/linux64/haxe_latest.tar.gz -o ./linuxBinaries/haxe_bin.tar.gz

    sudo apt install -qqy libmbedtls-dev

    set -ex
    tar -xf linuxBinaries/*_bin.tar.gz -C linuxBinaries --strip-components=1
    sudo mkdir -p /usr/local/bin/
    sudo mkdir -p /usr/local/share/haxe/
    sudo ln -s `pwd`/linuxBinaries/haxe /usr/local/bin/haxe
    sudo ln -s `pwd`/linuxBinaries/haxelib /usr/local/bin/haxelib
    sudo ln -s `pwd`/linuxBinaries/std /usr/local/share/haxe/std

- name: Print Haxe version
  run: haxe -version

- name: Setup haxelib
  run: |
    set -ex
    mkdir ~/haxelib
    haxelib setup ~/haxelib

- name: Install apt packages
  if: matrix.APT_PACKAGES
  run: |
    set -ex
    sudo apt update -qqy
    sudo apt install -qqy ${{matrix.APT_PACKAGES}}

# - name: Flash setup
#   if: matrix.target == 'flash9'
#   run: export DISPLAY=:99.0

- name: Test
  if: success() && !(matrix.SAUCE && matrix.SAUCE_ACCESS_KEY)
  run: haxe RunCi.hxml
  working-directory: ${{github.workspace}}/tests

- name: Test (with SauceLabs)
  if: matrix.target == 'js' && success() && matrix.SAUCE && matrix.SAUCE_ACCESS_KEY
  run: haxe RunCi.hxml
  working-directory: ${{github.workspace}}/tests
  env:
    SAUCE_ACCESS_KEY: matrix.SAUCE_ACCESS_KEY
