From 7c8041bfd2d5146888f07ee1dd3bac0a34068e91 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Tue, 28 Sep 2021 08:48:16 +0300 Subject: [PATCH] mswin gh actions #21: fix win32bit artifacts --- .github/workflows/windows-x64.yml | 229 ++++++++++++++++++ .../{windows.yml => windows-x86.yml} | 26 +- .../translate-travis.yml-to-github-actions.py | 41 +++- 3 files changed, 271 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/windows-x64.yml rename .github/workflows/{windows.yml => windows-x86.yml} (90%) diff --git a/.github/workflows/windows-x64.yml b/.github/workflows/windows-x64.yml new file mode 100644 index 000000000..142f2bb56 --- /dev/null +++ b/.github/workflows/windows-x64.yml @@ -0,0 +1,229 @@ +jobs: + perl: + runs-on: windows-latest + steps: + - name: Setup perl + uses: shogo82148/actions-setup-perl@v1 + with: + distribution: strawberry + perl-version: ${{ matrix.perl-version }} + - name: Set git to use LF + run: 'git config --global core.autocrlf false + + git config --global core.eol lf + + ' + - uses: actions/checkout@v2 + - name: perl -V + run: perl -V + - name: install cpanm and mult modules + uses: perl-actions/install-with-cpanm@v1 + with: + install: 'Code::TidyAll::Plugin::ClangFormat + + Code::TidyAll::Plugin::TestCount + + CHI + + Devel::Trace + + Games::Solitaire::Verify::HorneAutomovePrune + + LWP + + Perl::Tidy + + Task::FreecellSolver::Testing + + Test::Code::TidyAll' + - name: install and test_script code + run: '@echo on + + SET MSYS_PACKAGES=mingw-w64-x86_64-cmocka mingw-w64-i686-cmocka mingw-w64-x86_64-pkg-config + mingw-w64-i686-pkg-config + + SET PY3MODS=cffi freecell_solver pycotap pysol_cards random2 six + + dir + + cd + + c:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu" + + c:\msys64\usr\bin\bash -lc "pacman --noconfirm -Syuu" + + choco install ag + + if not exist C:\libtap mkdir C:\libtap + + copy c:\Python35-x64\python.exe c:\Python35-x64\python3.exe + + SET PATH=C:\Python35-x64;C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;%PATH% + + python3 -mpip install %PY3MODS% + + perl -v + + copy C:\msys64\mingw64\bin\mingw32-make.exe C:\msys64\mingw64\bin\make.exe + + SET PATH=C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;%PATH% + + 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 + + curl -o C:\libtap\gperf-3.0.4.tar.gz http://ftp.gnu.org/pub/gnu/gperf/gperf-3.0.4.tar.gz + + copy C:\libtap\gperf-3.0.4.tar.gz . + + tar -xvf gperf-3.0.4.tar.gz + + cd gperf-3.0.4 && perl -e "if (-e qq#C:\\libtap\\bin\\gperf.exe#) + { exit(0); } $ENV{PATH} = qq#C:\\msys64\\mingw64\\bin;$ENV{PATH}#; + system(''sh configure --prefix=C:/libtap'') or system(''gmake'') or + system(''gmake install'');" && cd .. + + git clone https://github.com/clibs/cmocka libtap + + mkdir libtap\b + + cd libtap\b + + set CMAKE_MAKE_PROGRAM=C:\strawberry\c\bin\gmake.exe + + cmake -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=%CMAKE_MAKE_PROGRAM% + -DCMAKE_INSTALL_PREFIX=C:\libtap .. + + echo %PATH% + + gmake + + gmake install + + cd ..\..\ + + git clone https://github.com/shlomif/rinutils rinutils + + mkdir rinutils\b + + cd rinutils\b + + set CMAKE_MAKE_PROGRAM=C:\strawberry\c\bin\gmake.exe + + cmake -G "MinGW Makefiles" -DWITH_TEST_SUITE=OFF -DCMAKE_MAKE_PROGRAM=%CMAKE_MAKE_PROGRAM% + -DCMAKE_INSTALL_PREFIX=C:\libtap .. + + echo %PATH% + + gmake + + gmake install + + SET MYOLDPATH_=%PATH% + + SET PATH=C:\MinGW\bin;%PATH% + + mkdir ..\b32 + + cd ..\b32 + + cmake -G "MinGW Makefiles" -DWITH_TEST_SUITE=OFF -DCMAKE_MAKE_PROGRAM=%CMAKE_MAKE_PROGRAM% + -DCMAKE_INSTALL_PREFIX=C:\libtap32 .. + + echo %PATH% + + gmake + + gmake install + + SET PATH=%MYOLDPATH_% + + cd ..\..\ + + set CMAKE_MAKE_PROGRAM=C:\strawberry\c\bin\gmake.exe + + set LIBRARY_PATH=C:\libtap\lib + + set CMAKE_LIBRARY_PATH=C:\libtap\lib + + set CMAKE_PREFIX_PATH=C:/libtap;c:/libtap32 + + set LD_LIBRARY_PATH=C:\libtap\lib + + set PKG_CONFIG_PATH=C:\libtap\lib\pkgconfig; + + dir c:\libtap /s + + set CPATH=C:\libtap\include + + set PATH=C:\libtap\bin;%PATH% + + set PATH=C:\msys64\mingw64\bin;%PATH% + + del c:\msys64\mingw64\bin\python*.exe + + set HARNESS_BREAK=1 + + set FCS_USE_TEST_RUN=1 + + mkdir fc-solve\b + + cd fc-solve\b + + perl ../scripts/Tatzer -G "MinGW Makefiles" -l x64t --dbm=kaztree + + SET PATH=C:\projects\fc-solve\fc-solve\scripts\win32;%PATH% + + echo %PATH% + + gmake + + gmake boards + + SET PATH=C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;C:\_P5\bin;%PATH% + + perl ../source/run-tests.pl + + cd .. + + mkdir pkg-build-win64 + + cd pkg-build-win64 + + perl ../scripts/Tatzer -G "MinGW Makefiles" --notest-suite -r + + gmake package + + cpack -G WIX + + ' + shell: cmd + - name: upload build artifacts - Freecell Solver Win64 Package + uses: actions/upload-artifact@v2 + with: + name: Freecell Solver Win64 Package + path: fc-solve\pkg-build-win64\freecell-solver-*-win64.exe + - name: upload build artifacts - Freecell Solver Win64 MSI Package + uses: actions/upload-artifact@v2 + with: + name: Freecell Solver Win64 MSI Package + path: fc-solve\pkg-build-win64\freecell-solver-*.msi + strategy: + fail-fast: true + matrix: + perl-version: + - '5.30' +name: windows +'on': + pull_request: null + push: + branches: + - '*' + tags-ignore: + - '*' diff --git a/.github/workflows/windows.yml b/.github/workflows/windows-x86.yml similarity index 90% rename from .github/workflows/windows.yml rename to .github/workflows/windows-x86.yml index fd599f9a4..5218bcf4e 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows-x86.yml @@ -36,6 +36,10 @@ jobs: Task::FreecellSolver::Testing Test::Code::TidyAll' + - name: Set up MinGW + uses: egor-tensin/setup-mingw@v2 + with: + platform: x86 - name: install and test_script code run: '@echo on @@ -192,18 +196,6 @@ jobs: cd .. - mkdir pkg-build-win64 - - cd pkg-build-win64 - - perl ../scripts/Tatzer -G "MinGW Makefiles" --notest-suite -r - - gmake package - - cpack -G WIX - - cd .. - mkdir pkg-build cd pkg-build @@ -236,21 +228,11 @@ jobs: with: name: Freecell Solver Win32 Package path: fc-solve\pkg-build\freecell-solver-*-win32.exe - - name: upload build artifacts - Freecell Solver Win64 Package - uses: actions/upload-artifact@v2 - with: - name: Freecell Solver Win64 Package - path: fc-solve\pkg-build-win64\freecell-solver-*-win64.exe - name: upload build artifacts - Freecell Solver Win32 MSI Package uses: actions/upload-artifact@v2 with: name: Freecell Solver Win32 MSI Package path: fc-solve\pkg-build\freecell-solver-*.msi - - name: upload build artifacts - Freecell Solver Win64 MSI Package - uses: actions/upload-artifact@v2 - with: - name: Freecell Solver Win64 MSI Package - path: fc-solve\pkg-build-win64\freecell-solver-*.msi strategy: fail-fast: true matrix: diff --git a/fc-solve/CI-testing/translate-travis.yml-to-github-actions.py b/fc-solve/CI-testing/translate-travis.yml-to-github-actions.py index 28e45a7e5..06cc84f9e 100644 --- a/fc-solve/CI-testing/translate-travis.yml-to-github-actions.py +++ b/fc-solve/CI-testing/translate-travis.yml-to-github-actions.py @@ -107,7 +107,7 @@ def _process_env(env): yaml.safe_dump(o, stream=outfh, canonical=False, indent=4, ) -def generate_windows_yaml(output_path, is_act): +def generate_windows_yaml(plat, output_path, is_act): """docstring for main""" env_keys = set() @@ -137,6 +137,15 @@ def _process_env(env): "uses": "perl-actions/install-with-cpanm@v1", } steps.append(cpanm_step) + if plat == 'x86': + mingw = { + "name": "Set up MinGW", + "uses": "egor-tensin/setup-mingw@v2", + "with": { + "platform": plat, + }, + } + steps.append(mingw) def _calc_batch_code(cmds): batch = "" @@ -144,6 +153,22 @@ def _calc_batch_code(cmds): for k, v in sorted(data['environment'].items()): # batch += "SET " + k + "=\"" + v + "\"\n" batch += "SET " + k + "=" + v + "\n" + if plat == 'x86': + start = 'mkdir pkg-build-win64' + end = "^cpack -G WIX" + else: + start = 'mkdir pkg-build' + end = "^7z a" + start_idx = [ + i for i, cmd in enumerate(cmds) + if cmd == "cd .." and + cmds[i+1] == start + ][0] + end_idx = start_idx + 1 + while not re.search(end, cmds[end_idx]): + end_idx += 1 + cmds = cmds[:start_idx] + cmds[(end_idx+1):] + for cmd in cmds: if cmd.startswith("cpanm "): words = cmd.split(' ')[1:] @@ -175,11 +200,15 @@ def _calc_batch_code(cmds): ), "shell": "cmd", }) + + def _myfilt(path): + is32 = ("\\pkg-build\\" in path) + return (is32 if plat == 'x86' else (not is32)) steps += [{ 'name': "upload build artifacts - " + art['name'], 'uses': "actions/upload-artifact@v2", 'with': art - } for art in data['artifacts']] + } for art in data['artifacts'] if _myfilt(art['path'])] with open(output_path, "wt") as outfh: # yaml.safe_dump(o, outfh) yaml.safe_dump(skel, stream=outfh, canonical=False, indent=4, ) @@ -195,7 +224,13 @@ def main(): is_act=True, ) generate_windows_yaml( - output_path=".github/workflows/windows.yml", + plat='x86', + output_path=".github/workflows/windows-x86.yml", + is_act=False, + ) + generate_windows_yaml( + plat='x64', + output_path=".github/workflows/windows-x64.yml", is_act=False, )