---
image: Visual Studio 2019
environment:
    matrix:
        - PYTHON: "C:\\Python39"
# Shamelessly taken from https://github.com/plicease/Dist-Zilla-PluginBundle-Author-Plicease/blob/master/.appveyor.yml
# Thanks!
install:
    # - choco install strawberryperl
    - copy %PYTHON%\python.exe %PYTHON%\python3.exe
    - SET PATH=%PYTHON%;%PYTHON%\Scripts;C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;%PATH%
    - python3 -mpip install Pillow attrs configobj flake8 flake8-import-order
        pycotap pygame pyinstaller pysol-cards random2 setuptools six
    - perl -v
    - copy C:\msys64\mingw64\bin\mingw32-make.exe C:\msys64\mingw64\bin\make.exe
    - SET PERL5LIB=C:/_P5/lib/perl5
    - SET PERL_LOCAL_LIB_ROOT=C:/_P5
    - SET PERL_MB_OPT=--install_base C:/_P5
    - SET PERL_MM_OPT=INSTALL_BASE=C:/_P5
    - perl -v
    - cpanm --notest Code::TidyAll::Plugin::Flake8 File::Find::Object
        Perl::Tidy Task::FreecellSolver::Testing  Test::Code::TidyAll
        Test::TrailingSpace
    - echo %PATH%
build: off
test_script:
    - set CMAKE_MAKE_PROGRAM=C:\strawberry\c\bin\gmake.exe
    - set HARNESS_BREAK=1
    - set HARNESS_VERBOSE=1
    - set FCS_USE_TEST_RUN=1
    - gmake pretest
    - perl run-tests.pl
    - gmake rules
    - gmake pot
    - gmake mo
    - pyinstaller pysol.py --windowed --icon=data\pysol.ico
    - python3 setup.py install_data -d dist\pysol
    - appveyor DownloadFile https://sourceforge.net/projects/pysolfc/files/PySolFC-Cardsets/minimal/PySolFC-Cardsets--Minimal-2.0.2.tar.xz/download -FileName cardsets.tar.xz
    - 7z x cardsets.tar.xz -so | 7z x -si -ttar
    - mv PySolFC-Cardsets--Minimal-2.0.2/cardset-* dist/pysol/data
    - appveyor DownloadFile https://sourceforge.net/projects/pysolfc/files/PySol-Music/PySol-Music-4.50/pysol-music-4.50.tar.xz/download -FileName music.tar.xz
    - 7z x music.tar.xz -so | 7z x -si -ttar
    - move pysol-music-4.50\data\music dist\pysol\data\music
    # - ps: |
    #    $apiUrl = 'https://ci.appveyor.com/api'
    #    $project = Invoke-RestMethod -Method Get -Uri "$apiUrl/projects/shlomif/fc-solve"
    #    $jobId = $project.build.jobs[0].jobId
    #    Invoke-RestMethod -Method Get -Uri "$apiUrl/buildjobs/$jobId/artifacts/fc-solve/pkg-build/fc-solve-for-pysol.zip" -OutFile fc-solve.zip
    #
    # For reproducible builds:
    # See:  https://reproducible-builds.org/ .
    - SET FC_SOLVE_VER=5.20.0
    - appveyor DownloadFile https://netix.dl.sourceforge.net/project/fc-solve/fc-solve/DO-NOT-USE--fc-solve-for-pysol/fc-solve-for-pysol--v%FC_SOLVE_VER%.zip -FileName fc-solve.zip
    - 7z x fc-solve.zip
    - move fcs-pysol dist\pysol\freecell-solver
    - 7z a -r pysol_win_dist.7z dist\pysol\
    - SET PYTHONPATH=%cd%
    - python3 scripts\create_iss.py
    - appveyor DownloadFile https://download.microsoft.com/download/C/6/D/C6D0FD4E-9E53-4897-9B91-836EBA2AACD3/vcredist_x86.exe -FileName vcredist_x86.exe
    - SET PATH=%PATH%;"C:\\Program Files (x86)\\Inno Setup 6"
    - ISCC /Q setup.iss
artifacts:
    - path: pysol_win_dist.7z
      name: pysol_win_dist
    - path: dist\pysol\PySolFC_*_setup.exe
      name: pysol_win_installer
cache:
    # - C:\_P5 -> .appveyor.yml
    # - C:\strawberry -> .appveyor.yml
shallow_clone: true
