From 10494037dcff4381a56ce25ddf2397ff68606bed Mon Sep 17 00:00:00 2001 From: Vern Kofford Date: Wed, 11 Feb 2026 21:54:50 -0700 Subject: [PATCH] ci: add GitHub Actions workflow for automated API testing - Create GitHub Actions workflow for running tests on push/PR - Add CI badge to README - Add CI/CD documentation to README Closes #6 --- .github/workflows/api-tests.yml | 36 +++++++++++++++++++++++++++++++++ README.md | 19 +++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .github/workflows/api-tests.yml diff --git a/.github/workflows/api-tests.yml b/.github/workflows/api-tests.yml new file mode 100644 index 0000000..b828825 --- /dev/null +++ b/.github/workflows/api-tests.yml @@ -0,0 +1,36 @@ +name: API Tests + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.9' + + - name: Install uv + run: curl -LsSf https://astral.sh/uv/install.sh | sh + + - name: Install dependencies + run: uv sync + + - name: Run tests + run: uv run pytest -v + + - name: Upload test results on failure + if: failure() + uses: actions/upload-artifact@v4 + with: + name: test-results + path: .pytest_cache/ \ No newline at end of file diff --git a/README.md b/README.md index 9c2c136..f4afbf4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Python API Testing - JSONPlaceholder +![API Tests](https://github.com/vernko/python-api-testing-jsonplaceholder/actions/workflows/api-tests.yml/badge.svg) + REST API test automation suite using Python, pytest, and requests library. Tests the JSONPlaceholder fake REST API to demonstrate API testing skills. ## Setup @@ -20,6 +22,23 @@ uv run pytest -v uv run pytest tests/test_posts.py -v ``` +## CI/CD + +This project uses GitHub Actions for continuous integration. Tests run automatically on: +- Every push to `main` branch +- Every pull request to `main` branch + +### Workflow Details + +The CI pipeline: +1. Sets up Python 3.9 environment +2. Installs `uv` package manager +3. Installs project dependencies +4. Runs all tests with pytest +5. Uploads test results as artifacts on failure + +See `.github/workflows/api-tests.yml` for full workflow configuration. + ## Project Structure ``` tests/