From 2e07be0cf73d5a3067c20ff3f668e85f1aa05462 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 27 Jan 2020 23:56:55 +0100 Subject: [PATCH] Let's try this instead. --- .github/workflows/ccpp.yml | 12 ++++------ .github/workflows/msys-bash.py | 43 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/msys-bash.py diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 57349bdc..be4d008f 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -24,14 +24,10 @@ jobs: build-windows: runs-on: windows-latest steps: - - uses: numworks/setup-msys2@v1 - with: - msystem: MSYS - uses: actions/checkout@v1 - name: pacman - run: msys2do pacman -S --noconfirm --needed make ninja mingw-w64-i686-libusb mingw-w64-i686-sqlite3 mingw-w64-i686-zlib mingw-w64-i686-gcc zip - - name: make + shell: python scripts\msys-bash.py {0} run: | - set MSYSTEM=MINGW32 - msys2do ls / - msys2do make + pacman -S --noconfirm --needed make ninja mingw-w64-i686-libusb mingw-w64-i686-sqlite3 mingw-w64-i686-zlib mingw-w64-i686-gcc zip + ls + diff --git a/.github/workflows/msys-bash.py b/.github/workflows/msys-bash.py new file mode 100644 index 00000000..1f387302 --- /dev/null +++ b/.github/workflows/msys-bash.py @@ -0,0 +1,43 @@ +#!/usr/bin/python3 + +# Copyright (C) 2019-2020 Patryk Obara +# SPDX-License-Identifier: GPL-2.0-or-later + +# pylint: disable=invalid-name +# pylint: disable=line-too-long + +r""" +This is a wrapper for MSYS2 bash inside Windows GitHub CI environment. + +Usage: + +- name: Step Name + shell: python scripts\msys-bash.py {0} + run: echo "Hello" + +GitHub documentation for specifying shell is here: [1], although it +leaves several VERY important details out: + +- The first parameter (program name) in template shell invocation needs to be + in PATH; absolute path will result in obscure C# exception. +- Name of temporary script file ends with a hardcoded extension matching the + first parameter. +- There is some additional undocumented trickery about expansion of {0} in + template (most probably it's something about formatting strings in C#). +- For some shells, an additional first line is prepended to the temporary + script (but not for python!) + +[1] https://help.github.com/en/github/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#using-a-specific-shell +""" + +import shutil +import subprocess +import sys + +if __name__ == "__main__": + script_py = sys.argv[1] + script_sh = script_py + '.sh' + shutil.copy(script_py, script_sh) + bash = [r'C:\tools\msys64\usr\bin\bash', '-eo', 'pipefail', '-l'] + rcode = subprocess.call(bash + [script_sh]) + sys.exit(rcode)