Skip to content

Commit 2e8dc69

Browse files
authored
Merge pull request #239 from prometheus-lua/docker-test-runner
Docker-based test runner with lua5.1, upstream LuaJIT, and Luau
2 parents b35fa0e + 51baddd commit 2e8dc69

8 files changed

Lines changed: 545 additions & 17 deletions

File tree

.dockerignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
node_modules
2+
web/node_modules
3+
web/dist
4+
web/dist-ssr
5+
web/public/docs
6+
web/test-results
7+
web/playwright-report
8+
.vite
9+
.vscode
10+
dist
11+
build
12+
Dockerfile
13+
.dockerignore
14+
.git
15+
.gitignore

.github/workflows/Test.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Test
2-
on:
2+
on:
33
push:
44
branches:
55
- master
@@ -8,14 +8,10 @@ on:
88
- master
99

1010
jobs:
11-
test-linux:
11+
test-docker:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout repo
15-
uses: actions/checkout@master
16-
- name: Install Lua
17-
uses: leafo/gh-actions-lua@master
18-
with:
19-
luaVersion: 5.1
20-
- name: Run test case
21-
run: lua ./tests.lua --Linux --CI
15+
uses: actions/checkout@v4
16+
- name: Build and run tests
17+
run: bash scripts/run-tests.sh -b -n 10 --ci

.github/workflows/release.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: actions/checkout@v4
17-
- name: Install Lua 5.1
18-
run: |
19-
sudo apt-get update
20-
sudo apt-get install -y lua5.1
21-
- name: Run tests
22-
run: lua5.1 ./tests.lua --Linux
17+
- name: Build and run tests
18+
run: bash scripts/run-tests.sh -b -n 10 --ci
2319

2420
package:
2521
name: Package (${{ matrix.os_name }})

CONTRIBUTING.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,29 @@ Thanks for contributing to Prometheus.
1010
- Add or update tests when changing behavior.
1111
- Document user-visible changes clearly.
1212

13+
## Running Tests
14+
15+
Tests run inside a Docker container with lua5.1 and Luau:
16+
17+
```bash
18+
./scripts/run-tests.sh # Run all tests (default: 10 iterations)
19+
./scripts/run-tests.sh -b # Build image (needed first time or after Dockerfile changes)
20+
./scripts/run-tests.sh -n 5 # Run with 5 iterations
21+
./scripts/run-tests.sh -c config.lua # Use a custom config
22+
./scripts/run-tests.sh -v # Verbose output
23+
```
24+
25+
### Test File Metadata
26+
27+
Test files can include metadata comments at the top of the file:
28+
29+
| Annotation | Effect |
30+
|-----------|--------|
31+
| `-- @skip` | Skip this test entirely |
32+
| `-- @luau-only` | Only run with Luau |
33+
| `-- @runtime lua51 luajit` | Only run with specified runtimes |
34+
| `-- @skip-preset Weak` | Skip a specific preset for this test |
35+
1336
## Reporting Bugs
1437

1538
When opening a bug report, include:

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM ubuntu:24.04
2+
3+
RUN apt-get update && apt-get install -y \
4+
lua5.1 \
5+
git \
6+
unzip \
7+
curl \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
# Download pre-built Luau binary
11+
RUN curl -sSLo /tmp/luau-ubuntu.zip \
12+
https://github.com/luau-lang/luau/releases/latest/download/luau-ubuntu.zip \
13+
&& unzip -j /tmp/luau-ubuntu.zip luau -d /usr/local/bin \
14+
&& chmod +x /usr/local/bin/luau \
15+
&& rm /tmp/luau-ubuntu.zip
16+
17+
# Verify installations
18+
RUN lua5.1 -v && printf 'print("luau OK")\n' > /tmp/luau_check.lua && luau /tmp/luau_check.lua && rm /tmp/luau_check.lua
19+
20+
WORKDIR /app
21+
COPY . /app
22+
23+
ENTRYPOINT ["lua5.1", "docker-test-runner.lua"]

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,14 @@ For more advanced use cases, configuration, and presets, see the [documentation]
138138

139139
## Tests
140140

141-
To run the Prometheus test suite:
141+
The test suite runs inside Docker with lua5.1 and Luau:
142142

143143
```bash
144-
lua ./tests.lua [--Linux]
144+
./scripts/run-tests.sh # Run all tests (default: 10 iterations)
145+
./scripts/run-tests.sh -b # Build image and run tests
146+
./scripts/run-tests.sh -n 5 # Run with 5 iterations
147+
./scripts/run-tests.sh -c config.lua # Use a custom config
148+
./scripts/run-tests.sh -v # Verbose output
145149
```
146150

147151
---

0 commit comments

Comments
 (0)