Skip to content

CI

CI #101

Workflow file for this run

name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
name: Test and Lint
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup 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: Run linter
run: npm run lint
- name: Check code formatting
run: npm run format:check
- name: Start server in background
run: |
npm start &
echo $! > server.pid
sleep 5
env:
DRUGBANK_API_KEY: test_key
- name: Run tests
run: npm test
env:
BASE_URL: http://localhost:3000
- name: Stop server
if: always()
run: |
if [ -f server.pid ]; then
kill $(cat server.pid) || true
fi
- name: Run security audit
run: npm audit --production --audit-level=moderate
continue-on-error: true
docker:
name: Docker Build
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build Docker image
run: docker build -t pharmaintel-api:test .
- name: Test Docker image
run: |
docker run -d -p 3000:3000 -e DRUGBANK_API_KEY=test_key --name test-container pharmaintel-api:test
sleep 5
curl -f http://localhost:3000/health || exit 1
docker stop test-container
docker rm test-container