Skip to content

Commit

Permalink
build: Add smoke test to CI test action and added new release action
Browse files Browse the repository at this point in the history
  • Loading branch information
dol committed Jan 6, 2025
1 parent ec4a44c commit dbe311e
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 17 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Release Rock

on:
push:
tags:
- 'v*' # Trigger for version tags

jobs:
build_and_release:
runs-on: ubuntu-24.04
steps:
- name: Check out code
uses: actions/checkout@main
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up Lua and Luarocks
uses: leafo/gh-actions-lua@v10
with:
luaVersion: '5.4.7'
- uses: leafo/gh-actions-luarocks@v4
with:
luarocksVersion: "3.11.1"
- name: Build rockspec files
run: |
make pack # Generates *.rock and *.scm.rock
git config user.name github-actions
git config user.email [email protected]
git add *.rockspec *.rock
git commit -m "Add rockspec files for release ${GITHUB_REF##*/}"
git push
- name: Publish to LuaRocks
env:
LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }}
run: |
luarocks upload --temp-key="${LUAROCKS_API_KEY}" *.rock *.src.rock
22 changes: 22 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,25 @@ jobs:
artifact-name: code-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
update-comment: true
smoke-tests:
timeout-minutes: ${{ fromJSON(vars.GHA_DEFAULT_TIMEOUT || 10) }}
name: Smoke Tests

runs-on: ubuntu-24.04

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Run the smoke test server
run: |
make smoke-test-run-server DOCKER_RUN_FLAGS_TTY='-d'
- name: Wait for service to be ready
run: |
# Wait until kong is ready
timeout 60s bash -c 'until docker exec kong-plugin-kong-authz-openfga-smoke-test curl -i http://localhost:8007/status/ready; do sleep 5; done'
- name: Run smoke tests DOCKER_RUN_FLAGS_TTY=''
run: |
make smoke-test-run-test
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ CONTAINER_CI_KONG_SMOKE_TEST_BUILD = DOCKER_BUILDKIT=1 BUILDKIT_PROGRESS=$(BUILD
--build-arg KONG_IMAGE_NAME='$(KONG_IMAGE_NAME)' \
--build-arg KONG_IMAGE_TAG='$(KONG_IMAGE_TAG)' \
--build-arg KONG_PLUGIN_NAME='$(KONG_PLUGIN_NAME)' \
--build-arg KONG_PLUGIN_VERSION='$(KONG_PLUGIN_VERSION)' \
--build-arg KONG_PLUGIN_REVISION='$(KONG_PLUGIN_REVISION)' \
--build-arg KONG_PLUGIN_ROCK_FILE='$(ROCK_FILE)' \
--build-arg KONG_PLUGIN_ROCKSPEC_FILE='$(ROCKSPEC_FILE)' \
.

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

.PHONY: container-ci-kong-smoke-test
container-ci-kong-smoke-test: $(ROCK_FILE) container-network-ci
container-ci-kong-smoke-test: container-network-ci
$(CONTAINER_CI_KONG_SMOKE_TEST_BUILD)

.PHONY: container-ci-kong-smoke-test-debug
Expand Down
12 changes: 7 additions & 5 deletions _build/images/kong-smoke-test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ FROM ${KONG_IMAGE_NAME}:${KONG_IMAGE_TAG} AS builder
USER root

ARG KONG_PLUGIN_NAME
ARG KONG_PLUGIN_VERSION
ARG KONG_PLUGIN_REVISION
ARG KONG_PLUGIN_ROCK_FILE
ARG KONG_PLUGIN_ROCKSPEC_FILE

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

COPY ${KONG_PLUGIN_ROCK_FILE} /${KONG_PLUGIN_ROCK_FILE}
WORKDIR /plugin
COPY . .

RUN luarocks install /${KONG_PLUGIN_ROCK_FILE}
# Install from .rockspec
RUN find && luarocks make ${KONG_PLUGIN_ROCKSPEC_FILE}

FROM ${KONG_IMAGE_NAME}:${KONG_IMAGE_TAG}

ENV KONG_LOG_LEVEL=debug

ENV KONG_NGINX_WORKER_PROCESSES=1

# Add the Lua files (.lua)
COPY --from=builder /usr/local/share/lua/5.1 /usr/local/share/lua/5.1

Expand Down
8 changes: 8 additions & 0 deletions _build/images/kong-smoke-test/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Ignore all files
*

# Exclude the following files
!/kong/
!/README.md
!/LICENSE
!/kong-plugin-kong-authz-openfga-*.rockspec
16 changes: 9 additions & 7 deletions _build/images/kong-tooling/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ ARG PONGO_ARCHIVE
ARG STYLUA_VERSION
ARG EMMY_LUA_DEBUGGER_VERSION

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
COPY _build/images/kong-plugin-testing-0.1.0-0.rockspec /kong-plugin-testing-0.1.0-0.rockspec

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN dnf install -y cmake gcc m4 git --setopt=install_weak_deps=False \
&& 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}" \
&& echo 'database = off' >> /kong/spec/kong_tests.conf \
Expand All @@ -31,14 +29,18 @@ RUN dnf install -y cmake gcc m4 git --setopt=install_weak_deps=False \
&& cd /tmp/EmmyLuaDebugger-${EMMY_LUA_DEBUGGER_VERSION}/build \
&& cmake .. -DCMAKE_BUILD_TYPE=Release -DEMMY_CORE_VERSION=${EMMY_LUA_DEBUGGER_VERSION} \
&& cmake --build . --config Release \
# Install package dependencies defined in the plugin rockspec file.
&& 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 \
# Install package dependencies used for unit and integration tests.
&& luarocks build /kong-plugin-testing-0.1.0-0.rockspec --only-deps OPENSSL_DIR=/usr/local/kong CRYPTO_DIR=/usr/local/kong \
&& unzip /tmp/stylua-linux-x86_64.zip -d /usr/local/bin \
&& cp /tmp/EmmyLuaDebugger-${EMMY_LUA_DEBUGGER_VERSION}/build/emmy_core/emmy_core.so /usr/local/lib/lua/5.1 \
&& rm -rf /var/tmp/*

COPY _build/images/kong-plugin-testing-0.1.0-0.rockspec /kong-plugin-testing-0.1.0-0.rockspec
# Install package dependencies used for unit and integration tests.
RUN luarocks build /kong-plugin-testing-0.1.0-0.rockspec --only-deps OPENSSL_DIR=/usr/local/kong CRYPTO_DIR=/usr/local/kong

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
# Install package dependencies defined in the plugin rockspec file.
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

FROM ${KONG_IMAGE_NAME}:${KONG_IMAGE_TAG}

ENV LUA_PATH="/kong-plugin/?.lua;/kong-plugin/?/init.lua;;"
Expand Down
4 changes: 3 additions & 1 deletion kong-plugin.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ version = package_version .. "-" .. rockspec_revision

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

description = {
summary = "Kong plugin for kong-authz-openfga integration",
homepage = "https://github.com/dol/kong-authz-openfga",
license = "proprietary",
license = "MIT",
}

dependencies = {
"lua ~> 5.1",
}

build = {
Expand Down

0 comments on commit dbe311e

Please sign in to comment.