Skip to content

CI for Nodejs-c-io_uring_example #24

CI for Nodejs-c-io_uring_example

CI for Nodejs-c-io_uring_example #24

Workflow file for this run

name: CI
on:
pull_request:
push:
branches:
- master
jobs:
linux:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up Dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
ca-certificates \
git \
liburing-dev \
cmake \
curl
- name: Clone and Build MetaCall
run: |
git clone --branch v0.8.7 https://github.com/metacall/core
cd core
./tools/metacall-environment.sh release base nodejs c
mkdir build && cd build
../tools/metacall-configure.sh release nodejs c ports install
../tools/metacall-build.sh release nodejs c ports install
cd ../..
rm -rf core
- name: Set path & Run MetaCall Example
run: |
export LOADER_LIBRARY_PATH="/usr/local/lib"
export LOADER_SCRIPT_PATH="$(pwd)/scripts" # path of the scripts
node -e "console.log(require('util').parseArgs({ args: ['a'] }))"
nohup metacallcli index.js & # running the server in the background
echo $! > metacall_pid.txt # Save the PID of the process to a file
- name: Wait for server to be ready
run: |
for i in {1..10}; do
if curl -s http://localhost:8000 > /dev/null; then
echo "Server is up!"
exit 0
fi
echo "Waiting for server..."
sleep 3
done
echo "Server did not start in time."
exit 1
- name: Test server response
run: |
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8000)
if [ "$RESPONSE" -eq 200 ]; then
echo "Server responded with HTTP 200 OK."
else
echo "Server did not respond with HTTP 200. Response code: $RESPONSE"
exit 1
fi
- name: Kill MetaCall process (free port 8000)
run: |
if [ -f metacall_pid.txt ]; then
PID=$(cat metacall_pid.txt)
echo "Killing process with PID $PID"
kill $PID
rm metacall_pid.txt # Remove the PID file after killing the process
else
echo "PID file not found. No process to kill."
fi
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Test Docker Build
run: |
docker build -t metacall/nodejs-c-liburing-example .
docker run --rm -p 8000:8000 --name metacall_test -d metacall/nodejs-c-liburing-example
# TODO: This works on my pc.. but it seems not to work in the CI, we should review it and implement it
# RETRIES=0
# while true; do
# HTTP_CODE="$(wget --server-response -q "http://localhost:8000" 2>&1 | grep "HTTP/" | awk '{print $2}')"
# if [[ "$HTTP_CODE" -eq "200" ]]; then
# echo "Service is ready (HTTP 200)."
# exit 0
# elif [[ "$RETRIES" -ge "20" ]]; then
# echo "Max retries reached. Service not ready."
# exit 1
# fi
# RETRIES=$((RETRIES + 1))
# sleep 5
# done