Skip to content

Commit

Permalink
CDAT Migration Phase 2: Add CDAT regression test notebook template an…
Browse files Browse the repository at this point in the history
…d fix GH Actions build (#743)

- Add Makefile for quick access to multiple Python-based commands such as linting, testing, cleaning up cache and build files
- Fix some lingering unit tests failure
- Update `xcdat=0.6.0rc1` to `xcdat >=0.6.0` in `ci.yml`, `dev.yml` and `dev-nompi.yml`
- Add `xskillscore` to `ci.yml`
- Fix `pre-commit` issues
  • Loading branch information
tomvothecoder committed Oct 23, 2023
1 parent a27fb53 commit c1332db
Show file tree
Hide file tree
Showing 43 changed files with 1,478 additions and 256 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ repos:
rev: 6.1.0
hooks:
- id: flake8
args: ["--config=setup.cfg"]
args: [--config=setup.cfg]
additional_dependencies: [flake8-isort==6.1.0]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
hooks:
- id: mypy
args: ["--config=pyproject.toml"]
args: [--config=pyproject.toml]
additional_dependencies:
[dask, numpy>=1.23.0, xarray>=2023.3.0, types-PyYAML]
82 changes: 82 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
.PHONY: clean clean-test clean-pyc clean-build docs help
.DEFAULT_GOAL := help

define BROWSER_PYSCRIPT
import os, webbrowser, sys

from urllib.request import pathname2url

webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
endef
export BROWSER_PYSCRIPT

define PRINT_HELP_PYSCRIPT
import re, sys

for line in sys.stdin:
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
print("%-20s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT

BROWSER := python -c "$$BROWSER_PYSCRIPT"

# To run these commands: make <COMMAND>
# ==================================================

help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)

# Clean local repository
# ----------------------
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts

clean-build: ## remove build artifacts
rm -fr build/
rm -fr conda-build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +

clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +

clean-test: ## remove test and coverage artifacts
rm -fr tests_coverage_reports/
rm -f .coverage
rm -fr htmlcov/
rm -f coverage.xml
rm -fr .pytest_cache
rm -rf .mypy_cache

# Quality Assurance
# ----------------------
pre-commit: # run pre-commit quality assurance checks
pre-commit run --all-files

lint: ## check style with flake8
flake8 e3sm_diags tests

test: ## run tests quickly with the default Python and produces code coverage report
pytest
$(BROWSER) tests_coverage_reports/htmlcov/index.html

# Documentation
# ----------------------
docs: ## generate Sphinx HTML documentation, including API docs
rm -rf docs/generated
cd docs && make html
$(MAKE) -C docs clean
$(MAKE) -C docs html
$(BROWSER) docs/_build/html/index.html

# Build
# ----------------------
install: clean ## install the package to the active Python's site-packages
python setup.py install
171 changes: 0 additions & 171 deletions auxiliary_tools/cdat_regression_test.py

This file was deleted.

Loading

0 comments on commit c1332db

Please sign in to comment.