Update GHA build.yml to use matrices of runners

* Add an Ubuntu matrix with 18.04, 20.04, 22.04, 23.04
* Make some steps conditional based on the environment
* Add a macOS matrix with macOS-11 and macOS-12
* Use Homebrew and a local Redis service started by `brew` on the macOS
  runners
master
Nicolas Favre-Felix 11 months ago
parent ea01d687b5
commit 90773ca519
No known key found for this signature in database
GPG Key ID: C04E7AA8B6F73372

@ -1,27 +1,63 @@
name: Build name: Build and test (OS matrix)
# trigger the workflow on push or pull requests # trigger the workflow on push or pull requests
on: [push, pull_request, workflow_dispatch] # on: [push, pull_request, workflow_dispatch]
on: [workflow_dispatch]
jobs: jobs:
build-and-run-tests:
runs-on: ubuntu-20.04 # this is a GitHub Runner, hosting the execution build-and-test-ubuntu:
container: ubuntu:20.04 # but this is a Docker Hub container, in which everything runs strategy:
fail-fast: false # don't cancel other jobs in the matrix if one fails
matrix:
include:
- runner: ubuntu-20.04
container: ubuntu:18.04
os_name: ubuntu-18.04
- runner: ubuntu-20.04
container: ubuntu:20.04
os_name: ubuntu-20.04
- runner: ubuntu-20.04
container: ubuntu:22.04
os_name: ubuntu-22.04
- runner: ubuntu-20.04
container: ubuntu:23.04
os_name: ubuntu-23.04
runs-on: ${{ matrix.runner }}
services: services:
redis: redis:
image: redis:7.0.12-alpine # Docker Hub image used as a sidecar image: redis:7.0.12-alpine # Docker Hub image used as a sidecar
# run each job in the container specified (ignored for macOS runners that don't use containers)
container:
image: ${{ matrix.container }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Fetch package lists
run: apt-get -y update
- name: Install dependencies - name: Install dependencies
run: | run: |
apt-get -y update
DEBIAN_FRONTEND=noninteractive apt-get -y --allow-unauthenticated --allow-downgrades --allow-remove-essential --allow-change-held-packages \ DEBIAN_FRONTEND=noninteractive apt-get -y --allow-unauthenticated --allow-downgrades --allow-remove-essential --allow-change-held-packages \
install make gcc libevent-dev libmsgpack-dev python3.8 python3-pip curl nodejs install make gcc libevent-dev libmsgpack-dev curl nodejs python3 python3-pip
- name: Fix pip3 on Ubuntu 23.04
if: matrix.os_name == 'ubuntu-23.04'
run: rm -f /usr/lib/python$(python3 --version | cut -d ' ' -f 2 | cut -d '.' -f 1,2)/EXTERNALLY-MANAGED
- name: Update Python3 on Ubuntu 18.04
if: matrix.os_name == 'ubuntu-18.04'
run: |
DEBIAN_FRONTEND=noninteractive apt-get -y install python3.8
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
- name: Build - name: Build
run: make run: make
- name: Run Webdis and test - name: Run Webdis and test
run: | run: |
./webdis .github/workflows/webdis-ci.json ./webdis .github/workflows/webdis-ci.json
@ -30,8 +66,54 @@ jobs:
./tests/curl-tests.sh ./tests/curl-tests.sh
pip3 --no-cache-dir install -r tests/requirements.txt pip3 --no-cache-dir install -r tests/requirements.txt
./tests/ws-tests.py ./tests/ws-tests.py
- name: Archive logs
uses: actions/upload-artifact@v3
with:
name: webdis-${{ matrix.os_name }}.log
path: webdis.log
build-and-test-macos:
strategy:
fail-fast: false
matrix:
include:
- runner: macos-11
os_name: macos-11
- runner: macos-12
os_name: macos-12
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
brew install libevent msgpack-c curl node python@3.11 redis
brew link --overwrite python@3.11
pip3 install --upgrade pip
- name: Set up redis hostname
run: echo "127.0.0.1 redis" | sudo tee -a /etc/hosts
- name: Build
run: make
- name: Run Webdis and test
run: |
brew services start redis
./webdis .github/workflows/webdis-ci.json
sleep 2
./tests/basic.py
./tests/curl-tests.sh
pip3 --no-cache-dir install -r tests/requirements.txt
./tests/ws-tests.py
- name: Archive logs - name: Archive logs
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: webdis.log name: webdis-${{ matrix.os_name }}.log
path: webdis.log path: webdis.log

@ -5,7 +5,12 @@ set -e
# GitHub issue #194 (connection: close + HTTP 100) # GitHub issue #194 (connection: close + HTTP 100)
function test_large_put_upload() { function test_large_put_upload() {
key=$(cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) echo 'Testing large PUT upload: generating the key...'
if [[ $(command -v uuidgen) ]]; then # macOS
key=$(uuidgen)
else
key=$(cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
fi
echo -n 'Sending a PUT request with a large payload... ' echo -n 'Sending a PUT request with a large payload... '
put_output=$(printf 'A%.0s' $(seq 1 10000) | curl -s -H 'Connection: close' -XPUT "http://127.0.0.1:7379/SET/${key}" -d @-) put_output=$(printf 'A%.0s' $(seq 1 10000) | curl -s -H 'Connection: close' -XPUT "http://127.0.0.1:7379/SET/${key}" -d @-)
if [[ ${PIPESTATUS[1]} -ne 0 || "${put_output}" != '{"SET":[true,"OK"]}' ]]; then if [[ ${PIPESTATUS[1]} -ne 0 || "${put_output}" != '{"SET":[true,"OK"]}' ]]; then

Loading…
Cancel
Save