Files
ai-news-writer/.gitea/workflows/test.yml
T
David Santos 616f8b0f52
ai-news-writer-ci / test (pull_request) Successful in 44s
fix(ci): do not fail Gitea Actions on artifact/Codecov steps
act_runner often cannot complete actions/upload-artifact@v3; treat upload and
Codecov as optional. Require coverage/lcov.info after tests so quality gate stays
strict. Harden PyYAML install for workflow parse step (PEP 668 / user site).
2026-05-01 20:43:34 +01:00

104 lines
3.8 KiB
YAML

# Gitea Actions — forge at git.bitreport.pt (BIT-2731 / BIT-3394).
#
# ## Secrets Management
# This workflow uses Gitea repository secrets to safely inject sensitive credentials.
# Never commit credentials directly to the repository.
#
# **Secrets in this workflow:**
# - `CODECOV_TOKEN` (optional): Codecov upload; job passes without it (artifact only).
#
# **Repository secrets for deploy / LXC (BIT-4619 — not all consumed by this file):**
# OPENAI_API_KEY, ANTHROPIC_API_KEY, WORDPRESS_USER, WORDPRESS_PASSWORD,
# TWITTER_BEARER_TOKEN, TELEGRAM_BOT_TOKEN, APP_ADMIN_SECRET, CODECOV_TOKEN.
# Deploy tooling maps WORDPRESS_* / APP_ADMIN_SECRET → WP_* / ADMIN_TOKEN in secrets.env.
#
# **To configure secrets:**
# 1. Go to repository Settings → Secrets
# 2. Add secret key-value pairs (e.g., CODECOV_TOKEN=<your-token>)
# 3. Reference in workflow as `${{ secrets.SECRET_NAME }}`
# 4. Secrets are not exposed in logs or build output
#
# **References:**
# - BIT-4620: Update Gitea Actions for secret injection
# - BIT-4603: Consolidate and standardize secrets management
name: ai-news-writer-ci
'on':
push:
branches: [main, master, develop]
pull_request:
branches: [main, master, develop]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: npm
- name: Install dependencies
run: npm ci
- name: Security audit
run: npm audit --audit-level=high
- name: Lint
run: npm run lint
- name: Run tests with coverage
run: npm test
- name: Verify coverage output
run: test -f coverage/lcov.info
# Gitea Actions / act_runner: upload-artifact@v4+ is unsupported; v3 can still fail on some
# runners. Coverage is already enforced by the step above; do not fail the merge gate on upload.
- name: Upload coverage artifact (lcov)
continue-on-error: true
uses: actions/upload-artifact@v3
with:
name: coverage-lcov
path: coverage/lcov.info
# Optional external upload — must not block CI when forge networking or Codecov is flaky.
- name: Codecov upload (optional — Gitea secret CODECOV_TOKEN)
continue-on-error: true
# Injects CODECOV_TOKEN from Gitea repository secrets
# If secret is not configured, this step gracefully skips upload
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: |
if [ -z "${CODECOV_TOKEN:-}" ]; then
echo "⚠ CODECOV_TOKEN not configured in repository secrets."
echo " Coverage artifact (lcov) is still available for manual upload."
echo " To enable automatic uploads, configure CODECOV_TOKEN in repo settings."
exit 0
fi
echo "↓ Uploading coverage to Codecov..."
curl -sSL -o codecov https://cli.codecov.io/latest/linux/codecov
chmod +x codecov
./codecov upload-process --disable-search -t "$CODECOV_TOKEN" -f coverage/lcov.info \
-n "ai-news-writer-ci-${{ github.run_id }}"
echo "✓ Coverage uploaded successfully"
- name: Workflow YAML parses
run: |
set -euo pipefail
python3 -m pip install --disable-pip-version-check --quiet pyyaml --break-system-packages \
|| python3 -m pip install --disable-pip-version-check --quiet --user pyyaml
python3 -c "import yaml; yaml.safe_load(open('.gitea/workflows/test.yml'))"
python3 -c "import yaml; yaml.safe_load(open('.gitea/workflows/deploy-staging.yml'))"
python3 -c "import yaml; yaml.safe_load(open('.gitea/workflows/deploy-production.yml'))"