From c8dc1ec3e2848e6a3a7900f6f76f4ede103721ba Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Mon, 9 Dec 2024 11:09:18 +0300 Subject: [PATCH 1/2] use pytest in ci --- .github/workflows/ci.yml | 32 ++++++++++++++++++-------------- validate_probes.py => tests.py | 10 ++++++---- 2 files changed, 24 insertions(+), 18 deletions(-) rename validate_probes.py => tests.py (80%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d03ef2..872e01d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Validation +name: Run Tests on: push: @@ -6,17 +6,21 @@ on: pull_request: branches: [main] - jobs: - validate: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install jsonschema requests - - name: Validate - run: | - python validate_probes.py \ No newline at end of file + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install jsonschema requests pytest + + - name: Run tests + run: | + python -m pytest tests.py -v \ No newline at end of file diff --git a/validate_probes.py b/tests.py similarity index 80% rename from validate_probes.py rename to tests.py index ffe88c4..310edc0 100644 --- a/validate_probes.py +++ b/tests.py @@ -1,6 +1,8 @@ import glob -import jsonschema import json + +import jsonschema +import pytest import requests schema_url = "https://raw.githubusercontent.com/SpikeInterface/probeinterface/main/resources/probe.json.schema" @@ -10,9 +12,9 @@ files = glob.glob("*/*/*.json") -print("Validating the following files:") -for file in files: - print(file) + +@pytest.mark.parametrize("file", files) +def test_valid_probe_dict(file): with open(file) as f: data = json.load(f) jsonschema.validate(data, response.json()) \ No newline at end of file From b3039007279d47572c539240708e0d030d08c4f8 Mon Sep 17 00:00:00 2001 From: Ben Dichter Date: Mon, 9 Dec 2024 03:13:49 -0500 Subject: [PATCH 2/2] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 872e01d..3a581cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up Python 3.12 + - name: Set up Python uses: actions/setup-python@v5 - name: Install dependencies @@ -23,4 +23,4 @@ jobs: - name: Run tests run: | - python -m pytest tests.py -v \ No newline at end of file + python -m pytest tests.py -v