From 970190e37835f2f8b99537f7119f4f14cddb47b4 Mon Sep 17 00:00:00 2001 From: Kleis Auke Wolthuizen Date: Sun, 19 Jan 2025 11:12:41 +0100 Subject: [PATCH] CI: Cleanup configuration --- .github/workflows/ci.yml | 37 ++++++++++++++++++++++++++++++------- ci/build-rate-limiter.sh | 14 -------------- ci/install-nginx.sh | 22 ---------------------- 3 files changed, 30 insertions(+), 43 deletions(-) delete mode 100755 ci/build-rate-limiter.sh delete mode 100755 ci/install-nginx.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9424679..4312e4d 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-24.04 nginx-version: 1.27.1 + steps: - - uses: actions/checkout@v4 + - name: Checkout repository + uses: actions/checkout@v4 + - name: Install dependencies run: | # for Test::Nginx @@ -18,17 +27,29 @@ 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 @@ -36,7 +57,9 @@ jobs: # 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 + - name: Prepare environment run: echo "$HOME/nginx/sbin" >> $GITHUB_PATH + - name: Run integration tests run: prove -r t 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