-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a simple build and smoke workflow - and package (#20)
* Add a build workflow * Add a smoke test workflow of forecast.py * Add preliminary package code to streamline tests
- Loading branch information
Showing
5 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Build | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
Build: | ||
runs-on: ubuntu-latest | ||
name: Install | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install . | ||
- name: Smoke test | ||
run: | | ||
pip install pytest | ||
pytest ./tests |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[pytest] | ||
testpaths = tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from setuptools import setup, find_packages | ||
import os | ||
|
||
|
||
# Function to parse requirements.txt | ||
def parse_requirements(filename): | ||
"""Load requirements from a pip requirements file.""" | ||
with open(filename, "r") as file: | ||
return file.read().splitlines() | ||
|
||
|
||
# Get the list of requirements from requirements.txt | ||
requirements_file = os.path.abspath( | ||
os.path.join(os.path.dirname(__file__), "requirements.txt") | ||
) | ||
install_requires = parse_requirements(requirements_file) | ||
|
||
setup( | ||
name="spinup_nemo", | ||
version="0.1", | ||
packages=find_packages(include=["lib"]), | ||
package_dir={"": "."}, # The root directory is the base | ||
install_requires=install_requires, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
This file contains tests for the 'forecast' module in the 'lib' package. | ||
The tests are written using pytest. | ||
""" | ||
|
||
import sys | ||
import os | ||
import pytest | ||
|
||
|
||
def test_import_forecast(): | ||
"""Test that the forecast module can be imported successfully.""" | ||
try: | ||
import lib.forecast | ||
|
||
assert True, "forecast imported successfully." | ||
except ImportError as e: | ||
pytest.fail(f"Failed to import forecast: {e}") |