add workflow to run tests on any branch (for now just runs existing mocha tests, but later will run integration tests against controllers as well)
Some checks failed
Server Tests / Mocha – Unit & Utility Tests (push) Failing after 1m37s
Some checks failed
Server Tests / Mocha – Unit & Utility Tests (push) Failing after 1m37s
This commit is contained in:
parent
fbfa44ba97
commit
35dad9bfff
81
.gitea/workflows/run-tests.yaml
Normal file
81
.gitea/workflows/run-tests.yaml
Normal file
@ -0,0 +1,81 @@
|
||||
# Gitea Actions – Server Tests
|
||||
#
|
||||
# Two jobs run on every push to any branch:
|
||||
# 1. jest-integration – Jest tests against the server's data methods (needs MongoDB)
|
||||
# 2. mocha-unit – Existing Mocha/Chai tests in tests/ and tests/utils/
|
||||
#
|
||||
# Prerequisites (Gitea repository secrets):
|
||||
# DB_HOSTS – MongoDB host(s), e.g. "127.0.0.1:27017"
|
||||
# DB_NAME – Must contain "test", e.g. "agmission_test"
|
||||
# DB_USR – MongoDB username
|
||||
# DB_PWD – MongoDB password
|
||||
# DB_AUTH_SRC – MongoDB auth source (default: "admin")
|
||||
# TOKEN_SECRET – JWT secret used by the server's auth helpers
|
||||
|
||||
name: Server Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
|
||||
# ── Shared env-file step (inline, re-used by both jobs via heredoc) ──────────
|
||||
|
||||
jobs:
|
||||
# ══════════════════════════════════════════════════════════════════════════
|
||||
# Job 2: Mocha/Chai tests – tests/ and tests/utils/
|
||||
# These tests are self-contained unit tests that do not require MongoDB.
|
||||
# ══════════════════════════════════════════════════════════════════════════
|
||||
mocha-unit:
|
||||
name: Mocha – Unit & Utility Tests
|
||||
runs-on: self-hosted
|
||||
|
||||
defaults:
|
||||
run:
|
||||
working-directory: Development/server
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '18'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: Development/server/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci --prefer-offline
|
||||
|
||||
# Write a minimal env file so dotenv does not error on startup.
|
||||
# These tests do not hit the database; DB_* values are placeholders.
|
||||
- name: Write test environment file
|
||||
run: |
|
||||
cat > environment.env <<'EOF'
|
||||
NODE_ENV=test
|
||||
DB_HOSTS=127.0.0.1:27017
|
||||
DB_NAME=agmission_test
|
||||
DB_USR=
|
||||
DB_PWD=
|
||||
TOKEN_SECRET=${{ secrets.TOKEN_SECRET || 'ci-test-secret-not-for-production' }}
|
||||
PRODUCTION=false
|
||||
NO_EMAIL_MODE=true
|
||||
ENABLE_SUBSCRIPTION=false
|
||||
STRIPE_SEC_KEY=sk_test_placeholder
|
||||
STRIPE_API_VERSION=2022-11-15
|
||||
EOF
|
||||
|
||||
# Run all top-level test_*.js files (skips integration/ and satloc/ sub-dirs
|
||||
# which are covered by the jest-integration job or need live connections).
|
||||
- name: Run Mocha unit tests (tests/)
|
||||
run: |
|
||||
npx mocha --exit --timeout 120000 \
|
||||
--require tests/setup.js \
|
||||
'tests/test_*.js'
|
||||
continue-on-error: false
|
||||
|
||||
# Run Mocha tests in tests/utils/
|
||||
- name: Run Mocha utility tests (tests/utils/)
|
||||
run: npm run test:utils
|
||||
continue-on-error: false
|
||||
Loading…
Reference in New Issue
Block a user