Skip to content

Commit 836ea3e

Browse files
committed
add support for LEGEND_METADATA_TESTDIR usage in tests for ci
1 parent 8ebf2b0 commit 836ea3e

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ jobs:
3232
run: |
3333
python -m pip install --upgrade pip wheel setuptools
3434
python -m pip install --upgrade .[test]
35-
- name: Set LEGEND_METADATA variable
35+
- name: Set LEGEND_METADATA_TESTDIR variable
3636
run: |
37-
echo "LEGEND_METADATA=$GITHUB_WORKSPACE/legend-metadata" >> $GITHUB_ENV
37+
echo "LEGEND_METADATA_TESTDIR=$GITHUB_WORKSPACE/legend-metadata" >> $GITHUB_ENV
3838
- name: Clone legend-metadata
3939
if: github.event.pull_request.head.repo.fork == false
4040
uses: actions/checkout@v4
@@ -43,11 +43,11 @@ jobs:
4343
fetch-depth: 0
4444
submodules: recursive
4545
token: ${{ secrets.READPRIVATE }}
46-
path: ${{ env.LEGEND_METADATA }}
46+
path: ${{ env.LEGEND_METADATA_TESTDIR }}
4747
- name: Run unit tests
4848
if: github.event.pull_request.head.repo.fork == true
4949
run: |
50-
python -m pytest
50+
python -m pytest -m "not needs_slowcontrol"
5151
- name: Run unit tests that need legend-metadata
5252
if: github.event.pull_request.head.repo.fork == false
5353
run: |
@@ -68,9 +68,9 @@ jobs:
6868
run: |
6969
python -m pip install --upgrade pip wheel setuptools
7070
python -m pip install --upgrade .[test]
71-
- name: Set LEGEND_METADATA variable
71+
- name: Set LEGEND_METADATA_TESTDIR variable
7272
run: |
73-
echo "LEGEND_METADATA=$GITHUB_WORKSPACE/legend-metadata" >> $GITHUB_ENV
73+
echo "LEGEND_METADATA_TESTDIR=$GITHUB_WORKSPACE/legend-metadata" >> $GITHUB_ENV
7474
- name: Clone legend-metadata
7575
if: github.event.pull_request.head.repo.fork == false
7676
uses: actions/checkout@v4
@@ -79,11 +79,11 @@ jobs:
7979
fetch-depth: 0
8080
submodules: recursive
8181
token: ${{ secrets.READPRIVATE }}
82-
path: ${{ env.LEGEND_METADATA }}
82+
path: ${{ env.LEGEND_METADATA_TESTDIR }}
8383
- name: Generate report for unit tests
8484
if: github.event.pull_request.head.repo.fork == true
8585
run: |
86-
python -m pytest --cov=legendmeta --cov-report=xml
86+
python -m pytest --cov=legendmeta --cov-report=xml -m "not needs_slowcontrol"
8787
- name: Generate report for (all) unit tests
8888
if: github.event.pull_request.head.repo.fork == false
8989
run: |

src/legendmeta/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class LegendMetadata(TextDB):
5151
"""
5252

5353
def __init__(self, path: str | None = None, **kwargs) -> None:
54-
if isinstance(path, str):
54+
if isinstance(path, (str, Path)):
5555
self.__repo_path__ = path
5656
else:
5757
self.__repo_path__ = os.getenv("LEGEND_METADATA", "")

tests/test_lmeta.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import os
34
from datetime import datetime
45

56
import pytest
@@ -16,8 +17,13 @@
1617

1718

1819
@pytest.fixture
19-
def metadb():
20-
mdata = LegendMetadata(lazy=True)
20+
def metadb(tmpdir):
21+
if os.getenv("LEGEND_METADATA_TESTDIR") is not None:
22+
# for the CI
23+
mdata = LegendMetadata(os.getenv("LEGEND_METADATA_TESTDIR"), lazy=True)
24+
else:
25+
# explicit path ignores LEGEND_METADATA
26+
mdata = LegendMetadata(str(tmpdir), lazy=True)
2127
mdata.checkout("main")
2228
return mdata
2329

0 commit comments

Comments
 (0)