diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c050e9b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: CI # This is the name of our workflow. + +on: # This section defines the events that trigger the workflow. + push: # When you push code to the repository. + branches: [ main, master ] # Only trigger on the main or master branch. + pull_request: # When a pull request is opened or updated. + +jobs: # All tasks that we want to run are grouped under jobs. + lint-and-test: # The name of our job. + runs-on: ubuntu-latest # This job will run on the latest version of Ubuntu. + + steps: # Each job consists of multiple steps. + - uses: actions/checkout@v4 # Step 1: Checkout the code from your repo. + + - uses: actions/setup-python@v5 # Step 2: Set up Python environment. + with: + python-version: '3.11' # We’re using Python 3.11. + cache: 'pip' # Cache the dependencies to speed up future runs. + + - name: Install dependencies + run: | + python -m pip install --upgrade pip # Upgrade pip. + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi # Install project dependencies. + pip install pytest pytest-cov # Also install testing tools. + + - name: Run tests + run: pytest -q --maxfail=1 --disable-warnings --cov=src --cov-report=xml # Step 4: Run tests and measure code coverage. + + - name: Upload coverage.xml + if: always() # Even if tests fail, upload the coverage report. + uses: actions/upload-artifact@v4 + with: + name: coverage-xml + path: coverage.xml # Save the test coverage report. \ No newline at end of file diff --git a/tests/test_imports.py b/tests/test_imports.py new file mode 100644 index 0000000..ec049a3 --- /dev/null +++ b/tests/test_imports.py @@ -0,0 +1,14 @@ +import importlib + +def test_imports(): + import streamlit + import numpy + import matplotlib + +def test_project_modules_import(): + for mod in [ + "src.fh_segmentation", + "src.union_find", + "src.image_utils", + ]: + importlib.import_module(mod)