final ts cleanup?
Some checks failed
Deploy to Test Environment / deploy-to-test (push) Failing after 11m31s
Some checks failed
Deploy to Test Environment / deploy-to-test (push) Failing after 11m31s
This commit is contained in:
@@ -43,7 +43,20 @@ jobs:
|
||||
- name: Install Dependencies
|
||||
run: npm ci # 'ci' is faster and safer for CI/CD than 'install'.
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
- name: Bump Version and Push
|
||||
run: |
|
||||
# Configure git for the commit.
|
||||
git config --global user.name 'Gitea Actions'
|
||||
git config --global user.email 'actions@gitea.projectium.com'
|
||||
|
||||
# Bump the patch version number. This creates a new commit and a new tag.
|
||||
# The commit message includes [skip ci] to prevent this push from triggering another workflow run.
|
||||
npm version patch -m "ci: Bump version to %s [skip ci]"
|
||||
|
||||
# Push the new commit and the new tag back to the main branch.
|
||||
git push --follow-tags
|
||||
|
||||
# -----------------------------------------------------------------------
|
||||
|
||||
# --- NEW DEBUGGING STEPS ---
|
||||
- name: Verify Project Structure
|
||||
@@ -85,23 +98,23 @@ jobs:
|
||||
DB_HOST: ${{ secrets.DB_HOST }}
|
||||
DB_USER: ${{ secrets.DB_USER }}
|
||||
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
|
||||
DB_NAME: "flyer-crawler-test" # Explicitly set for tests
|
||||
DB_NAME: 'flyer-crawler-test' # Explicitly set for tests
|
||||
|
||||
# --- Redis credentials for the test suite ---
|
||||
REDIS_URL: "redis://localhost:6379"
|
||||
REDIS_URL: 'redis://localhost:6379'
|
||||
REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD_TEST }}
|
||||
|
||||
# --- Integration test specific variables ---
|
||||
FRONTEND_URL: "http://localhost:3000"
|
||||
VITE_API_BASE_URL: "http://localhost:3001/api"
|
||||
FRONTEND_URL: 'http://localhost:3000'
|
||||
VITE_API_BASE_URL: 'http://localhost:3001/api'
|
||||
GEMINI_API_KEY: ${{ secrets.VITE_GOOGLE_GENAI_API_KEY }}
|
||||
|
||||
|
||||
# --- JWT Secret for Passport authentication in tests ---
|
||||
JWT_SECRET: ${{ secrets.JWT_SECRET }}
|
||||
|
||||
# --- Increase Node.js memory limit to prevent heap out of memory errors ---
|
||||
# This is crucial for memory-intensive tasks like running tests and coverage.
|
||||
NODE_OPTIONS: "--max-old-space-size=8192"
|
||||
NODE_OPTIONS: '--max-old-space-size=8192'
|
||||
|
||||
run: |
|
||||
# Fail-fast check to ensure secrets are configured in Gitea for testing.
|
||||
@@ -109,15 +122,15 @@ jobs:
|
||||
echo "ERROR: One or more test secrets (DB_*, GEMINI_API_KEY, REDIS_PASSWORD_TEST) are not set in Gitea repository secrets."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Temporarily disable secret masking to prevent the runner from garbling test output numbers.
|
||||
echo "::stop-commands secret-masking::"
|
||||
|
||||
|
||||
# Run unit and integration tests as separate steps.
|
||||
# The `|| true` ensures the workflow continues even if tests fail, allowing coverage to run.
|
||||
echo "--- Running Unit Tests ---"
|
||||
npm run test:unit -- --coverage --reporter=verbose --includeTaskLocation --testTimeout=10000 --silent=passed-only || true
|
||||
|
||||
|
||||
echo "--- Running Integration Tests ---"
|
||||
npm run test:integration -- --coverage --reporter=verbose --includeTaskLocation --testTimeout=10000 --silent=passed-only || true
|
||||
|
||||
@@ -155,13 +168,13 @@ jobs:
|
||||
# nyc's `report` command can merge multiple coverage files automatically.
|
||||
# The standard way to do this is to place all `coverage-final.json` files
|
||||
# into a single directory and point `nyc report` to it.
|
||||
|
||||
|
||||
# Step 1: Define a directory for nyc to use as its source for merging.
|
||||
# We use a path relative to the workspace to avoid issues with the runner's CWD.
|
||||
NYC_SOURCE_DIR=".coverage/nyc-source-for-report"
|
||||
mkdir -p "$NYC_SOURCE_DIR" || echo "Directory $NYC_SOURCE_DIR already exists."
|
||||
echo "Created temporary directory for nyc reporting source: $NYC_SOURCE_DIR"
|
||||
|
||||
|
||||
# Step 2: Copy the individual coverage reports into the source directory.
|
||||
# We give them unique names to be safe, though it's not strictly necessary.
|
||||
cp .coverage/unit/coverage-final.json "$NYC_SOURCE_DIR/unit-coverage.json"
|
||||
@@ -170,7 +183,7 @@ jobs:
|
||||
cp .coverage/integration-server/coverage-final.json "$NYC_SOURCE_DIR/integration-server-coverage.json" || echo "Server coverage file not found, skipping."
|
||||
echo "Copied coverage files to source directory. Contents:"
|
||||
ls -l "$NYC_SOURCE_DIR"
|
||||
|
||||
|
||||
# Step 3: Generate the reports directly from the source directory.
|
||||
# We explicitly tell nyc where to find the source coverage files (`--temp-dir`)
|
||||
# and where to output the final reports (`--report-dir`).
|
||||
@@ -281,7 +294,7 @@ jobs:
|
||||
run: |
|
||||
echo "Deploying application files to /var/www/flyer-crawler-test.projectium.com..."
|
||||
APP_PATH="/var/www/flyer-crawler-test.projectium.com"
|
||||
|
||||
|
||||
# Ensure the destination directory exists
|
||||
mkdir -p "$APP_PATH"
|
||||
mkdir -p "$APP_PATH/flyer-images/icons" "$APP_PATH/flyer-images/archive" # Ensure all required subdirectories exist
|
||||
@@ -308,23 +321,22 @@ jobs:
|
||||
DB_NAME: ${{ secrets.DB_DATABASE_TEST }}
|
||||
|
||||
# Redis Credentials
|
||||
REDIS_URL: "redis://localhost:6379"
|
||||
REDIS_URL: 'redis://localhost:6379'
|
||||
REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD_TEST }}
|
||||
|
||||
# Application Secrets
|
||||
FRONTEND_URL: "https://flyer-crawler-test.projectium.com"
|
||||
FRONTEND_URL: 'https://flyer-crawler-test.projectium.com'
|
||||
JWT_SECRET: ${{ secrets.JWT_SECRET_TEST }}
|
||||
GEMINI_API_KEY: ${{ secrets.VITE_GOOGLE_GENAI_API_KEY_TEST }}
|
||||
GOOGLE_MAPS_API_KEY: ${{ secrets.GOOGLE_MAPS_API_KEY }}
|
||||
|
||||
# SMTP (email)
|
||||
SMTP_HOST: "localhost"
|
||||
SMTP_PORT: "1025"
|
||||
SMTP_SECURE: "false"
|
||||
SMTP_USER: "" # Using MailHog, no auth needed
|
||||
SMTP_PASS: "" # Using MailHog, no auth needed
|
||||
SMTP_FROM_EMAIL: "noreply@flyer-crawler-test.projectium.com"
|
||||
|
||||
SMTP_HOST: 'localhost'
|
||||
SMTP_PORT: '1025'
|
||||
SMTP_SECURE: 'false'
|
||||
SMTP_USER: '' # Using MailHog, no auth needed
|
||||
SMTP_PASS: '' # Using MailHog, no auth needed
|
||||
SMTP_FROM_EMAIL: 'noreply@flyer-crawler-test.projectium.com'
|
||||
|
||||
run: |
|
||||
# Fail-fast check to ensure secrets are configured in Gitea.
|
||||
@@ -341,7 +353,7 @@ jobs:
|
||||
# We also add `&& pm2 save` to persist the process list across server reboots.
|
||||
pm2 startOrReload ecosystem.config.cjs --env test && pm2 save
|
||||
echo "Test backend server reloaded successfully."
|
||||
|
||||
|
||||
# After a successful deployment, update the schema hash in the database.
|
||||
# This ensures the next deployment will compare against this new state.
|
||||
echo "Updating schema hash in test database..."
|
||||
@@ -349,7 +361,7 @@ jobs:
|
||||
PGPASSWORD="$DB_PASSWORD" psql -v ON_ERROR_STOP=1 -h "$DB_HOST" -p 5432 -U "$DB_USER" -d "$DB_NAME" -c \
|
||||
"INSERT INTO public.schema_info (environment, schema_hash, deployed_at) VALUES ('test', '$CURRENT_HASH', NOW())
|
||||
ON CONFLICT (environment) DO UPDATE SET schema_hash = EXCLUDED.schema_hash, deployed_at = NOW();"
|
||||
|
||||
|
||||
# Verify the hash was updated
|
||||
UPDATED_HASH=$(PGPASSWORD="$DB_PASSWORD" psql -v ON_ERROR_STOP=1 -h "$DB_HOST" -p 5432 -U "$DB_USER" -d "$DB_NAME" -c "SELECT schema_hash FROM public.schema_info WHERE environment = 'test';" -t -A)
|
||||
if [ "$CURRENT_HASH" = "$UPDATED_HASH" ]; then
|
||||
@@ -357,7 +369,7 @@ jobs:
|
||||
else
|
||||
echo "ERROR: Failed to update schema hash in the database."
|
||||
fi
|
||||
|
||||
|
||||
echo "--- Cleaning up test-generated flyer assets from production directories ---"
|
||||
PROD_APP_PATH="/var/www/flyer-crawler.projectium.com"
|
||||
find "$PROD_APP_PATH/flyer-images" -type f -name '*-test-flyer-image.*' -delete || echo "No test flyer images to delete in prod."
|
||||
@@ -372,4 +384,4 @@ jobs:
|
||||
sleep 5 # Wait a few seconds for the app to start and log its output.
|
||||
pm2 describe flyer-crawler-api-test || echo "Could not find test pm2 process."
|
||||
pm2 logs flyer-crawler-api-test --lines 20 --nostream || echo "Could not find test pm2 process."
|
||||
pm2 env flyer-crawler-api-test || echo "Could not find test pm2 process."
|
||||
pm2 env flyer-crawler-api-test || echo "Could not find test pm2 process."
|
||||
|
||||
Reference in New Issue
Block a user