Skip to content

Commit 4fd1181

Browse files
committed
fix coverage
1 parent 31ea0b1 commit 4fd1181

File tree

3 files changed

+87
-67
lines changed

3 files changed

+87
-67
lines changed

.coveragerc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
[run]
22
source =
3-
engine/
4-
visualize/
5-
probtest.py
6-
util/
3+
engine
4+
util
5+
visualize
76
omit =
8-
tests/*
7+
tests/*

.github/workflows/pytest.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,35 @@ on:
77
pull_request:
88
branches:
99
- main
10+
1011
jobs:
1112
probtest-pytest:
1213
runs-on: ubuntu-latest
1314
defaults:
1415
run:
1516
shell: bash -l {0}
17+
1618
steps:
1719
- uses: actions/checkout@v2
20+
1821
- name: Set up Python
1922
uses: actions/setup-python@v2
2023
with:
2124
python-version: 3.10.8
22-
- name: Install dependencies with pip
25+
- name: Install Poetry
26+
run: |
27+
curl -sSL https://install.python-poetry.org | python3 -
28+
- name: Configure Poetry to use the right Python version
29+
run: |
30+
poetry env use python3.10
31+
- name: Install dependencies with Poetry
2332
run: |
24-
python -m pip install --upgrade pip
25-
pip install -r requirements.txt
26-
- name: Run setup_env.py script
33+
poetry install
34+
- name: Run setup_env for eccodes definition
2735
run: |
28-
python setup_env.py
29-
- name: Run Pytest
36+
poetry run python setup_env
37+
- name: Run Pytest with Poetry
3038
env:
3139
TZ: Europe/Zurich
3240
run: |
33-
pytest -v -s --cov --cov-report=term tests/
41+
poetry run pytest -v -s --cov --cov-report=term tests/

setup_env.py

Lines changed: 68 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,73 @@
22
""" Setup .env with local eccodes definition """
33

44
import os
5+
import shutil
56
import subprocess
67

7-
base_path = os.getcwd()
8-
9-
eccodes_definition_path = os.path.join(base_path, "resource", "eccodes")
10-
cosmo_definition_path = os.path.join(base_path, "resource", "eccodes-cosmo-resources")
11-
12-
# Clone repositories
13-
subprocess.run(
14-
[
15-
"git",
16-
"clone",
17-
"--depth",
18-
"1",
19-
"-b",
20-
"2.39.0",
21-
"https://github.com/ecmwf/eccodes.git",
22-
eccodes_definition_path,
23-
],
24-
check=True,
25-
)
26-
subprocess.run(
27-
[
28-
"git",
29-
"clone",
30-
"--depth",
31-
"1",
32-
"-b",
33-
"v2.36.0.3",
34-
"https://github.com/COSMO-ORG/eccodes-cosmo-resources.git",
35-
cosmo_definition_path,
36-
],
37-
check=True,
38-
)
39-
40-
# Remove deprecated directory
41-
deprecated_path = os.path.join(eccodes_definition_path, "deprecated")
42-
if os.path.exists(deprecated_path):
43-
for root, dirs, files in os.walk(deprecated_path, topdown=False):
44-
for name in files:
45-
os.remove(os.path.join(root, name))
46-
for name in dirs:
47-
os.rmdir(os.path.join(root, name))
48-
os.rmdir(deprecated_path)
49-
50-
# Remove existing .env file
51-
ENV_FILE = ".env"
52-
if os.path.exists(ENV_FILE):
53-
os.remove(ENV_FILE)
54-
55-
# Write to .env file
56-
ENV_CONTENT = (
57-
f"ECCODES_DEFINITION_PATH={eccodes_definition_path}/definitions:"
58-
f"{cosmo_definition_path}/definitions\n"
59-
)
60-
with open(ENV_FILE, "w", encoding="utf-8") as file:
61-
file.write(ENV_CONTENT)
8+
9+
def main():
10+
base_path = os.getcwd()
11+
12+
resource_path = os.path.join(base_path, "resource")
13+
14+
eccodes_definition_path = os.path.join(resource_path, "eccodes")
15+
cosmo_definition_path = os.path.join(resource_path, "eccodes-cosmo-resources")
16+
17+
# remove existing resource
18+
if os.path.exists(resource_path):
19+
shutil.rmtree(resource_path)
20+
21+
# Clone repositories
22+
subprocess.run(
23+
[
24+
"git",
25+
"clone",
26+
"--depth",
27+
"1",
28+
"-b",
29+
"2.39.0",
30+
"https://github.com/ecmwf/eccodes.git",
31+
eccodes_definition_path,
32+
],
33+
check=True,
34+
)
35+
subprocess.run(
36+
[
37+
"git",
38+
"clone",
39+
"--depth",
40+
"1",
41+
"-b",
42+
"v2.36.0.3",
43+
"https://github.com/COSMO-ORG/eccodes-cosmo-resources.git",
44+
cosmo_definition_path,
45+
],
46+
check=True,
47+
)
48+
49+
# Remove deprecated directory
50+
deprecated_path = os.path.join(eccodes_definition_path, "deprecated")
51+
if os.path.exists(deprecated_path):
52+
for root, dirs, files in os.walk(deprecated_path, topdown=False):
53+
for name in files:
54+
os.remove(os.path.join(root, name))
55+
for name in dirs:
56+
os.rmdir(os.path.join(root, name))
57+
os.rmdir(deprecated_path)
58+
59+
# Remove existing .env file
60+
env_file = ".env"
61+
if os.path.exists(env_file):
62+
os.remove(env_file)
63+
64+
# Write to .env file
65+
env_content = (
66+
f"ECCODES_DEFINITION_PATH={eccodes_definition_path}/definitions:"
67+
f"{cosmo_definition_path}/definitions\n"
68+
)
69+
with open(env_file, "w", encoding="utf-8") as file:
70+
file.write(env_content)
71+
72+
73+
if __name__ == "__main__":
74+
main()

0 commit comments

Comments
 (0)