Skip to content

Commit ea7ab3a

Browse files
committed
docs: add CI examples
1 parent 776c46f commit ea7ab3a

3 files changed

Lines changed: 317 additions & 17 deletions

File tree

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
1-
![CI](https://github.com/luau-project/LuaInstaller/actions/workflows/CI.yaml/badge.svg)
1+
# LuaInstaller
2+
3+
[![CI](https://github.com/luau-project/LuaInstaller/actions/workflows/CI.yaml/badge.svg)](./.github/workflows/CI.yaml)
24
[![github release](https://img.shields.io/github/release/luau-project/LuaInstaller.svg?logo=github)](https://github.com/luau-project/LuaInstaller/releases/latest)
35

6+
[![icon](./LuaInstaller/Assets/LuaInstaller-256x256.ico)](#overview)
7+
48
## Overview
59

6-
The toolset available here aids the process to download, build and install Lua versions on Windows, downloading Lua source code directly from [https://www.lua.org](https://www.lua.org).
10+
The toolset available here aids in the process to download, build and install Lua versions on Windows, downloading Lua source code directly from [https://www.lua.org](https://www.lua.org).
711

812
## Table of Contents
913
* [For End-Users](#for-end-users)
1014
* [Setup](#setup)
1115
* [Running](#running)
1216
* [For Developers](#for-developers)
13-
* [Future Work](#future-work)
1417
* [Contributors](#contributors)
1518

1619
## For End-Users
@@ -22,19 +25,23 @@ The toolset available here aids the process to download, build and install Lua v
2225
> Among all the possible versions of Visual Studio, **Visual Studio Community** edition or **Visual Studio Build Tools** are the preferred choices for individuals.
2326
2427
1. Visit [https://visualstudio.microsoft.com](https://visualstudio.microsoft.com), download and install the most recent MSVC (Microsoft Visual Studio for C/C++) Build Tools for x86/x64 native desktop development together with the most recent Windows SDK for your operating system:
25-
* Step 1: On the latest Visual Studio installer, switch to individual components tab;
28+
* **Step 1**: On the latest Visual Studio installer, switch to ```Individual components``` tab;
2629

2730
![Step 1: Switch to Individual Components tab](https://github.com/user-attachments/assets/8f848c4e-d61d-4fc7-a869-a0b63fb4aecb)
2831

29-
* Step 2: Search for "Windows SDK"; Step 3: Select the most recent;
32+
* **Step 2**: Search for ```Windows SDK```;
33+
* **Step 3**: Select the most recent;
3034

3135
![Step 2: Search for "Windows SDK"; Step 3: Select the most recent;](https://github.com/user-attachments/assets/04a3a6a6-297c-4935-a5b7-0baa41cddc12)
3236

33-
* Step 4: Search for "MSVC Build Tools"; Step 5: Select the latest x86/x64 build tools; Step 6: Verify the "Individual Components" selection shows the latest Build Tools and Windows SDK; Step 7: Hit "Install" button and await the installation.
37+
* **Step 4**: Search for ```MSVC Build Tools```;
38+
* **Step 5**: Select the ```latest``` MSVC x86/x64 build tools available;
39+
* **Step 6**: Verify that ```Individual components``` selection in the right panel shows the latest Build Tools and Windows SDK;
40+
* **Step 7**: Hit ```Install``` button and await the installation.
3441

3542
![Step 4: Search for MSVC Build Tools; Step 5: Select the latest x86/x64 build tools; Step 6: Verify that the Individual Components selection shows the latest Build Tools and Windows SDK; Step 7: Hit Install button and await the installation.](https://github.com/user-attachments/assets/7c3cec11-31d5-4bc7-85bb-08ba53b655c1)
3643

37-
2. Download and extract the latest ```LuaInstaller.EndUsers-*.zip``` from the [Releases](https://github.com/luau-project/LuaInstaller/releases) page anywhere on your computer;
44+
2. Download and extract the latest ```LuaInstaller.EndUsers-*.zip``` from the [Releases](https://github.com/luau-project/LuaInstaller/releases/latest) page anywhere on your computer;
3845

3946
### Running
4047

@@ -54,17 +61,10 @@ The toolset available here aids the process to download, build and install Lua v
5461

5562
## For Developers
5663

57-
Do you want to integrate it on your project? Read the [docs](./docs/README.md).
58-
59-
## Future Work
60-
61-
We want to ease the process to have latest versions of Lua and LuaRocks installed in the system, so LuaRocks support is on top of our todo list.
64+
* Are you looking for CI / CD content? [check our CI examples here](./docs/UsageCI.md).
6265

63-
The following features might come in next releases
64-
* Logging
65-
* LuaRocks installation
66-
* Full rewrite of the project
66+
* Do you want to integrate it on your project? Read the [docs](./docs/README.md).
6767

6868
## Contributors
6969

70-
Special thanks goes to [warlockx](https://github.com/Warlockx) for bug hunting and valuable suggestions that are going to be incorporated soon.
70+
Special thanks goes to [warlockx](https://github.com/Warlockx) for valuable suggestions and bug hunting in the beginning of this project.

docs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Did you get here by a mistake? Back to the project's [home page](../).
88

99
## Developers
1010

11+
Are you looking for CI / CD content? [check our CI examples here](./UsageCI.md).
12+
1113
> [!IMPORTANT]
1214
>
1315
> Before you try to use the tools and libraries provided here, be sure to perform the [initial setup](../README.md#setup).

docs/UsageCI.md

Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
1+
# Usage in CI servers
2+
3+
## Overview
4+
5+
By the use of ```LuaInstaller.Console```, you can setup continuous integration / continuous delivery (CI CD) to buid and test your Lua-related project on Windows against the MSVC toolchain.
6+
7+
## Table of Contents
8+
9+
* [Setup Lua](#setup-lua)
10+
* [Setup Lua and LuaRocks](#setup-lua-and-luarocks)
11+
12+
## Setup Lua
13+
14+
Below, in a GitHub workflow, we setup different versions of Lua, building for x64 and x86 architectures.
15+
16+
> [!TIP]
17+
>
18+
> After testing the built interpreter, as a bonus, we also make Lua discoverable by ```CMake``` and ```pkg-config```.
19+
20+
```yaml
21+
name: Setup Lua
22+
23+
on: [push, pull_request]
24+
25+
env:
26+
LUAINSTALLER_VERSION: 0.5.0.0
27+
28+
jobs:
29+
30+
build:
31+
runs-on: windows-latest
32+
name: Build
33+
34+
strategy:
35+
matrix:
36+
37+
lua-version:
38+
- 5.1.5
39+
- 5.2.4
40+
- 5.3.6
41+
- 5.4.7
42+
43+
arch:
44+
- x64
45+
- x86
46+
47+
steps:
48+
49+
- name: Sanity check the Lua version
50+
shell: pwsh
51+
run: |
52+
if (-not ("${{ matrix.lua-version }}" -match "^[0-9]+\.[0-9]+\.[0-9]+$"))
53+
{
54+
Write-Host "Invalid Lua version";
55+
exit 1;
56+
}
57+
58+
- name: Sanity check the architecture
59+
run: |
60+
if (-not ("${{ matrix.arch }}" -match "^[xX](64|86)$"))
61+
{
62+
Write-Host "Invalid architecture";
63+
exit 1;
64+
}
65+
66+
- name: Set environment variable to hold Lua's installation directory
67+
shell: pwsh
68+
run: |
69+
$guid_string = [System.Guid]::NewGuid() | Select-Object -ExpandProperty Guid;
70+
$lua_dir = Join-Path -Path "${{ runner.temp }}" -ChildPath $guid_string;
71+
Add-Content "${{ github.env }}" "LUA_DIR=${lua_dir}";
72+
73+
- name: Download and extract LuaInstaller.Console, and place it on PATH environment variable
74+
shell: pwsh
75+
env:
76+
LUAINSTALLER_URL: https://github.com/luau-project/LuaInstaller/releases/download/v${{ env.LUAINSTALLER_VERSION }}/LuaInstaller.Console-v${{ env.LUAINSTALLER_VERSION }}-${{ matrix.arch }}.zip
77+
run: |
78+
$guid_string = [System.Guid]::NewGuid() | Select-Object -ExpandProperty Guid;
79+
$luainstaller_zip_file = Join-Path -Path "${{ runner.temp }}" -ChildPath "${guid_string}.zip";
80+
81+
# Download
82+
Invoke-WebRequest -Uri "${{ env.LUAINSTALLER_URL }}" -OutFile $luainstaller_zip_file;
83+
84+
# Unzip
85+
Expand-Archive -Path $luainstaller_zip_file -DestinationPath "${{ runner.temp }}";
86+
87+
$luainstaller_path = Join-Path -Path "${{ runner.temp }}" -ChildPath "LuaInstaller.Console";
88+
89+
# Add LuaInstaller.Console to the PATH environment variable
90+
Add-Content "${{ github.path }}" "${luainstaller_path}";
91+
92+
- name: Install Lua ${{ matrix.lua-version }}
93+
run: |
94+
LuaInstaller.Console install "dest-dir=${{ env.LUA_DIR }}" "version=${{ matrix.lua-version }}" "arch=${{ matrix.arch }}"
95+
96+
- name: Add Lua interpreter and DLL to PATH environment variable
97+
shell: pwsh
98+
run: |
99+
$lua_bin = Join-Path -Path "${{ env.LUA_DIR }}" -ChildPath "bin";
100+
Add-Content "${{ github.path }}" "${lua_bin}";
101+
102+
- name: Test Lua ${{ matrix.lua-version }}
103+
run: lua -v
104+
105+
- name: Setup Lua ${{ matrix.lua-version }} for CMake
106+
shell: pwsh
107+
run: |
108+
$cmake_module_path = "$env:CMAKE_MODULE_PATH";
109+
Add-Content "${{ github.env }}" "CMAKE_MODULE_PATH=${{ env.LUA_DIR }};${cmake_module_path}";
110+
111+
- name: Setup Lua ${{ matrix.lua-version }} for pkg-config
112+
shell: pwsh
113+
run: |
114+
$lua_pc_dir = Get-ChildItem "${{ env.LUA_DIR }}" -File -Recurse |
115+
Where-Object Name -Like "lua*.pc" |
116+
Select-Object -ExpandProperty FullName -First 1 |
117+
Split-Path;
118+
119+
$pkg_config_path = "$env:PKG_CONFIG_PATH";
120+
Add-Content "${{ github.env }}" "PKG_CONFIG_PATH=${lua_pc_dir};${pkg_config_path}";
121+
```
122+
123+
## Setup Lua and LuaRocks
124+
125+
This time, in another GitHub workflow, we setup Lua and LuaRocks. At the end of the workflow, we install a few libraries using LuaRocks.
126+
127+
```yaml
128+
name: Setup Lua and LuaRocks
129+
130+
on: [push, pull_request]
131+
132+
env:
133+
LUAINSTALLER_VERSION: 0.5.0.0
134+
LUAROCKS_VERSION: 3.11.1
135+
136+
jobs:
137+
138+
build:
139+
runs-on: windows-latest
140+
name: Build
141+
142+
strategy:
143+
matrix:
144+
145+
lua-version:
146+
- 5.1.5
147+
- 5.2.4
148+
- 5.3.6
149+
- 5.4.7
150+
151+
arch:
152+
- x64
153+
- x86
154+
155+
steps:
156+
157+
- name: Sanity check the Lua version
158+
shell: pwsh
159+
run: |
160+
if (-not ("${{ matrix.lua-version }}" -match "^[0-9]+\.[0-9]+\.[0-9]+$"))
161+
{
162+
Write-Host "Invalid Lua version";
163+
exit 1;
164+
}
165+
166+
- name: Sanity check the architecture
167+
run: |
168+
if (-not ("${{ matrix.arch }}" -match "^[xX](64|86)$"))
169+
{
170+
Write-Host "Invalid architecture";
171+
exit 1;
172+
}
173+
174+
- name: Set environment variable to hold Lua's installation directory
175+
shell: pwsh
176+
run: |
177+
$guid_string = [System.Guid]::NewGuid() | Select-Object -ExpandProperty Guid;
178+
$lua_dir = Join-Path -Path "${{ runner.temp }}" -ChildPath $guid_string;
179+
Add-Content "${{ github.env }}" "LUA_DIR=${lua_dir}";
180+
181+
- name: Download and extract LuaInstaller.Console, and place it on PATH environment variable
182+
shell: pwsh
183+
env:
184+
LUAINSTALLER_URL: https://github.com/luau-project/LuaInstaller/releases/download/v${{ env.LUAINSTALLER_VERSION }}/LuaInstaller.Console-v${{ env.LUAINSTALLER_VERSION }}-${{ matrix.arch }}.zip
185+
run: |
186+
$guid_string = [System.Guid]::NewGuid() | Select-Object -ExpandProperty Guid;
187+
$luainstaller_zip_file = Join-Path -Path "${{ runner.temp }}" -ChildPath "${guid_string}.zip";
188+
189+
# Download
190+
Invoke-WebRequest -Uri "${{ env.LUAINSTALLER_URL }}" -OutFile $luainstaller_zip_file;
191+
192+
# Unzip
193+
Expand-Archive -Path $luainstaller_zip_file -DestinationPath "${{ runner.temp }}";
194+
195+
$luainstaller_path = Join-Path -Path "${{ runner.temp }}" -ChildPath "LuaInstaller.Console";
196+
197+
# Add LuaInstaller.Console to the PATH environment variable
198+
Add-Content "${{ github.path }}" "${luainstaller_path}";
199+
200+
- name: Install Lua ${{ matrix.lua-version }}
201+
run: |
202+
LuaInstaller.Console install "dest-dir=${{ env.LUA_DIR }}" "version=${{ matrix.lua-version }}" "arch=${{ matrix.arch }}"
203+
204+
- name: Add Lua interpreter and DLL to PATH environment variable
205+
shell: pwsh
206+
run: |
207+
$lua_bin = Join-Path -Path "${{ env.LUA_DIR }}" -ChildPath "bin";
208+
Add-Content "${{ github.path }}" "${lua_bin}";
209+
210+
- name: Test Lua ${{ matrix.lua-version }}
211+
run: lua -v
212+
213+
- name: Setup Lua ${{ matrix.lua-version }} for CMake
214+
shell: pwsh
215+
run: |
216+
$cmake_module_path = "$env:CMAKE_MODULE_PATH";
217+
Add-Content "${{ github.env }}" "CMAKE_MODULE_PATH=${{ env.LUA_DIR }};${cmake_module_path}";
218+
219+
- name: Setup Lua ${{ matrix.lua-version }} for pkg-config
220+
shell: pwsh
221+
run: |
222+
$lua_pc_dir = Get-ChildItem "${{ env.LUA_DIR }}" -File -Recurse |
223+
Where-Object Name -Like "lua*.pc" |
224+
Select-Object -ExpandProperty FullName -First 1 |
225+
Split-Path;
226+
227+
$pkg_config_path = "$env:PKG_CONFIG_PATH";
228+
Add-Content "${{ github.env }}" "PKG_CONFIG_PATH=${lua_pc_dir};${pkg_config_path}";
229+
230+
# Setting up LuaRocks
231+
- name: Set environment variable to LuaRocks download URL depending on arch
232+
shell: pwsh
233+
run: |
234+
$allowed_archs = @{ x86 = "32"; x64 = "64" };
235+
$arch_lower = "${{ matrix.arch }}".ToLower();
236+
237+
if ($allowed_archs.Keys -contains $arch_lower)
238+
{
239+
$v = $allowed_archs[$arch_lower];
240+
241+
Add-Content "${{ github.env }}" "LUAROCKS_URL=https://luarocks.github.io/luarocks/releases/luarocks-${{ env.LUAROCKS_VERSION }}-windows-${v}.zip";
242+
}
243+
else
244+
{
245+
Write-Host "Invalid arch: x64 or x86 expected, but got ${{ matrix.arch }}";
246+
exit 1;
247+
}
248+
249+
- name: Download and extract LuaRocks, and place it on PATH environment variable
250+
shell: pwsh
251+
run: |
252+
$uri = [System.Uri]::new("${{ env.LUAROCKS_URL }}");
253+
$zipname = $uri | Select-Object -ExpandProperty Segments | Select-Object -Last 1;
254+
255+
$luarocks_zip = Join-Path -Path "${{ runner.temp }}" -ChildPath "${zipname}";
256+
257+
# Download
258+
Invoke-WebRequest -Uri "${{ env.LUAROCKS_URL }}" -OutFile "${luarocks_zip}";
259+
260+
# Extract
261+
Expand-Archive -Path "${luarocks_zip}" -DestinationPath "${{ runner.temp }}";
262+
263+
$luarocks_dir = Get-ChildItem -Path "${{ runner.temp }}" -Recurse -File |
264+
Where-Object Name -EQ "luarocks.exe" |
265+
Select-Object -ExpandProperty FullName -First 1 |
266+
Split-Path;
267+
268+
# Add LuaRocks to PATH
269+
Add-Content "${{ github.path }}" "${luarocks_dir}";
270+
271+
- name: Setup MSVC dev-prompt for LuaRocks configuration
272+
uses: ilammy/msvc-dev-cmd@v1
273+
with:
274+
arch: ${{ matrix.arch }}
275+
276+
- name: Configure LuaRocks for Lua ${{ matrix.lua-version }}
277+
shell: pwsh
278+
run: |
279+
luarocks config lua_dir "${{ env.LUA_DIR }}";
280+
281+
$lua_short_version = "${{ matrix.lua-version }}" -split "\." |
282+
Select-Object -First 2 |
283+
Join-String -Separator ".";
284+
285+
luarocks config lua_version $lua_short_version;
286+
287+
# Update environment variables with variables from LuaRocks
288+
$luarocks_path = luarocks path;
289+
Add-Content "${{ github.env }}" $luarocks_path.Replace("""", "").Replace("'", "").Replace("SET ", "");
290+
291+
- name: Install a few libraries through LuaRocks
292+
run: |
293+
luarocks install luafilesystem
294+
luarocks install luasocket
295+
luarocks install lua-cjson
296+
```
297+
298+
[Back to the Docs](../docs/README.md)

0 commit comments

Comments
 (0)