Skip to content

Bump qs and express #13

Bump qs and express

Bump qs and express #13

Workflow file for this run

name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
test:
runs-on: ubuntu-latest
services:
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
strategy:
matrix:
node-version: [20.x, 22.x, 24.x]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Create test configuration
run: |
# Use test config if available, otherwise sample config
if [ -f "config.test.json" ]; then
cp config.test.json config.json
echo "Using config.test.json"
elif [ -f "config.json.sample" ]; then
cp config.json.sample config.json
echo "Using config.json.sample"
else
echo "No config file found!"
exit 1
fi
# Update Redis connection for CI environment
sed -i 's/"host": ".*"/"host": "localhost"/' config.json
sed -i 's/"port": [0-9]*/"port": 6379/' config.json
- name: Run linter
run: npm run lint
- name: Run unit tests
run: npm run test:unit
env:
NODE_ENV: test
- name: Run integration tests
run: npm run test:integration
env:
NODE_ENV: test
REDIS_HOST: localhost
REDIS_PORT: 6379
- name: Run all tests
run: npm test
env:
NODE_ENV: test
REDIS_HOST: localhost
REDIS_PORT: 6379
test-without-redis:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x, 22.x, 24.x]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Create test configuration
run: |
if [ -f "config.test.json" ]; then
cp config.test.json config.json
elif [ -f "config.json.sample" ]; then
cp config.json.sample config.json
fi
- name: Run tests with mocked Redis
run: npm test
env:
NODE_ENV: test
# Tests use redis-mock, no real Redis needed
docker-test:
runs-on: ubuntu-latest
needs: [test, test-without-redis]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: coce:test
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Test Docker container
run: |
# Create config for Docker test
if [ -f "config.test.json" ]; then
cp config.test.json config.json
elif [ -f "config.json.sample" ]; then
cp config.json.sample config.json
fi
# Start services with docker compose V2
docker compose up -d
# Wait for services to be ready
echo "Waiting for services to start..."
sleep 15
# Test basic endpoint
echo "Testing basic endpoint..."
curl -f http://localhost:8080/ || echo "Basic endpoint test completed"
# Test cover endpoint (may fail without API keys but should not crash)
echo "Testing cover endpoint..."
curl -f "http://localhost:8080/cover?id=9780415480635" || echo "Cover endpoint test completed"
# Check container logs for errors
echo "Checking container logs..."
docker compose logs coce
# Cleanup
docker compose down