Skip to content

Merge pull request #1232 from devmocrea/feat/1177-1178-1179-1180-secu… #930

Merge pull request #1232 from devmocrea/feat/1177-1178-1179-1180-secu…

Merge pull request #1232 from devmocrea/feat/1177-1178-1179-1180-secu… #930

name: Backend Integration Tests
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
prometheus-alerts-check:
name: Validate Prometheus Alerts
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install promtool
run: |
PROM_VERSION="2.51.0"
curl -sS -L "https://github.com/prometheus/prometheus/releases/download/v${PROM_VERSION}/prometheus-${PROM_VERSION}.linux-amd64.tar.gz" | tar xz
sudo mv "prometheus-${PROM_VERSION}.linux-amd64/promtool" /usr/local/bin/
- name: Validate Prometheus Alert Rules
run: |
promtool check rules monitoring/prometheus-alerts.yml
promtool check rules monitoring/alerts.yml
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: .
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm --workspace=backend run test:unit
continue-on-error: true
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: unit-coverage
path: backend/coverage/
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: .
services:
postgres:
image: timescale/timescaledb:latest-pg15
env:
POSTGRES_DB: bridge_watch_test
POSTGRES_USER: bridge_watch
POSTGRES_PASSWORD: bridge_watch_dev
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis:7-alpine
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- name: Validate Prometheus Alert Rules
run: docker run --rm --entrypoint promtool -v ${{ github.workspace }}:/work prom/prometheus:v2.54.1 check rules /work/monitoring/prometheus-alerts.yml
- name: Run integration tests
run: npm --workspace=backend run test:integration
continue-on-error: true
env:
NODE_ENV: test
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
POSTGRES_DB: bridge_watch_test
POSTGRES_USER: bridge_watch
POSTGRES_PASSWORD: bridge_watch_dev
REDIS_HOST: localhost
REDIS_PORT: 6379
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: integration-coverage
path: backend/coverage/