diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04651e2..ff1ffe8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,16 +1,25 @@ name: CI + on: [ push, pull_request, workflow_dispatch ] + +permissions: {} + jobs: CI: runs-on: ${{ matrix.os }} + permissions: + contents: read strategy: fail-fast: true matrix: include: - - os: ubuntu-22.04 - nginx-version: 1.25.3 + - os: ubuntu-24.04 + nginx-version: 1.27.3 + steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install dependencies run: | # for Test::Nginx @@ -18,25 +27,39 @@ jobs: echo "deb [signed-by=/usr/share/keyrings/openresty.gpg] https://openresty.org/package/ubuntu $(lsb_release -sc) main" | \ sudo tee /etc/apt/sources.list.d/openresty.list > /dev/null sudo apt-get update - sudo apt-get install libtest-nginx-perl redis-server + sudo apt-get install --no-install-recommends libtest-nginx-perl redis-server + - name: Install nginx env: NGINX_VERSION: ${{ matrix.nginx-version }} - run: ci/install-nginx.sh --add-module=$GITHUB_WORKSPACE/ - - name: Build Redis rate limiter module - run: ci/build-rate-limiter.sh + working-directory: ${{ runner.temp }} + run: | + mkdir nginx + curl -Ls https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz | \ + tar xzC nginx --strip-components=1 + cd nginx + ./configure --prefix="$HOME/nginx" --add-module=${{ github.workspace }} + make -j$(nproc) + make install + - name: Install Redis rate limiter module + working-directory: ${{ runner.temp }} run: | - sudo mkdir -p /usr/lib/redis/modules - sudo mv rate-limiter/ratelimit.so /usr/lib/redis/modules/ + git clone https://github.com/onsigntv/redis-rate-limiter.git + cd redis-rate-limiter + make -j$(nproc) USE_MONOTONIC_CLOCK=1 + sudo install -D -t /usr/lib/redis/modules ratelimit.so + - name: Load Redis rate limiter module run: | # Redis < 7 - redis-cli MODULE LOAD /usr/lib/redis/modules/ratelimit.so + # redis-cli MODULE LOAD /usr/lib/redis/modules/ratelimit.so # Redis >= 7 (due to `enable-module-command no` restriction) - # echo "loadmodule /usr/lib/redis/modules/ratelimit.so" | sudo tee -a /etc/redis/redis.conf - # sudo service redis-server restart + echo "loadmodule /usr/lib/redis/modules/ratelimit.so" | sudo tee -a /etc/redis/redis.conf + sudo service redis-server restart + - name: Prepare environment run: echo "$HOME/nginx/sbin" >> $GITHUB_PATH + - name: Run integration tests run: prove -r t diff --git a/README.md b/README.md index 29988e2..1a8d25d 100644 --- a/README.md +++ b/README.md @@ -66,13 +66,13 @@ location = /quota { You can install this module manually by recompiling the standard Nginx core as follows: -1. Grab the nginx source code from [nginx.org](http://nginx.org) (this module is tested on version 1.25.3). +1. Grab the nginx source code from [nginx.org](https://nginx.org) (this module is tested on version 1.27.3). 2. Clone this repository into a newly created directory (for e.g. `./rate-limit-nginx-module`) 3. Build the nginx source with this module: ```bash -wget https://nginx.org/download/nginx-1.25.3.tar.gz -tar -xzvf nginx-1.25.3.tar.gz -cd nginx-1.25.3/ +wget https://nginx.org/download/nginx-1.27.3.tar.gz +tar -xzvf nginx-1.27.3.tar.gz +cd nginx-1.27.3/ git clone https://github.com/weserv/rate-limit-nginx-module rate-limit-nginx-module diff --git a/ci/build-rate-limiter.sh b/ci/build-rate-limiter.sh deleted file mode 100755 index 44f5ccf..0000000 --- a/ci/build-rate-limiter.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash - -# Exit immediately if a command exits with a non-zero status -set -e - -# Define variables -branch=master -rate_limiter_repo=https://github.com/onsigntv/redis-rate-limiter.git - -echo "Building redis-rate-limiter from source" - -git clone -b $branch --single-branch $rate_limiter_repo rate-limiter -cd rate-limiter -make -j$(nproc) USE_MONOTONIC_CLOCK=1 diff --git a/ci/install-nginx.sh b/ci/install-nginx.sh deleted file mode 100755 index 7a74f4d..0000000 --- a/ci/install-nginx.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -# Exit immediately if a command exits with a non-zero status -set -e - -# Define variables -version=$NGINX_VERSION -nginx_tarball=https://nginx.org/download/nginx-$version.tar.gz - -# Make sure the nginx folder exist -mkdir -p "$HOME/nginx" - -echo "Installing nginx $version" - -curl -Ls $nginx_tarball | tar xz -cd nginx-$version -./configure --prefix="$HOME/nginx" "$@" -make -j$(nproc) && make install - -# Clean-up build directory -cd ../ -rm -rf nginx-$version