Skip to content

chore(release): 2.0.0 (#121) #175

chore(release): 2.0.0 (#121)

chore(release): 2.0.0 (#121) #175

Workflow file for this run

name: Live API Tests
# Runs the LIVE contract tests (tests/live/**) against the real OilPriceAPI.
# These require the OILPRICEAPI_TEST_KEY repo secret. The job is gated so it
# only runs when the secret is present, and the live suite itself skips
# gracefully when the key env var is absent — so external forks (which cannot
# read the secret) are never blocked or failed.
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
live:
name: Live API contract tests
runs-on: ubuntu-latest
# Only run when the secret is available (it is empty on forked-PR contexts).
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository }}
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: "22"
- name: Install dependencies
run: npm ci
- name: Build package
run: npm run build
- name: Run live tests
# Shell-level guard: the `secrets` context is NOT available in step
# `if:` conditions — using it there makes GitHub reject the ENTIRE
# workflow file (red X on every push, tests never ran — issue #25).
# Same pattern as python-sdk: skip gracefully when no key (forks).
run: |
if [ -z "$OILPRICEAPI_TEST_KEY" ]; then
echo "OILPRICEAPI_TEST_KEY not set — skipping live tests (fork or unconfigured)."
exit 0
fi
npm run test:live
env:
OILPRICEAPI_TEST_KEY: ${{ secrets.OILPRICEAPI_TEST_KEY }}
- name: Run canonical success snippets against production
env:
OILPRICEAPI_KEY: ${{ secrets.OILPRICEAPI_TEST_KEY }}
run: |
if [ -z "$OILPRICEAPI_KEY" ]; then
echo "OILPRICEAPI_TEST_KEY not set; canonical snippet smoke skipped."
exit 0
fi
npx tsx examples/snippets/latest-price.ts
npx tsx examples/snippets/history.ts