Skip to content

Commit

Permalink
chore(workflows) install lua-resty-events in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
locao committed Jun 8, 2022
1 parent 55c5d9e commit 3009fc6
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 33 deletions.
102 changes: 82 additions & 20 deletions .github/workflows/build_and_test_with_resty_events.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and test using lua-resty-events
name: Build and test

on: [push, pull_request]

Expand All @@ -21,37 +21,94 @@ jobs:
- name: Set environment variables
env:
OPENRESTY_VER: ${{ matrix.openresty-version }}
RESTY_EVENTS_VER: 0.1.0
LUAROCKS_VER: 3.9.0
OPENSSL_VER: 1.1.1o
PCRE_VER: 8.45
run: |
echo "/usr/local/openresty/nginx/sbin" >> $GITHUB_PATH
echo "INSTALL_ROOT=$HOME/install-root" >> $GITHUB_ENV
echo "DOWNLOAD_ROOT=$HOME/download-root" >> $GITHUB_ENV
echo "OPENRESTY=$OPENRESTY_VER" >> $GITHUB_ENV
echo "LUAROCKS=$LUAROCKS_VER" >> $GITHUB_ENV
echo "OPENSSL=$OPENSSL_VER" >> $GITHUB_ENV
echo "PCRE=$PCRE_VER" >> $GITHUB_ENV
echo "RESTY_EVENTS=$RESTY_EVENTS_VER" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$HOME/install-root/openssl/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
- name: Checkout lua-resty-healthcheck
uses: actions/checkout@v3

- name: Lookup build cache
uses: actions/cache@v2
uses: actions/cache@v3
id: cache-deps
with:
path: |
~/perl5
key: ${{ runner.os }}-${{ hashFiles('.github/workflows/build_and_test_with_resty_events.yml') }}
path: ${{ env.GITHUB_WORKSPACE }}/
key: ${{ runner.os }}-${{ hashFiles('**/.github/workflows/build_and_test_with_resty_events.yml') }}-${{ matrix.openresty-version }}

- name: Install OpenResty ${{ matrix.openresty-version }}
env:
OPENRESTY_VER: ${{ matrix.openresty-version }}
- name: Add to Path
if: steps.cache-deps.outputs.cache-hit != 'true'
run: echo "$INSTALL_ROOT/openssl/bin:$INSTALL_ROOT/openresty/nginx/sbin:$INSTALL_ROOT/openresty/bin:$INSTALL_ROOT/luarocks/bin:$INSTALL_ROOT/bin" >> $GITHUB_PATH

- name: Build and install OpenSSL
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
curl -sSLO https://www.openssl.org/source/openssl-$OPENSSL.tar.gz
tar -xzf openssl-$OPENSSL.tar.gz
cd openssl-$OPENSSL
./config -g shared -DPURIFY no-threads --prefix=$INSTALL_ROOT --openssldir=$INSTALL_ROOT no-unit-test
make
make install_sw
- name: Checkout lua-resty-events
uses: actions/checkout@v3
if: steps.cache-deps.outputs.cache-hit != 'true'
with:
repository: Kong/lua-resty-events
ref: refs/tags/0.1.0
path: lua-resty-events

