Prompt

How do I run API tests from GitHub Actions?

Technology / Testing & QA1 observationLast seen Oct 6, 2026

Latest observation

Oct 6, 2026OpenAI APIWeb search: off

A common way is to run your API tests as part of a GitHub Actions workflow on every push or pull request.

1) Put your tests in the repo

Typically you’ll have:

  • API test code in a folder like tests/
  • a test runner like:
    • pytest for Python
    • jest/supertest for Node.js
    • newman for Postman collections
    • curl + shell scripts for simple checks

2) Create a workflow file

Add a file like:

.github/workflows/api-tests.yml

3) Example: Python + pytest

If your API tests are in Python:

name: API Tests

on:
  push:
    branches: [main]
  pull_request:

jobs:
  api-tests:
    runs-on: ubuntu-latest

    services:
      postgres:
        image: postgres:16
        env:
          POSTGRES_USER: test
          POSTGRES_PASSWORD: test
          POSTGRES_DB: testdb
        ports:
          - 5432:5432
        options: >-
          --health-cmd="pg_isready -U test"
          --health-interval=10s
          --health-timeout=5s
          --health-retries=5

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.12'

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt

      - name: Run API tests
        env:
          API_BASE_URL: http://localhost:8000
        run: |
          pytest tests/api

4) Example: Node.js + Jest

If your API tests are Node-based:

name: API Tests

on:
  push:
    branches: [main]
  pull_request:

jobs:
  api-tests:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: 20

      - run: npm ci

      - name: Run API tests
        env:
          API_BASE_URL: https://staging.example.com
        run: npm test

5) If your API needs to be started in CI

If the API is part of the same repo, you may need to start it before tests:

- name: Start API
  run: |
    npm run start &
    sleep 10

Better is to wait for a health endpoint rather than using a fixed sleep.

Example:

- name: Wait for API
  run: |
    until curl -sf http://localhost:3000/health; do
      echo "Waiting for API..."
      sleep 2
    done

6) Use secrets for auth tokens

If your tests need credentials, store them in GitHub Secrets and reference them:

env:
  API_TOKEN: ${{ secrets.API_TOKEN }}

7) Postman/Newman example

If you use Postman collections:

name: API Tests

on:
  push:
    branches: [main]

jobs:
  newman-tests:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Newman
        run: npm install -g newman

      - name: Run Postman collection
        run: newman run tests/postman/collection.json

Best practices

  • Run tests on push and pull_request
  • Use environment variables for base URLs and secrets
  • Prefer a health check over arbitrary sleep
  • If possible, run tests against a disposable test environment
  • Upload test reports/artifacts if you want CI visibility

If you want, I can give you a workflow tailored to your stack (Python, Node, Postman, Java, etc.) and whether your API runs inside the workflow or against a deployed staging server.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.