Fixed CI/CD and .env vars #39

Merged
Ichitux merged 5 commits from feat/parapharmacy-api into main 2026-07-16 16:36:24 +00:00
4 changed files with 227 additions and 19 deletions
+168 -15
View File
@@ -13,6 +13,8 @@ jobs:
outputs: outputs:
backend: ${{ steps.filter.outputs.backend }} backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }} frontend: ${{ steps.filter.outputs.frontend }}
parapharmacy-api: ${{ steps.filter.outputs.parapharmacy-api }}
pip-platform: ${{ steps.filter.outputs.pip-platform }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: dorny/paths-filter@v3 - uses: dorny/paths-filter@v3
@@ -25,6 +27,11 @@ jobs:
frontend: frontend:
- 'apps/frontend/**' - 'apps/frontend/**'
- 'packages/**' - 'packages/**'
parapharmacy-api:
- 'apps/parapharmacy-api/**'
- 'packages/**'
pip-platform:
- 'apps/pip-platform/**'
test-backend: test-backend:
name: Backend Tests name: Backend Tests
@@ -46,6 +53,73 @@ jobs:
- name: Run tests - name: Run tests
run: npm test --workspace=farma-clic-backend run: npm test --workspace=farma-clic-backend
test-parapharmacy-api:
name: Parapharmacy API Tests
needs: detect-changes
if: needs.detect-changes.outputs.parapharmacy-api == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
services:
mongodb:
image: mongo:7
ports:
- 27017:27017
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci --ignore-scripts
- name: Run Parapharmacy API Tests
run: npm test --workspace=farmafinder-parapharmacy-api
test-pip-platform:
name: Pip Platform Tests
needs: detect-changes
if: false && needs.detect-changes.outputs.pip-platform == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: pip_test
POSTGRES_USER: pip
POSTGRES_PASSWORD: pip_test
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U pip"
--health-interval=10s
--health-timeout=5s
--health-retries=5
redis:
image: redis:alpine
ports:
- 6379:6379
options: >-
--health-cmd="redis-cli ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install uv
run: pip install uv
- name: Install dependencies
working-directory: apps/pip-platform
run: uv sync --extra dev
- name: Run Tests
working-directory: apps/pip-platform
run: uv run pytest
test-frontend: test-frontend:
name: Frontend Tests name: Frontend Tests
needs: detect-changes needs: detect-changes
@@ -90,6 +164,58 @@ jobs:
git.hacecalor.net/ichitux/farmafinder-backend:latest git.hacecalor.net/ichitux/farmafinder-backend:latest
git.hacecalor.net/ichitux/farmafinder-backend:${{ gitea.sha }} git.hacecalor.net/ichitux/farmafinder-backend:${{ gitea.sha }}
build-parapharmacy-api:
name: Build Parapharmacy API
needs: [ detect-changes, test-parapharmacy-api ]
if: |
always() &&
needs.detect-changes.outputs.parapharmacy-api == 'true' &&
(needs.test-parapharmacy-api.result == 'success' || needs.test-parapharmacy-api.result == 'skipped')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Log in to Gitea registry
uses: docker/login-action@v3
with:
registry: git.hacecalor.net
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push parapharmacy-api image
uses: docker/build-push-action@v5
with:
context: .
file: ./apps/parapharmacy-api/Dockerfile
push: true
tags: |
git.hacecalor.net/ichitux/farmafinder-parapharmacy-api:latest
git.hacecalor.net/ichitux/farmafinder-parapharmacy-api:${{ gitea.sha }}
build-pip-platform:
name: Build Pip Platform
needs: [ detect-changes, test-pip-platform ]
if: |
always() &&
needs.detect-changes.outputs.pip-platform == 'true' &&
(needs.test-pip-platform.result == 'success' || needs.test-pip-platform.result == 'skipped')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Log in to Gitea registry
uses: docker/login-action@v3
with:
registry: git.hacecalor.net
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push pip-platform image
uses: docker/build-push-action@v5
with:
context: .
file: ./apps/pip-platform/Dockerfile
push: true
tags: |
git.hacecalor.net/ichitux/farmafinder-pip-platform:latest
git.hacecalor.net/ichitux/farmafinder-pip-platform:${{ gitea.sha }}
build-frontend: build-frontend:
name: Build Frontend name: Build Frontend
needs: [ detect-changes, test-frontend ] needs: [ detect-changes, test-frontend ]
@@ -117,24 +243,51 @@ jobs:
deploy: deploy:
name: Deploy name: Deploy
needs: [ detect-changes, build-backend, build-frontend ] needs: [ detect-changes, build-backend, build-frontend, build-parapharmacy-api, build-pip-platform ]
if: | if: |
always() && always() &&
(needs.build-backend.result == 'success' || needs.build-backend.result == 'skipped') && (needs.build-backend.result == 'success' || needs.build-backend.result == 'skipped') &&
(needs.build-frontend.result == 'success' || needs.build-frontend.result == 'skipped') && (needs.build-frontend.result == 'success' || needs.build-frontend.result == 'skipped') &&
(needs.build-parapharmacy-api.result == 'success' || needs.build-parapharmacy-api.result == 'skipped') &&
(needs.build-pip-platform.result == 'success' || needs.build-pip-platform.result == 'skipped') &&
(needs.detect-changes.outputs.backend == 'true' || needs.detect-changes.outputs.frontend == 'true') (needs.detect-changes.outputs.backend == 'true' || needs.detect-changes.outputs.frontend == 'true')
runs-on: ubuntu-latest runs-on: self-hosted
steps: steps:
- name: SSH to remote server - name: Pull latest code
uses: appleboy/ssh-action@v1.0.3 working-directory: /docker/FarmaFinder
with: run: |
host: ${{ secrets.HOST }} set -euo pipefail
username: ${{ secrets.USERNAME }} git pull
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }} - name: Sync .env files from .env.example
script: | working-directory: /docker/FarmaFinder
cd /docker/FarmaFinder run: |
git pull set -euo pipefail
docker compose pull while IFS= read -r env_example; do
docker compose down --remove-orphans dir=$(dirname "$env_example")
docker compose up -d env_file="$dir/.env"
if [ ! -f "$env_file" ]; then
cp "$env_example" "$env_file"
echo "[env-sync] Created $env_file from $env_example"
else
while IFS= read -r line || [ -n "$line" ]; do
case "$line" in
''|\#*) continue ;;
esac
key=$(echo "$line" | cut -d'=' -f1)
if ! grep -qF "$key=" "$env_file"; then
echo "$line" >> "$env_file"
echo "[env-sync] Added missing key '$key' to $env_file"
fi
done < "$env_example"
fi
done < <(find apps -name ".env.example" -type f)
- name: Deploy containers
working-directory: /docker/FarmaFinder
run: |
set -euo pipefail
docker compose pull
docker compose down --remove-orphans
docker compose up -d
+54 -3
View File
@@ -13,6 +13,8 @@ jobs:
backend: ${{ steps.filter.outputs.backend }} backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }} frontend: ${{ steps.filter.outputs.frontend }}
frontend-mobile: ${{ steps.filter.outputs.frontend-mobile }} frontend-mobile: ${{ steps.filter.outputs.frontend-mobile }}
parapharmacy-api: ${{ steps.filter.outputs.parapharmacy-api }}
pip-platform: ${{ steps.filter.outputs.pip-platform }}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: dorny/paths-filter@v3 - uses: dorny/paths-filter@v3
@@ -31,6 +33,8 @@ jobs:
parapharmacy-api: parapharmacy-api:
- 'apps/parapharmacy-api/**' - 'apps/parapharmacy-api/**'
- 'packages/**' - 'packages/**'
pip-platform:
- 'apps/pip-platform/**'
test-backend: test-backend:
name: Backend Tests name: Backend Tests
@@ -95,6 +99,11 @@ jobs:
if: needs.detect-changes.outputs.parapharmacy-api == 'true' if: needs.detect-changes.outputs.parapharmacy-api == 'true'
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 15 timeout-minutes: 15
services:
mongodb:
image: mongo:7
ports:
- 27017:27017
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Setup Node.js - name: Setup Node.js
@@ -104,7 +113,49 @@ jobs:
cache: 'npm' cache: 'npm'
- name: Install dependencies - name: Install dependencies
run: npm ci --ignore-scripts run: npm ci --ignore-scripts
- name: Install parapharmacy-api native deps
run: npm rebuild sqlite3 bcrypt --workspace=farma-clic-parapharmacy-api
- name: Run Parapharmacy API Tests - name: Run Parapharmacy API Tests
run: npm test --workspace=farma-clic-parapharmacy-api run: npm test --workspace=farmafinder-parapharmacy-api
test-pip-platform:
name: PIP Platform Tests
needs: detect-changes
if: false && needs.detect-changes.outputs.pip-platform == 'true'
runs-on: ubuntu-latest
timeout-minutes: 15
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_DB: pip_test
POSTGRES_USER: pip
POSTGRES_PASSWORD: pip_test
ports:
- 5432:5432
options: >-
--health-cmd="pg_isready -U pip"
--health-interval=10s
--health-timeout=5s
--health-retries=5
redis:
image: redis:alpine
ports:
- 6379:6379
options: >-
--health-cmd="redis-cli ping"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install uv
run: pip install uv
- name: Install dependencies
working-directory: apps/pip-platform
run: uv sync --extra dev
- name: Run Tests
working-directory: apps/pip-platform
run: uv run pytest
+4
View File
@@ -20,5 +20,9 @@ VAPID_SUBJECT=mailto:admin@example.com
# https://expo.dev/accounts/[username]/settings/access-tokens # https://expo.dev/accounts/[username]/settings/access-tokens
EXPO_ACCESS_TOKEN= EXPO_ACCESS_TOKEN=
# Clave para que los workflows de N8N (capa ETL) hagan ingest al catálogo unificado.
# Genera una cadena aleatoria fuerte, p.ej.: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
INGEST_API_KEY=dev-ingest-key-change-me
# Parapharmacy API # Parapharmacy API
PARAPHARMACY_API_URL=http://localhost:3002 PARAPHARMACY_API_URL=http://localhost:3002
+1 -1
View File
@@ -6,7 +6,7 @@
# In Docker on the same host as Alloy, use http://localhost:4318 (the # In Docker on the same host as Alloy, use http://localhost:4318 (the
# container's perspective of the host). For external deploys, use the # container's perspective of the host). For external deploys, use the
# Alloy's public URL, e.g. https://alloy.example.com. # Alloy's public URL, e.g. https://alloy.example.com.
VITE_FARO_ENDPOINT=http://localhost:4318 VITE_FARO_ENDPOINT=https://grafana.hacecalor.net:4318
# App name shown in Grafana Explore / Faro data source. # App name shown in Grafana Explore / Faro data source.
VITE_FARO_APP_NAME=farmaclic-frontend VITE_FARO_APP_NAME=farmaclic-frontend