Skip to content

feat: Add Sentry queues monitoring #822

feat: Add Sentry queues monitoring

feat: Add Sentry queues monitoring #822

name: Lint, Test and Build
on:
push:
branches: [main]
pull_request:
# enable manual triggers
workflow_dispatch:
jobs:
prepare-dependencies:
name: Prepare local deps
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- id: prepare-env
uses: ./.github/actions/prepare-local-env
- name: Install dependencies
if: steps.prepare-env.outputs.cache-hit != 'true'
run: npm ci
detect-changes:
name: Detect code changes
runs-on: ubuntu-latest
outputs:
frontend-only: ${{ steps.detect.outputs.frontend_only }}
backend-only: ${{ steps.detect.outputs.backend_only }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for file changes
- id: detect
uses: ./.github/actions/detect-changes
frontend:
name: Frontend tasks
needs: [prepare-dependencies, detect-changes]
runs-on: ubuntu-latest
strategy:
matrix:
task: [lint, test, build, knip]
steps:
- name: Skip – no frontend changes
if: needs.detect-changes.outputs.backend-only == 'true'
run: echo "No frontend changes detected. Skipping."
- uses: actions/checkout@v4
if: needs.detect-changes.outputs.backend-only != 'true'
- uses: ./.github/actions/prepare-local-env
if: needs.detect-changes.outputs.backend-only != 'true'
- name: Run ${{ matrix.task }}
if: needs.detect-changes.outputs.backend-only != 'true'
run: npm run ${{ matrix.task }} -w packages/frontend
frontend-docker-build:
name: Build frontend Docker image
runs-on: ubuntu-latest
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
- name: Checkout repository
uses: actions/checkout@v4
- id: frontend-docker-build
uses: ./.github/actions/frontend-docker-build
- name: Image digest
run: echo ${{ steps.frontend-docker-build.outputs.docker-build-digest }}
backend:
name: Backend tasks
needs: [prepare-dependencies, detect-changes]
runs-on: ubuntu-latest
strategy:
matrix:
task: [lint, test, knip]
steps:
- name: Skip – no backend changes
if: needs.detect-changes.outputs.frontend-only == 'true'
run: echo "No backend changes detected. Skipping."
- uses: actions/checkout@v4
if: needs.detect-changes.outputs.frontend-only != 'true'
- uses: ./.github/actions/prepare-local-env
if: needs.detect-changes.outputs.frontend-only != 'true'
- name: Make backend env file
if: needs.detect-changes.outputs.frontend-only != 'true'
uses: SpicyPizza/create-envfile@v2
with:
envkey_APPLICATION_HOST: 127.0.0.1
envkey_APPLICATION_PORT: 8081
envkey_APPLICATION_JWT_SECRET: test-jwt
# docker/test/backend/docker-compose.yml DB's service name
envkey_APPLICATION_DB_HOST: test-db
envkey_APPLICATION_DB_USERNAME: test
envkey_APPLICATION_DB_PASSWORD: test
envkey_APPLICATION_DB_DATABASE: budget-tracker_test
envkey_APPLICATION_DB_PORT: 5432
envkey_APPLICATION_DB_DIALECT: postgres
# docker/test/backend/docker-compose.yml redis' service name
envkey_APPLICATION_REDIS_HOST: test-redis
# GitHub runner has 4 CPU
# https://docs.github.com/en/actions/reference/runners/github-hosted-runners#standard-github-hosted-runners-for-public-repositories
envkey_JEST_WORKERS_AMOUNT: 4
envkey_SHOW_LOGS_IN_TESTS: false
envkey_POLYGON_API_KEY: test
envkey_ALPHA_VANTAGE_API_KEY: test
envkey_API_LAYER_API_KEYS: test,test
envkey_FMP_API_KEY: test
envkey_ADMIN_USERS: test1
file_name: .env.test
fail_on_empty: true # fail if any env variable is empty
- name: Run ${{ matrix.task }}
if: needs.detect-changes.outputs.frontend-only != 'true' && matrix.task != 'test'
run: npm run ${{ matrix.task }} -w packages/backend
- name: Run ${{ matrix.task }} (with retry)
if: needs.detect-changes.outputs.frontend-only != 'true' && matrix.task == 'test'
run: |
for attempt in 1 2 3; do
echo "=== Attempt $attempt of 3 ==="
if npm run test -w packages/backend; then
exit 0
fi
if [ $attempt -lt 3 ]; then
echo "Test failed. Retrying..."
fi
done
echo "Tests failed after 3 attempts"
exit 1
backend-docker-build:
name: Build backend Docker image
runs-on: ubuntu-latest
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
- name: Checkout repository
uses: actions/checkout@v4
- id: backend-docker-build
uses: ./.github/actions/backend-docker-build
- name: Image digest
run: echo ${{ steps.backend-docker-build.outputs.docker-build-digest }}