Skip to content

Commit c70e9dd

Browse files
authored
Implement a docker container for tests (#8199)
* FEAT: implement container for tests * FEAT: add action for building image * FIX: pin luajit by hash instead of tag * FIX: typo
1 parent 5dc8ca4 commit c70e9dd

File tree

4 files changed

+97
-30
lines changed

4 files changed

+97
-30
lines changed

.github/workflows/builddocker.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build and publish busted tests docker image
2+
on:
3+
workflow_dispatch:
4+
jobs:
5+
build-and-push-image:
6+
runs-on: ubuntu-latest
7+
permissions:
8+
contents: read
9+
packages: write
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
- name: Log in to the Container registry
14+
uses: docker/login-action@v3
15+
with:
16+
registry: ghcr.io
17+
username: ${{ github.repository_owner }}
18+
password: ${{ secrets.GITHUB_TOKEN }}
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v3
21+
- name: Generate docker image metadata
22+
uses: docker/metadata-action@v5
23+
id: meta
24+
with:
25+
images: |
26+
ghcr.io/${{ github.repository_owner }}/pathofbuilding-tests
27+
labels: |
28+
org.opencontainers.image.description=A docker image packaged with the correct versions of tools to run PathOfBuilding busted tests. Includes emmylua debugger files. Refer to https://github.com/PathOfBuildingCommunity/PathOfBuilding/blob/dev/CONTRIBUTING.md for usage instructions.
29+
org.opencontainers.image.licenses=https://opensource.org/licenses/MIT
30+
tags: |
31+
type=sha
32+
type=raw,value=latest
33+
- name: Build and push Docker image
34+
uses: docker/build-push-action@v5
35+
with:
36+
context: .
37+
push: true
38+
platforms: linux/amd64
39+
cache-from: type=gha
40+
cache-to: type=gha,mode=max
41+
tags: ${{ steps.meta.outputs.tags }}
42+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/test.yml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,11 @@ on:
77
jobs:
88
run_tests:
99
runs-on: ubuntu-latest
10+
container: ghcr.io/paliak/pathofbuilding-tests:latest
1011
steps:
1112
- name: Checkout
12-
uses: actions/checkout@v2
13-
- name: Install Lua/LuaJIT
14-
uses: leafo/gh-actions-lua@v8.0.0
15-
with:
16-
luaVersion: "luajit-2.0.5"
17-
- name: Install LuaRocks
18-
uses: leafo/gh-actions-luarocks@v4.0.0
19-
- name: Install busted
20-
run: luarocks install busted
21-
- name: Install cluacov
22-
run: luarocks install cluacov 0.1.2-1
23-
- name: Install coveralls integration
24-
run: luarocks install luacov-coveralls
13+
uses: actions/checkout@v4
2514
- name: Run tests
26-
run: busted --lua=/home/runner/work/PathOfBuilding/PathOfBuilding/.lua/bin/luajit
15+
run: busted --lua=luajit
2716
- name: Report coverage
2817
run: cd src; luacov-coveralls --repo-token=${{ secrets.github_token }} -e TestData -e Data -e runtime

Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM alpine:3.18 AS base
2+
# Common dependencies
3+
RUN apk add --no-cache cmake readline-dev build-base tar
4+
5+
FROM base AS buildbase
6+
# Build dependencies
7+
RUN apk add --no-cache git
8+
WORKDIR /opt
9+
RUN wget https://www.lua.org/ftp/lua-5.1.5.tar.gz && tar -xf lua-5.1.5.tar.gz
10+
RUN cd lua-5.1.5 && make linux && make install
11+
12+
FROM buildbase AS luarocks
13+
RUN wget https://luarocks.org/releases/luarocks-3.7.0.tar.gz && tar xf luarocks-3.7.0.tar.gz
14+
RUN cd luarocks-3.7.0 && ./configure && make
15+
16+
FROM buildbase AS luajit
17+
RUN git clone https://github.com/LuaJIT/LuaJIT && cd LuaJIT && git checkout c7db8255e1eb59f933fac7bc9322f0e4f8ddc6e6
18+
RUN cd LuaJIT && make
19+
20+
FROM buildbase AS emmyluadebugger
21+
RUN git clone --depth 1 --branch 1.7.1 https://github.com/EmmyLua/EmmyLuaDebugger
22+
RUN cd EmmyLuaDebugger && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release ../ && make
23+
24+
FROM base
25+
# Luarocks packages dependencies
26+
RUN apk add --no-cache curl unzip openssl
27+
28+
RUN --mount=type=cache,from=buildBase,source=/opt,target=/opt make -C /opt/lua-5.1.5/ install
29+
RUN --mount=type=cache,from=luarocks,source=/opt,target=/opt make -C /opt/luarocks-3.7.0/ install
30+
31+
# Install here to install lua rocks pkgs in pararell with compilation of emmylua and luajit
32+
RUN luarocks install busted 2.2.0-1;\
33+
luarocks install cluacov 0.1.2-1;\
34+
luarocks install luacov-coveralls 0.2.3-1
35+
36+
RUN --mount=type=cache,from=emmyluadebugger,source=/opt,target=/opt make -C /opt/EmmyLuaDebugger/build/ install
37+
RUN --mount=type=cache,from=luajit,source=/opt,target=/opt make -C /opt/LuaJIT/ install
38+
39+
CMD [ "echo", "This container is meant to be ran with docker compose. See: https://github.com/PathOfBuildingCommunity/PathOfBuilding/blob/dev/CONTRIBUTING.md" ]

docker-compose.yml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
version: "3.8"
21
services:
3-
42
busted-tests:
5-
image: summ1else/poe-busted-image
6-
container_name: busted-tests
7-
command: bash -c "rm -f spec/test_results.log && busted --lua=luajit | tee spec/test_results.log"
3+
#build: .
4+
image: ghcr.io/paliak/pathofbuilding-tests:latest
5+
environment:
6+
HOME: /tmp
7+
container_name: pathofbuilding-tests
8+
user: nobody:nobody
9+
command: busted --lua=luajit
10+
security_opt:
11+
- no-new-privileges:true
12+
ports:
13+
- "9966:9966"
14+
working_dir: /workdir
815
volumes:
9-
- ./:/root
10-
depends_on:
11-
- busted-generate-build
12-
13-
busted-generate-build:
14-
image: summ1else/poe-busted-image
15-
container_name: busted-generate-build
16-
command: bash -c "rm -f spec/test_generation.log && busted --lua=luajit -r generate | tee spec/test_generation.log"
17-
restart: "no"
18-
volumes:
19-
- ./:/root
16+
- ./:/workdir:ro

0 commit comments

Comments
 (0)