Skip to content

Commit

Permalink
Additional github workflow action for automatic test under Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
osch committed Dec 14, 2023
1 parent 80b0675 commit dc4d15a
Show file tree
Hide file tree
Showing 14 changed files with 403 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/mingw-w64-lua-luarocks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*.tar.gz
/*.zst
/pkg
/src

Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
diff file generated from Sutou Kouhei PR -> https://github.com/luarocks/luarocks/pull/1230/files
diff -Naur luarocks-3.7.0.orig/spec/util/test_env.lua luarocks-3.7.0/spec/util/test_env.lua
--- luarocks-3.7.0.orig/spec/util/test_env.lua 2021-04-13 23:53:36.000000000 +0200
+++ luarocks-3.7.0/spec/util/test_env.lua 2021-07-25 17:43:16.413491100 +0200
@@ -248,6 +248,8 @@
test_env.MINGW = true
elseif argument == "vs" then
test_env.MINGW = false
+ elseif argument == "msys2_mingw_w64" then
+ test_env.MSYS2_MINGW_W64 = true
elseif argument:find("^lua_dir=") then
test_env.LUA_DIR = argument:match("^lua_dir=(.*)$")
elseif argument:find("^lua_interpreter=") then
@@ -429,7 +431,9 @@
return execute_output("find " .. path .. " -type f -exec stat -f \"%z %N\" {} \\; | md5")
elseif test_env.TEST_TARGET_OS == "windows" then
return execute_output("\"" .. Q(test_env.testing_paths.win_tools .. "/find") .. " " .. Q(path)
- .. " -printf \"%s %p\"\" > temp_sum.txt && certUtil -hashfile temp_sum.txt && del temp_sum.txt")
+ .. " -printf \"%s %p\"\" > temp_sum.txt && "
+ .. "C:\\Windows\\System32\\certUtil -hashfile temp_sum.txt && "
+ .. "del temp_sum.txt")
end
end

@@ -823,10 +827,14 @@
if test_env.TEST_TARGET_OS == "windows" then
if test_env.MINGW then
table.insert(lines, [[SYSTEM = "mingw",]])
+ elseif test_env.MSYS2_MINGW_W64 then
+ table.insert(lines, [[SYSTEM = "msys2_mingw_w64",]])
else
table.insert(lines, [[SYSTEM = "windows",]])
end
- table.insert(lines, ("WIN_TOOLS = %q,"):format(testing_paths.win_tools))
+ if not test_env.MSYS2_MINGW_W64 then
+ table.insert(lines, ("WIN_TOOLS = %q,"):format(testing_paths.win_tools))
+ end
end

table.insert(lines, "}")
diff -Naur luarocks-3.7.0.orig/src/luarocks/core/cfg.lua luarocks-3.7.0/src/luarocks/core/cfg.lua
--- luarocks-3.7.0.orig/src/luarocks/core/cfg.lua 2021-04-13 23:53:36.000000000 +0200
+++ luarocks-3.7.0/src/luarocks/core/cfg.lua 2021-07-25 17:51:51.829906200 +0200
@@ -414,6 +414,7 @@
defaults.makefile = "Makefile"
defaults.cmake_generator = "MSYS Makefiles"
defaults.local_cache = home.."/.cache/luarocks"
+ defaults.variables.PWD = "cd"
defaults.variables.MAKE = "make"
defaults.variables.CC = "gcc"
defaults.variables.RC = "windres"
@@ -745,7 +749,7 @@

local defaults = make_defaults(cfg.lua_version, processor, platforms, cfg.home)

- if platforms.windows and hardcoded.WIN_TOOLS then
+ if platforms.windows and not platforms.msys2_mingw_w64 and hardcoded.WIN_TOOLS then
local tools = { "SEVENZ", "CP", "FIND", "LS", "MD5SUM", "WGET", }
for _, tool in ipairs(tools) do
defaults.variables[tool] = '"' .. hardcoded.WIN_TOOLS .. "/" .. defaults.variables[tool] .. '.exe"'
diff -Naur luarocks-3.7.0.orig/src/luarocks/fs/msys2_mingw_w64.lua luarocks-3.7.0/src/luarocks/fs/msys2_mingw_w64.lua
--- luarocks-3.7.0.orig/src/luarocks/fs/msys2_mingw_w64.lua 1970-01-01 01:00:00.000000000 +0100
+++ luarocks-3.7.0/src/luarocks/fs/msys2_mingw_w64.lua 2021-07-25 17:52:51.477791300 +0200
@@ -0,0 +1,12 @@
+--- MSYS2 + Mingw-w64 implementation of filesystem and platform abstractions.
+local msys2_mingw_w64 = {}
+
+local unix_tools = require("luarocks.fs.unix.tools")
+
+msys2_mingw_w64.zip = unix_tools.zip
+msys2_mingw_w64.unzip = unix_tools.unzip
+msys2_mingw_w64.gunzip = unix_tools.gunzip
+msys2_mingw_w64.bunzip2 = unix_tools.bunzip2
+msys2_mingw_w64.copy_contents = unix_tools.copy_contents
+
+return msys2_mingw_w64
\ No newline at end of file
diff -Naur luarocks-3.7.0.orig/src/luarocks/fs/unix/tools.lua luarocks-3.7.0/src/luarocks/fs/unix/tools.lua
--- luarocks-3.7.0.orig/src/luarocks/fs/unix/tools.lua 2021-04-13 23:53:36.000000000 +0200
+++ luarocks-3.7.0/src/luarocks/fs/unix/tools.lua 2021-07-25 17:54:45.618437900 +0200
@@ -152,13 +152,13 @@
end
end

-local function uncompress(default_ext, program, infile, outfile)
+local function uncompress(default_ext, program, uncompress_flag, infile, outfile)
assert(type(infile) == "string")
assert(outfile == nil or type(outfile) == "string")
if not outfile then
outfile = infile:gsub("%."..default_ext.."$", "")
end
- if fs.execute(fs.Q(program).." -c "..fs.Q(infile).." > "..fs.Q(outfile)) then
+ if fs.execute(fs.Q(program).." "..fs.Q(uncompress_flag).." -c "..fs.Q(infile).." > "..fs.Q(outfile)) then
return true
else
return nil, "failed extracting " .. infile
@@ -171,7 +171,7 @@
-- If not given, name is derived from input file.
-- @return boolean: true on success; nil and error message on failure.
function tools.gunzip(infile, outfile)
- return uncompress("gz", "gunzip", infile, outfile)
+ return uncompress("gz", "gzip", "-d", infile, outfile)
end

--- Uncompresses a .bz2 file.
@@ -180,7 +180,7 @@
-- If not given, name is derived from input file.
-- @return boolean: true on success; nil and error message on failure.
function tools.bunzip2(infile, outfile)
- return uncompress("bz2", "bunzip2", infile, outfile)
+ return uncompress("bz2", "bzip2", "-d", infile, outfile)
end

do
45 changes: 45 additions & 0 deletions .github/workflows/mingw-w64-lua-luarocks/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Modified PKGBUILD, see https://github.com/msys2/MINGW-packages/pull/12002
#
# Maintainer: Ricky Wu <[email protected]>
# Contributor: ImperatorS79 <[email protected]>
# Contributoor: Ray Donnelly <[email protected]>

_realname=luarocks
pkgbase=mingw-w64-lua-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-lua-${_realname}")
pkgver=3.9.0
pkgrel=2
pkgdesc="the package manager for Lua modules (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
install=${_realname}-${MSYSTEM}.install
url="https://luarocks.org"
license=("MIT")
depends=("${MINGW_PACKAGE_PREFIX}-lua"
"unzip"
"zip")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc" "${MINGW_PACKAGE_PREFIX}-autotools")
options=('staticlibs' 'strip')
source=("https://luarocks.org/releases/${_realname}-${pkgver}.tar.gz"
"0001-luarocks_msys2_mingw_w64.patch")
sha256sums=('5e840f0224891de96be4139e9475d3b1de7af3a32b95c1bdf05394563c60175f'
'4ac1ec6372899693548d2d7d575f312d704b6883b50c8d4d3740f47a8e08eef3')

prepare() {
cd "${srcdir}/${_realname}-${pkgver}"
patch -p1 -i "${srcdir}"/0001-luarocks_msys2_mingw_w64.patch
}

build() {
cd "${srcdir}/${_realname}-${pkgver}"
./configure --prefix=${MINGW_PREFIX} --lua-version=5.4 --with-lua-interpreter=lua.exe
make ./build/luarocks ./build/luarocks-admin ./build/config-5.4.lua
make LUA_VERSION=5.1 LUA_INTERPRETER=lua5.1.exe LUA_INCDIR=${MINGW_PREFIX}/include/lua5.1 ./build/config-5.1.lua
}

package() {
cd "${srcdir}/${_realname}-${pkgver}"
make DESTDIR="${pkgdir}" install
make DESTDIR="$pkgdir" LUA_VERSION=5.1 install-config
}
21 changes: 21 additions & 0 deletions .github/workflows/mingw-w64-lua-luarocks/luarocks-CLANG32.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MINGW_PREFIX=/clang32

post_install() {
PREFIX_WIN=$(cygpath -m ${MINGW_PREFIX})
sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/etc/luarocks/config-5.1.lua

sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/etc/luarocks/config-5.4.lua

sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/bin/luarocks

sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/bin/luarocks-admin

}

post_upgrade() {
post_install
}
21 changes: 21 additions & 0 deletions .github/workflows/mingw-w64-lua-luarocks/luarocks-CLANG64.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MINGW_PREFIX=/clang64

post_install() {
PREFIX_WIN=$(cygpath -m ${MINGW_PREFIX})
sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/etc/luarocks/config-5.1.lua

sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/etc/luarocks/config-5.4.lua

sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/bin/luarocks

sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/bin/luarocks-admin

}

post_upgrade() {
post_install
}
21 changes: 21 additions & 0 deletions .github/workflows/mingw-w64-lua-luarocks/luarocks-MINGW32.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MINGW_PREFIX=/mingw32

post_install() {
PREFIX_WIN=$(cygpath -m ${MINGW_PREFIX})
sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/etc/luarocks/config-5.1.lua

sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/etc/luarocks/config-5.4.lua

sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/bin/luarocks

sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/bin/luarocks-admin

}

post_upgrade() {
post_install
}
21 changes: 21 additions & 0 deletions .github/workflows/mingw-w64-lua-luarocks/luarocks-MINGW64.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MINGW_PREFIX=/mingw64

post_install() {
PREFIX_WIN=$(cygpath -m ${MINGW_PREFIX})
sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/etc/luarocks/config-5.1.lua

sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/etc/luarocks/config-5.4.lua

sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/bin/luarocks

sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/bin/luarocks-admin

}

post_upgrade() {
post_install
}
21 changes: 21 additions & 0 deletions .github/workflows/mingw-w64-lua-luarocks/luarocks-UCRT64.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MINGW_PREFIX=/ucrt64

post_install() {
PREFIX_WIN=$(cygpath -m ${MINGW_PREFIX})
sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/etc/luarocks/config-5.1.lua

sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/etc/luarocks/config-5.4.lua

sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/bin/luarocks

sed -s "s|${MINGW_PREFIX}|${PREFIX_WIN}|g" \
-i ${MINGW_PREFIX}/bin/luarocks-admin

}

post_upgrade() {
post_install
}
95 changes: 95 additions & 0 deletions .github/workflows/test-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: test-windows

on: [push, workflow_dispatch]

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [windows-latest]
luaVersion: ["5.4"]

runs-on: ${{ matrix.os }}

defaults:
run:
shell: msys2 {0}

steps:
- shell: cmd
run: git config --global core.autocrlf input

- uses: actions/checkout@master

- uses: msys2/setup-msys2@v2
with:
msystem: mingw64
pacboy: >-
binutils:
patch:
zip:
unzip:
cc:p
libltdl:p
libtool:p
pkgconf:p
autotools:p
lua:p
cairo:p
- name: setup-luarocks
shell: msys2 {0}
run: |
uname -a
pwd
echo "-----------------------------------------------------------"
echo "-- Workaround for msys2-luarocks bug, "
echo "-- see: https://github.com/msys2/MINGW-packages/pull/12002 "
echo "-----------------------------------------------------------"
cd .github/workflows/mingw-w64-lua-luarocks
makepkg-mingw -isCf --noconfirm
cd -
echo "-----------------------------------------------------------"
type lua
type luarocks
lua -v
luarocks
luarocks install luafilesystem
- name: setup-lwtk
shell: msys2 {0}
run: |
luarocks install lpath
luarocks install oocairo
luarocks install https://luarocks.org/manifests/xavier-wang/luautf8-0.1.5-2.rockspec
luarocks --server=https://luarocks.org/dev install lpugl
luarocks --server=https://luarocks.org/dev install lpugl_cairo
luarocks --server=https://luarocks.org/dev install lpugl_opengl
echo "-----------------------------------------------------------"
luarocks make lwtk-scm-0.rockspec
echo "-----------------------------------------------------------"
- name: alltests
shell: msys2 {0}
run: |
set -e
lua -v
echo "-----------------------------------------------------------"
lua src/alltests.lua src/tests
echo "-----------------------------------------------------------"
- name: doctest
shell: msys2 {0}
run: |
set -e
lua -v
cd src
lua -e 'print("package.path=", package.path)'
export LUA_PATH='.\?.lua;.\?\init.lua;'"$(lua -e 'print(package.path)')"
echo "LUA_PATH=$LUA_PATH"
lua -e 'print("package.path=", package.path)'
echo "-----------------------------------------------------------"
lua doctest.lua
echo "-----------------------------------------------------------"
Loading

0 comments on commit dc4d15a

Please sign in to comment.