Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Tests
on:
pull_request:
push:
branches:
- master

env:
KONG_VERSION: master
Expand All @@ -16,6 +18,8 @@ jobs:
build:
name: Build dependencies
runs-on: ubuntu-22.04
permissions:
contents: write # required to create branch

steps:
- name: Checkout source code
Expand All @@ -31,13 +35,9 @@ jobs:
- name: Set the LUA_KONG_NGINX_MODULE in kong/.requirements
run: |
cd kong
branch=""

if [ ${{ github.event_name }} == 'pull_request' ]; then
branch=${GITHUB_HEAD_REF}
else
branch=${GITHUB_REF}
fi
# always use the commit ID, even if it's a PR merge; we will push the commit to temporary branch
# so that we can cache by commit ID instead of literal PR branch name
branch=${GITHUB_REF}

branch=$(echo "$branch" | sed 's/\//\\\//g')
sed -i "s/LUA_KONG_NGINX_MODULE=.\+/LUA_KONG_NGINX_MODULE=${branch}/" .requirements
Expand All @@ -51,6 +51,12 @@ jobs:
${{ env.BUILD_ROOT }}
key: ${{ hashFiles('src/**', 'lualib/**', '.github/workflows/tests.yml', 'kong/.requirements') }}

- name: Push PR merge to a temporary branch
# Push the temporary commit to a branch so that we can reference in build kong
if: github.event_name == 'pull_request' && steps.cache-deps.outputs.cache-hit != 'true'
run: |
git push https://oauth2:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git HEAD:refs/heads/${{ github.head_ref }}-merge

- name: Install packages
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
Expand All @@ -72,6 +78,11 @@ jobs:
ldd $(which nginx)
luarocks

- name: Delete temporary branch
if: always() && github.event_name == 'pull_request' && steps.cache-deps.outputs.cache-hit != 'true'
run: |
git push https://oauth2:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git --delete refs/heads/${{ github.head_ref }}-merge

test:
name: Test
runs-on: ubuntu-22.04
Expand Down