Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial push GHA workflow #69

Merged
merged 4 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
on:
push:
branches: [main]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: 3.12

- name: cache poetry install
uses: actions/cache@v4
with:
path: ~/.local
key: poetry-1.8.3-0

- uses: snok/install-poetry@v1
with:
version: 1.8.3
virtualenvs-create: true
virtualenvs-in-project: true

- name: cache deps
id: cache-deps
uses: actions/cache@v4
with:
path: .venv
key: pydeps-${{ hashFiles('**/poetry.lock') }}

- run: poetry install --no-interaction --no-root
if: steps.cache-deps.outputs.cache-hit != 'true'

- run: poetry install --no-interaction

- run: poetry run pytest
17 changes: 8 additions & 9 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from unittest.mock import patch

from click.testing import CliRunner
import pytest

Expand Down Expand Up @@ -34,16 +36,13 @@ def test_info_with_config_summarizes(cli_runner):
for key in ['auth_id', 'data_dir', 'environment', 'local_output_dir', 'kinesis_arn', 'provider', 'ummg_dir', 'version']:
assert key in result.output

def test_process_requires_config(cli_runner):
@patch('nsidc.metgen.metgen.process')
def test_process_requires_config_does_not_call_process(mock, cli_runner):
result = cli_runner.invoke(cli, ['process'])
assert not mock.called
assert result.exit_code != 0

def test_process_with_config(cli_runner):
@patch('nsidc.metgen.metgen.process')
def test_process_with_config_calls_process(mock, cli_runner):
result = cli_runner.invoke(cli, ['process', '--config', './example/modscg.ini'])
assert result.exit_code == 0

def test_process_output(cli_runner):
result = cli_runner.invoke(cli, ['process', '--config', './example/modscg.ini'])
assert result.exit_code == 0
assert 'Saved CNM message' in result.output
assert 'Processed granules' in result.output
assert mock.called