Skip to content

external-api-contracts #39

external-api-contracts

external-api-contracts #39

Workflow file for this run

# Non-PR-blocking external API contract checks (see docs/operations-testing.md).
# Runs the live halves of the contract suites against the real partner APIs nightly;
# failures alert but never gate merges. The hermetic halves of the same suites run
# in the PR-blocking test job.
name: external-api-contracts
on:
schedule:
- cron: "30 3 * * *"
workflow_dispatch:
jobs:
contracts:
name: External API contracts (live)
runs-on: ubuntu-latest
concurrency:
group: external-api-contracts-avenia-sandbox
cancel-in-progress: false
env:
CI: true
RUN_LIVE_TESTS: "1"
# A nightly where zero live calls completed must fail, not rot as green.
CONTRACT_EXPECT_LIVE: "1"
steps:
- name: 🛒 Checkout code
uses: actions/checkout@v3
- name: 🧩 Setup Bun
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.3.1
- name: 🧩 Install dependencies
run: bun install --frozen-lockfile
- name: 🔨 Build shared package
run: bun run build:shared
- name: 🧪 Live contract suites
working-directory: apps/api
# Sandbox credentials and pre-provisioned fixtures (see .env.example). A missing
# secret resolves to "" -> the suite's live half skips -> CONTRACT_EXPECT_LIVE
# fails that suite loudly instead of letting the drift detector rot as green.
env:
ALFREDPAY_BASE_URL: ${{ secrets.CONTRACT_ALFREDPAY_BASE_URL }}
ALFREDPAY_API_KEY: ${{ secrets.CONTRACT_ALFREDPAY_API_KEY }}
ALFREDPAY_API_SECRET: ${{ secrets.CONTRACT_ALFREDPAY_API_SECRET }}
ALFREDPAY_CONTRACT_CUSTOMER_ID: ${{ secrets.CONTRACT_ALFREDPAY_CUSTOMER_ID }}
ALFREDPAY_CONTRACT_FIAT_ACCOUNT_ID: ${{ secrets.CONTRACT_ALFREDPAY_FIAT_ACCOUNT_ID }}
ALFREDPAY_CONTRACT_KYC_SUBMISSION_ID: ${{ secrets.CONTRACT_ALFREDPAY_KYC_SUBMISSION_ID }}
BRLA_BASE_URL: ${{ secrets.CONTRACT_BRLA_BASE_URL }}
BRLA_API_KEY: ${{ secrets.CONTRACT_BRLA_API_KEY }}
BRLA_PRIVATE_KEY: ${{ secrets.CONTRACT_BRLA_PRIVATE_KEY }}
AVENIA_CONTRACT_SUBACCOUNT_ID: ${{ secrets.CONTRACT_AVENIA_SUBACCOUNT_ID }}
AVENIA_CONTRACT_WEBHOOK_URL: ${{ secrets.CONTRACT_AVENIA_WEBHOOK_URL }}
COINGECKO_API_KEY: ${{ secrets.COINGECKO_API_KEY }}
run: bun test src/tests/contracts/
# Non-blocking runs are only useful if somebody hears about failures.
# Same webhook token the nightly e2e workflow uses; skips silently when unset.
- name: 📣 Notify Slack on failure
if: failure()
env:
SLACK_WEB_HOOK_TOKEN: ${{ secrets.SLACK_WEB_HOOK_TOKEN }}
run: |
if [ -z "$SLACK_WEB_HOOK_TOKEN" ]; then
echo "SLACK_WEB_HOOK_TOKEN secret not configured; skipping notification."
exit 0
fi
curl -sf -X POST -H 'Content-Type: application/json' \
-d "{\"text\":\"Nightly external API contract run failed: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" \
"https://hooks.slack.com/services/${SLACK_WEB_HOOK_TOKEN}"