Skip to content

Commit

Permalink
Make PyCIEMSS testable (#32)
Browse files Browse the repository at this point in the history
* Refactor glue code into models

* Remove operations

* Install dev tools

* Add tests [mocking broken]

* Test if visual is True

* Document how to test

* Add CI for tests and formatting

* Link to file instead of URL for dataset

* Remove yaml lint

* Simplify API

* Fix imports on server

* Fix tests path
  • Loading branch information
fivegrant authored Aug 10, 2023
1 parent bba1705 commit 63993f1
Show file tree
Hide file tree
Showing 49 changed files with 86,474 additions and 413 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/correctness.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Correctness
on:
workflow_call:
push:
branches: ['main']
pull_request:
branches: ['main', 'dev/*']

jobs:
correctness:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Run image
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.5.1
- name: Create environment
run: poetry install
- name: Pytest
run: poetry run pytest
27 changes: 27 additions & 0 deletions .github/workflows/formatting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Formatting
on:
workflow_call:
push:
branches: ['main']
pull_request:
branches: ['main', 'dev/*']

jobs:
formatting:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Run image
uses: abatilo/actions-poetry@v2
with:
poetry-version: 1.5.1
- name: Create environment
run: poetry install
- name: Black
run: poetry run black . --check --verbose
- name: Ruff
run: poetry run ruff .
27 changes: 0 additions & 27 deletions .github/workflows/lint.yaml

This file was deleted.

9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.282
hooks:
- id: ruff
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ export LANG
.PHONY:init
init:
make envfile; \
poetry run pre-commit install; \
git submodule update --init; \


.PHONY:tidy
tidy:
poetry run pre-commit run; \
poetry run pytest

# Environment file copy
envfile:
ifeq ($(wildcard envfile),)
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ in order to pull the PyCIEMSS repository in as a submodule and set up the enviro

to start the containers and the API. The API url will be `http://localhost:8010` by default

## Testing

`poetry run pytest` executes tests. Run `make tidy` to execute the code formatter, tests, etc.

## Notes

### Result Files
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile.api
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ RUN poetry config virtualenvs.create false && \
poetry install --no-root --no-cache

COPY service service
COPY tests tests
COPY README.md README.md

RUN poetry install
Expand Down
1 change: 1 addition & 0 deletions docker/Dockerfile.worker
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ RUN poetry config virtualenvs.create false && \

RUN pip install --no-cache-dir git+https://github.com/ciemss/pyciemss.git
COPY service service
COPY tests tests
COPY README.md README.md

ENV REDIS_HOST redis
Expand Down
Loading

0 comments on commit 63993f1

Please sign in to comment.