1+ name : MSVC CI
2+
3+ on :
4+ push :
5+ branches : [ master ]
6+ pull_request :
7+ branches : [ master ]
8+
9+ jobs :
10+ build-msvc-puc :
11+ name : Test on PUC-Rio Lua (MSVC)
12+ runs-on : windows-latest
13+
14+ strategy :
15+ matrix :
16+
17+ version :
18+ - 5.1.5
19+ - 5.2.4
20+ - 5.3.6
21+ - 5.4.7
22+
23+ gtk-major-version :
24+ - 3
25+ - 4
26+
27+ env :
28+ WINGTK_URL : https://github.com/wingtk/gvsbuild/releases/download/2024.10.0/GTK${{ matrix.gtk-major-version }}_Gvsbuild_2024.10.0_x64.zip
29+ LUAINSTALLER_URL : https://github.com/luau-project/LuaInstaller/releases/download/v0.2.0.0/LuaInstaller.Console-v0.2.0.0-x64.zip
30+
31+ steps :
32+
33+ - name : Download and extract GTK ${{ matrix.gtk-major-version }} prebuilt binaries (MSVC toolset) provided by wingtk
34+ run : |
35+ $gtk_zip_file = Join-Path -Path "${{ runner.temp }}" -ChildPath "gtk.zip";
36+
37+ # Download
38+ Invoke-WebRequest -Uri "${{ env.WINGTK_URL }}" -OutFile $gtk_zip_file;
39+
40+ # Unzip
41+ $gtk_dir = Join-Path -Path "${{ runner.temp }}" -ChildPath "gtk";
42+ Expand-Archive -Path $gtk_zip_file -DestinationPath "${gtk_dir}";
43+
44+ # Some helper variables
45+ $gtk_bin_dir = Join-Path -Path $gtk_dir -ChildPath "bin";
46+ $gtk_pkg_config_dir = Join-Path -Path $gtk_dir -ChildPath "lib" |
47+ Join-Path -ChildPath "pkgconfig";
48+
49+ # Set environment variable GTK_DIR pointing to GTK's directory
50+ Add-Content "${{ github.env }}" "GTK_DIR=${gtk_dir}";
51+
52+ # Set environment variable GTK_BIN_DIR pointing to GTK's bin directory
53+ Add-Content "${{ github.env }}" "GTK_BIN_DIR=${gtk_bin_dir}";
54+
55+ # Set environment variable GTK_PKG_CONFIG_PATH pointing to GTK's pkg-config directory
56+ Add-Content "${{ github.env }}" "GTK_PKG_CONFIG_PATH=${gtk_pkg_config_dir}";
57+
58+ # Place GTK bin directory on system PATH environment variable
59+ Add-Content "${{ github.path }}" "${gtk_bin_dir}";
60+
61+ - name : Download and extract LuaInstaller, and set an environment variable for it
62+ run : |
63+ $luainstaller_zip_file = Join-Path -Path "${{ runner.temp }}" -ChildPath "luainstaller.zip";
64+
65+ # Download
66+ Invoke-WebRequest -Uri "${{ env.LUAINSTALLER_URL }}" -OutFile $luainstaller_zip_file;
67+
68+ # Unzip
69+ Expand-Archive -Path $luainstaller_zip_file -DestinationPath "${{ runner.temp }}";
70+
71+ $luainstaller = Join-Path -Path "${{ runner.temp }}" -ChildPath "LuaInstaller.Console" |
72+ Join-Path -ChildPath "LuaInstaller.Console.exe";
73+
74+ # Set LUA_INSTALLER environment variable pointing to the app
75+ Add-Content "${{ github.env }}" "LUA_INSTALLER=${luainstaller}";
76+
77+ - name : Install Lua ${{ matrix.version }} on GTK's directory and set environment variables for it
78+ run : |
79+ & "${{ env.LUA_INSTALLER }}" install "dest-dir=${{ env.GTK_DIR }}" "version=${{ matrix.version }}";
80+
81+ # Test Lua
82+ & lua -v;
83+
84+ # Find Lua's pkgconfig (.pc) file
85+ $lua_pc = Get-ChildItem "${{ env.GTK_PKG_CONFIG_PATH }}" -File |
86+ Where-Object Name -Like "lua*.pc" |
87+ Select-Object -ExpandProperty BaseName -First 1;
88+
89+ # Set LUA_PC environment variable pointing to Lua's (.pc) file
90+ Add-Content "${{ github.env }}" "LUA_PC=${lua_pc}";
91+
92+ - name : Setup Python 3.12
93+ uses : actions/setup-python@v5
94+ with :
95+ python-version : ' 3.12'
96+
97+ - name : Install meson
98+ run : pip install meson
99+
100+ - name : Setup MSVC dev-prompt
101+ uses : ilammy/msvc-dev-cmd@v1
102+
103+ - name : Checkout
104+ uses : actions/checkout@v4
105+
106+ - name : Configure lgi through meson
107+ run : meson setup lgi-build . --prefix "${{ env.GTK_DIR }}" "-Dlua-pc=${{ env.LUA_PC }}" -Dtests=false
108+
109+ - name : Build lgi
110+ run : meson compile -C lgi-build
111+
112+ - name : Install lgi
113+ run : meson install -C lgi-build
114+
115+ - name : Create a simple test script using lgi
116+ run : |
117+ $test_script = @'
118+ local lgi = assert(require("lgi"))
119+ local Gtk = assert(lgi.require("Gtk", "${{ matrix.gtk-major-version }}.0"))
120+
121+ local app = Gtk.Application({ application_id = "org.lgi-devs.lgi" })
122+
123+ function app:on_activate()
124+ local w = Gtk.ApplicationWindow()
125+ w:set_default_size(900, 600)
126+ w:set_title("My great title")
127+
128+ w.application = self
129+
130+ if ("${{ matrix.gtk-major-version }}" == "3") then
131+ w:show_all()
132+ elseif ("${{ matrix.gtk-major-version }}" == "4") then
133+ w:present()
134+ else
135+ error("Unknown GTK version")
136+ end
137+
138+ w:close()
139+ end
140+
141+ app:run()
142+ '@;
143+
144+ $test_file = Join-Path -Path "${{ runner.temp }}" -ChildPath "small-lgi-test.lua";
145+
146+ # Write the script above to file
147+ Set-Content $test_file $test_script -NoNewLine;
148+
149+ # Set the test file name on LGI_TEST_FILE environment variable
150+ Add-Content "${{ github.env }}" "LGI_TEST_FILE=${test_file}";
151+
152+ - name : Test lgi
153+ run : lua "${{ env.LGI_TEST_FILE }}"
0 commit comments