Skip to content

Commit

Permalink
Add a simple build and smoke workflow - and package (#20)
Browse files Browse the repository at this point in the history
* Add a build workflow

* Add a smoke test workflow of forecast.py

* Add preliminary package code to streamline tests
  • Loading branch information
ma595 authored Dec 10, 2024
1 parent 9c17972 commit 9574ff0
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/python.yml
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 added lib/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
testpaths = tests
24 changes: 24 additions & 0 deletions setup.py
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,
)
19 changes: 19 additions & 0 deletions tests/test_forecast.py
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}")

0 comments on commit 9574ff0

Please sign in to comment.