Skip to content

Commit cdfe191

Browse files
committed
build: Add smoke test to CI test action and added new release action
1 parent ec4a44c commit cdfe191

File tree

7 files changed

+87
-17
lines changed

7 files changed

+87
-17
lines changed

.github/workflows/release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Release Rock
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Trigger for version tags
7+
8+
jobs:
9+
build_and_release:
10+
runs-on: ubuntu-24.04
11+
steps:
12+
- name: Check out code
13+
uses: actions/checkout@main
14+
- name: Set up Docker Buildx
15+
uses: docker/setup-buildx-action@v3
16+
- name: Set up Lua and Luarocks
17+
uses: leafo/gh-actions-lua@v10
18+
with:
19+
luaVersion: '5.4.7'
20+
- uses: leafo/gh-actions-luarocks@v4
21+
with:
22+
luarocksVersion: "3.11.1"
23+
- name: Build rockspec files
24+
run: |
25+
make pack # Generates *.rock and *.scm.rock
26+
git config user.name github-actions
27+
git config user.email [email protected]
28+
git add *.rockspec *.rock
29+
git commit -m "Add rockspec files for release ${GITHUB_REF##*/}"
30+
git push
31+
32+
- name: Publish to LuaRocks
33+
env:
34+
LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }}
35+
run: |
36+
luarocks upload --temp-key="${LUAROCKS_API_KEY}" *.rock *.src.rock

.github/workflows/tests.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,25 @@ jobs:
3434
artifact-name: code-coverage-report
3535
github-token: ${{ secrets.GITHUB_TOKEN }}
3636
update-comment: true
37+
smoke-tests:
38+
timeout-minutes: ${{ fromJSON(vars.GHA_DEFAULT_TIMEOUT || 10) }}
39+
name: Smoke Tests
40+
41+
runs-on: ubuntu-24.04
42+
43+
steps:
44+
- name: Checkout code
45+
uses: actions/checkout@v2
46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v3
48+
- name: Run the smoke test server
49+
run: |
50+
make smoke-test-run-server
51+
- name: Wait for service to be ready
52+
run: |
53+
# Wait until kong is ready
54+
timeout 60s bash -c 'until docker exec -it kong-plugin-kong-authz-openfga-smoke-test curl -i http://localhost:8007/status/ready; do sleep 5; done'
55+
56+
- name: Run smoke tests
57+
run: |
58+
make smoke-test-run-test

Makefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ CONTAINER_CI_KONG_SMOKE_TEST_BUILD = DOCKER_BUILDKIT=1 BUILDKIT_PROGRESS=$(BUILD
144144
--build-arg KONG_IMAGE_NAME='$(KONG_IMAGE_NAME)' \
145145
--build-arg KONG_IMAGE_TAG='$(KONG_IMAGE_TAG)' \
146146
--build-arg KONG_PLUGIN_NAME='$(KONG_PLUGIN_NAME)' \
147-
--build-arg KONG_PLUGIN_VERSION='$(KONG_PLUGIN_VERSION)' \
148-
--build-arg KONG_PLUGIN_REVISION='$(KONG_PLUGIN_REVISION)' \
149-
--build-arg KONG_PLUGIN_ROCK_FILE='$(ROCK_FILE)' \
147+
--build-arg KONG_PLUGIN_ROCKSPEC_FILE='$(ROCKSPEC_FILE)' \
150148
.
151149

152150
CONTAINER_CI_KONG_TOOLING_RUN := MSYS_NO_PATHCONV=1 $(DOCKER) run $(DOCKER_RUN_FLAGS) \
@@ -235,7 +233,7 @@ container-ci-kong-tooling-debug: DOCKER_NO_CACHE = '--no-cache'
235233
container-ci-kong-tooling-debug: container-ci-kong-tooling
236234

237235
.PHONY: container-ci-kong-smoke-test
238-
container-ci-kong-smoke-test: $(ROCK_FILE) container-network-ci
236+
container-ci-kong-smoke-test: container-network-ci
239237
$(CONTAINER_CI_KONG_SMOKE_TEST_BUILD)
240238

241239
.PHONY: container-ci-kong-smoke-test-debug

_build/images/kong-smoke-test/Dockerfile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,23 @@ FROM ${KONG_IMAGE_NAME}:${KONG_IMAGE_TAG} AS builder
55
USER root
66

77
ARG KONG_PLUGIN_NAME
8-
ARG KONG_PLUGIN_VERSION
9-
ARG KONG_PLUGIN_REVISION
10-
ARG KONG_PLUGIN_ROCK_FILE
8+
ARG KONG_PLUGIN_ROCKSPEC_FILE
119

1210
RUN dnf install -y gcc m4 --setopt=install_weak_deps=False \
1311
&& dnf clean all
1412

15-
COPY ${KONG_PLUGIN_ROCK_FILE} /${KONG_PLUGIN_ROCK_FILE}
13+
WORKDIR /plugin
14+
COPY . .
1615

17-
RUN luarocks install /${KONG_PLUGIN_ROCK_FILE}
16+
# Install from .rockspec
17+
RUN luarocks make ${KONG_PLUGIN_ROCKSPEC_FILE}
1818

1919
FROM ${KONG_IMAGE_NAME}:${KONG_IMAGE_TAG}
2020

2121
ENV KONG_LOG_LEVEL=debug
2222

23+
ENV KONG_NGINX_WORKER_PROCESSES=1
24+
2325
# Add the Lua files (.lua)
2426
COPY --from=builder /usr/local/share/lua/5.1 /usr/local/share/lua/5.1
2527

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Ignore all files
2+
*
3+
4+
# Exclude the following files
5+
!/kong/
6+
!/README.md
7+
!/LICENSE
8+
!/kong-plugin-kong-authz-openfga-*.rockspec

_build/images/kong-tooling/Dockerfile

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ ARG PONGO_ARCHIVE
1515
ARG STYLUA_VERSION
1616
ARG EMMY_LUA_DEBUGGER_VERSION
1717

18-
COPY kong-plugin-${KONG_PLUGIN_NAME}-${KONG_PLUGIN_VERSION}-${KONG_PLUGIN_REVISION}.rockspec /kong-plugin-${KONG_PLUGIN_NAME}-${KONG_PLUGIN_VERSION}-${KONG_PLUGIN_REVISION}.rockspec
19-
COPY _build/images/kong-plugin-testing-0.1.0-0.rockspec /kong-plugin-testing-0.1.0-0.rockspec
20-
2118
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
19+
2220
RUN dnf install -y cmake gcc m4 git --setopt=install_weak_deps=False \
2321
&& curl -sSf -L https://github.com/Kong/kong-pongo/archive/refs/heads/master.tar.gz | tar xfvz - -C / --strip-components 3 kong-pongo-master/kong-versions/"${PONGO_KONG_VERSION}" \
2422
&& echo 'database = off' >> /kong/spec/kong_tests.conf \
@@ -31,14 +29,18 @@ RUN dnf install -y cmake gcc m4 git --setopt=install_weak_deps=False \
3129
&& cd /tmp/EmmyLuaDebugger-${EMMY_LUA_DEBUGGER_VERSION}/build \
3230
&& cmake .. -DCMAKE_BUILD_TYPE=Release -DEMMY_CORE_VERSION=${EMMY_LUA_DEBUGGER_VERSION} \
3331
&& cmake --build . --config Release \
34-
# Install package dependencies defined in the plugin rockspec file.
35-
&& luarocks build /kong-plugin-${KONG_PLUGIN_NAME}-${KONG_PLUGIN_VERSION}-${KONG_PLUGIN_REVISION}.rockspec --only-deps OPENSSL_DIR=/usr/local/kong CRYPTO_DIR=/usr/local/kong \
36-
# Install package dependencies used for unit and integration tests.
37-
&& luarocks build /kong-plugin-testing-0.1.0-0.rockspec --only-deps OPENSSL_DIR=/usr/local/kong CRYPTO_DIR=/usr/local/kong \
3832
&& unzip /tmp/stylua-linux-x86_64.zip -d /usr/local/bin \
3933
&& cp /tmp/EmmyLuaDebugger-${EMMY_LUA_DEBUGGER_VERSION}/build/emmy_core/emmy_core.so /usr/local/lib/lua/5.1 \
4034
&& rm -rf /var/tmp/*
4135

36+
COPY _build/images/kong-plugin-testing-0.1.0-0.rockspec /kong-plugin-testing-0.1.0-0.rockspec
37+
# Install package dependencies used for unit and integration tests.
38+
RUN luarocks build /kong-plugin-testing-0.1.0-0.rockspec --only-deps OPENSSL_DIR=/usr/local/kong CRYPTO_DIR=/usr/local/kong
39+
40+
COPY kong-plugin-${KONG_PLUGIN_NAME}-${KONG_PLUGIN_VERSION}-${KONG_PLUGIN_REVISION}.rockspec /kong-plugin-${KONG_PLUGIN_NAME}-${KONG_PLUGIN_VERSION}-${KONG_PLUGIN_REVISION}.rockspec
41+
# Install package dependencies defined in the plugin rockspec file.
42+
RUN luarocks build /kong-plugin-${KONG_PLUGIN_NAME}-${KONG_PLUGIN_VERSION}-${KONG_PLUGIN_REVISION}.rockspec --only-deps OPENSSL_DIR=/usr/local/kong CRYPTO_DIR=/usr/local/kong
43+
4244
FROM ${KONG_IMAGE_NAME}:${KONG_IMAGE_TAG}
4345

4446
ENV LUA_PATH="/kong-plugin/?.lua;/kong-plugin/?/init.lua;;"

kong-plugin.rockspec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ version = package_version .. "-" .. rockspec_revision
1010

1111
source = {
1212
url = "git+https://github.com/dol/kong-authz-openfga.git",
13+
tag = "v" .. version,
1314
}
1415

1516
description = {
1617
summary = "Kong plugin for kong-authz-openfga integration",
1718
homepage = "https://github.com/dol/kong-authz-openfga",
18-
license = "proprietary",
19+
license = "MIT",
1920
}
2021

2122
dependencies = {
23+
"lua ~> 5.1",
2224
}
2325

2426
build = {

0 commit comments

Comments
 (0)