- name: Build and install OpenResty
if: steps.cache-deps.outputs.cache-hit != true
run: |
sudo apt-get -y install --no-install-recommends wget gnupg ca-certificates
wget -O - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
echo "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/openresty.list
sudo apt-get update
sudo apt-get -y install openresty=$OPENRESTY_VER-1~focal1
curl -sSLO https://openresty.org/download/openresty-$OPENRESTY.tar.gz
tar -xzf openresty-$OPENRESTY.tar.gz
cd openresty-$OPENRESTY
./configure \
--prefix=$INSTALL_ROOT \
--with-cc-opt='-I$INSTALL_ROOT/include' \
--with-ld-opt='-L$INSTALL_ROOT/lib -Wl,-rpath,$INSTALL_ROOT/lib' \
--with-pcre-jit \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_v2_module \
--without-http_encrypted_session_module \
--with-stream_realip_module \
--with-stream_ssl_preread_module \
--add-module=../lua-resty-events \
--with-pcre
make
make install
make install LUA_LIBDIR=$INSTALL_ROOT/lualib
- name: Install LuaRocks
if: steps.cache-deps.outputs.cache-hit != 'true'
run: sudo apt-get install -y luarocks
run: |
curl -sSLO https://luarocks.org/releases/luarocks-$LUAROCKS.tar.gz
tar -xzf luarocks-$LUAROCKS.tar.gz
cd luarocks-$LUAROCKS
./configure \
--prefix=$INSTALL_ROOT \
--lua-suffix=jit \
--with-lua=$INSTALL_ROOT/luajit \
--with-lua-include=$INSTALL_ROOT/luajit/include/luajit-2.1
make build
make install
- name: Install manual dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
sudo luarocks install luacheck
sudo luarocks install lua-resty-events 0.1.0
luarocks install luacheck
- name: Install Test::NGINX
if: steps.cache-deps.outputs.cache-hit != 'true'
Expand All @@ -60,13 +117,18 @@ jobs:
cpanm --notest --local-lib=$HOME/perl5 local::lib && eval $(perl -I $HOME/perl5/lib/perl5/ -Mlocal::lib)
cpanm --notest Test::Nginx
- name: Checkout lua-resty-healthcheck
uses: actions/checkout@v2
- name: Install lua-resty-events
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
cd lua-resty-events
OPENRESTY_PREFIX=$INSTALL_ROOT/openresty PREFIX=$INSTALL_ROOT make install
- name: Install lua-resty-healthcheck
run: sudo luarocks make
run: luarocks make

- name: Run tests
env:
PATH: ${{ env.INSTALL_ROOT }}/openssl/bin:${{ env.INSTALL_ROOT }}/openresty/nginx/sbin:${{ env.INSTALL_ROOT }}/openresty/bin:${{ env.INSTALL_ROOT }}/luarocks/bin:${{ env.INSTALL_ROOT }}/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
run: |
eval `luarocks path`
eval $(perl -I $HOME/perl5/lib/perl5/ -Mlocal::lib)
Expand Down
17 changes: 4 additions & 13 deletions .github/workflows/build_and_test_with_worker_events.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and test using lua-resty-worker-events
name: Build and test

on: [push, pull_request]

Expand All @@ -24,18 +24,12 @@ jobs:
run: |
echo "/usr/local/openresty/nginx/sbin" >> $GITHUB_PATH
- name: Lookup build cache
uses: actions/cache@v2
id: cache-deps
with:
path: |
~/perl5
key: ${{ runner.os }}-${{ hashFiles('.github/workflows/build_and_test_with_worker_events.yml') }}
- name: Checkout lua-resty-healthcheck
uses: actions/checkout@v3

- name: Install OpenResty ${{ matrix.openresty-version }}
env:
OPENRESTY_VER: ${{ matrix.openresty-version }}
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
sudo apt-get -y install --no-install-recommends wget gnupg ca-certificates
wget -O - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
Expand All @@ -44,24 +38,21 @@ jobs:
sudo apt-get -y install openresty=$OPENRESTY_VER-1~focal1
- name: Install LuaRocks
if: steps.cache-deps.outputs.cache-hit != 'true'
run: sudo apt-get install -y luarocks

- name: Install manual dependencies
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
sudo luarocks install luacheck
sudo luarocks install lua-resty-worker-events 1.0.0
- name: Install Test::NGINX
if: steps.cache-deps.outputs.cache-hit != 'true'
run: |
sudo apt-get install cpanminus
cpanm --notest --local-lib=$HOME/perl5 local::lib && eval $(perl -I $HOME/perl5/lib/perl5/ -Mlocal::lib)
cpanm --notest Test::Nginx
- name: Checkout lua-resty-healthcheck
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install lua-resty-healthcheck
run: sudo luarocks make
Expand Down

0 comments on commit 3009fc6

Please sign in to comment.