From 5fef677fd03f9d3fa8dffb23f20718053e62b219 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Mon, 16 Dec 2024 11:40:11 -0800 Subject: [PATCH 1/3] added python setup for running tests against PROOF API --- .github/workflows/api-tests.yml | 30 ++++++++++++++++++++++++++++++ .gitignore | 13 +++++++++++++ .python-version | 1 + pyproject.toml | 10 ++++++++++ pytest.ini | 3 +++ tests/__init__.py | 0 tests/proof-api/test-api-basics.py | 29 +++++++++++++++++++++++++++++ 7 files changed, 86 insertions(+) create mode 100644 .github/workflows/api-tests.yml create mode 100644 .gitignore create mode 100644 .python-version create mode 100644 pyproject.toml create mode 100644 pytest.ini create mode 100644 tests/__init__.py create mode 100644 tests/proof-api/test-api-basics.py diff --git a/.github/workflows/api-tests.yml b/.github/workflows/api-tests.yml new file mode 100644 index 0000000..6714f6e --- /dev/null +++ b/.github/workflows/api-tests.yml @@ -0,0 +1,30 @@ +name: API Tests + +on: + push: + branches: + - main + - dev + - test-api + workflow_dispatch: + +jobs: + api-tests: + runs-on: + labels: linux-docker-runner + steps: + - uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: "0.5.8" + + - name: Set up Python + run: uv python install 3.13 + + - name: Run tests + env: + PROOF_API_TOKEN_DEV: ${{ secrets.PROOF_API_TOKEN_DEV }} + working-directory: wdl-tests + run: uv run pytest tests/proof-api/ --verbose diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8e32c0b --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# Python-generated files +__pycache__/ +*.py[oc] +build/ +dist/ +wheels/ +*.egg-info +uv.lock +.pytest_cache + +# Virtual environments +.venv +.env diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..24ee5b1 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.13 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..63782ce --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,10 @@ +[project] +name = "wdl-unit-tests" +version = "0.1.0" +description = "Add your description here" +readme = "README.md" +requires-python = ">=3.13" +dependencies = [ + "httpx>=0.28.1", + "pytest>=8.3.4", +] diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..0e0a68f --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +python_files = test-*.py +testpaths = tests diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/proof-api/test-api-basics.py b/tests/proof-api/test-api-basics.py new file mode 100644 index 0000000..de382ac --- /dev/null +++ b/tests/proof-api/test-api-basics.py @@ -0,0 +1,29 @@ +import os + +import httpx + +BASE_URL = "https://proof-api-dev.fredhutch.org" +# test user token +TOKEN = os.getenv("PROOF_API_TOKEN_DEV") +headers = {"Authorization": f"Bearer {TOKEN}"} +info_keys = ["branch", "commit_sha", "short_commit_sha", "commit_message", "tag"] +status_keys = [ + "canJobStart", + "jobStatus", + "cromwellUrl", + "jobStartTime", + "jobEndTime", + "jobInfo", +] + + +def test_info(): + res = httpx.get(f"{BASE_URL}/info") + assert isinstance(res, httpx.Response) + assert list(res.json().keys()) == info_keys + + +def test_status(): + res = httpx.get(f"{BASE_URL}/cromwell-server", headers=headers, timeout=10) + assert isinstance(res, httpx.Response) + assert list(res.json().keys()) == status_keys From bd0e992fd99ee03056b5e25b42f89784778b76f3 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Mon, 16 Dec 2024 13:42:06 -0800 Subject: [PATCH 2/3] runs-on self-hosted --- .github/workflows/api-tests.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/api-tests.yml b/.github/workflows/api-tests.yml index 6714f6e..cd82581 100644 --- a/.github/workflows/api-tests.yml +++ b/.github/workflows/api-tests.yml @@ -10,8 +10,7 @@ on: jobs: api-tests: - runs-on: - labels: linux-docker-runner + runs-on: self-hosted steps: - uses: actions/checkout@v4 From 98d22cca01e80a1a76cdffed92859aa673e4e423 Mon Sep 17 00:00:00 2001 From: Scott Chamberlain Date: Mon, 16 Dec 2024 13:44:18 -0800 Subject: [PATCH 3/3] remove working dir in api-tests yml file --- .github/workflows/api-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/api-tests.yml b/.github/workflows/api-tests.yml index cd82581..c409a22 100644 --- a/.github/workflows/api-tests.yml +++ b/.github/workflows/api-tests.yml @@ -25,5 +25,4 @@ jobs: - name: Run tests env: PROOF_API_TOKEN_DEV: ${{ secrets.PROOF_API_TOKEN_DEV }} - working-directory: wdl-tests run: uv run pytest tests/proof-api/ --verbose