From 4da8573d6df8ea74b18dbbde3b2fad233541f9ea Mon Sep 17 00:00:00 2001 From: Joseph Hamman Date: Tue, 24 Aug 2021 17:26:31 -0700 Subject: [PATCH 1/4] add basic ci setup --- .github/dependabot.yml | 11 ++++ .github/workflows/main.yaml | 81 ++++++++++++++++++++++++++++++ .github/workflows/pypipublish.yaml | 26 ++++++++++ .pre-commit-config.yaml | 56 +++++++++++++++++++++ dev-requirements.txt | 5 ++ requirements.txt | 4 ++ setup.py | 28 +++++------ 7 files changed, 196 insertions(+), 15 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/main.yaml create mode 100644 .github/workflows/pypipublish.yaml create mode 100644 .pre-commit-config.yaml create mode 100644 dev-requirements.txt create mode 100644 requirements.txt diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..d1d1190b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: + - package-ecosystem: pip + directory: "/" + schedule: + interval: daily + - package-ecosystem: "github-actions" + directory: "/" + schedule: + # Check for updates to GitHub Actions every weekday + interval: "daily" diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml new file mode 100644 index 00000000..e8d8f3d4 --- /dev/null +++ b/.github/workflows/main.yaml @@ -0,0 +1,81 @@ +name: CI + +on: + push: + branches: "*" + pull_request: + branches: main + schedule: + - cron: "0 0 * * *" + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.3.4 + - uses: actions/setup-python@v2.2.2 + - uses: pre-commit/action@v2.0.3 + + test: + name: ${{ matrix.python-version }}-build + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.7, 3.8, 3.9] + steps: + - uses: actions/checkout@v2.3.4 + - name: Setup Python + uses: actions/setup-python@v2.2.2 + with: + python-version: ${{ matrix.python-version }} + architecture: x64 + - uses: actions/cache@v2.1.6 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/dev-requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - run: | + python -m pip install -r dev-requirements.txt + python -m pip install --no-deps -e . + python -m pip list + - name: Running Tests + run: | + python -m pytest --cov=./ --cov-report=xml --verbose + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v2.0.2 + if: ${{ matrix.python-version }} == 3.8 + with: + file: ./coverage.xml + fail_ci_if_error: false + + test-upstream: + name: ${{ matrix.python-version }}-dev-build + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8, 3.9] + steps: + - uses: actions/checkout@v2.3.4 + - name: Setup Python + uses: actions/setup-python@v2.2.2 + with: + python-version: ${{ matrix.python-version }} + architecture: x64 + - uses: actions/cache@v2.1.6 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + - run: | + python -m pip install -r dev-requirements.txt + python -m pip install --no-deps --upgrade \ + git+https://github.com/pydata/xarray \ + git+https://github.com/Unidata/netcdf4-python \ + git+https://github.com/c0fec0de/anytree + python -m pip install --no-deps -e . + python -m pip list + - name: Running Tests + run: | + python -m pytest --verbose diff --git a/.github/workflows/pypipublish.yaml b/.github/workflows/pypipublish.yaml new file mode 100644 index 00000000..986315ca --- /dev/null +++ b/.github/workflows/pypipublish.yaml @@ -0,0 +1,26 @@ +name: Upload Python Package + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.3.4 + - name: Set up Python + uses: actions/setup-python@v2.2.1 + with: + python-version: "3.x" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install setuptools setuptools-scm wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..53525d0d --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,56 @@ +# https://pre-commit.com/ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.0.1 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + # isort should run before black as black sometimes tweaks the isort output + - repo: https://github.com/PyCQA/isort + rev: 5.9.3 + hooks: + - id: isort + # https://github.com/python/black#version-control-integration + - repo: https://github.com/psf/black + rev: 21.7b0 + hooks: + - id: black + - repo: https://github.com/keewis/blackdoc + rev: v0.3.4 + hooks: + - id: blackdoc + - repo: https://gitlab.com/pycqa/flake8 + rev: 3.9.2 + hooks: + - id: flake8 + # - repo: https://github.com/Carreau/velin + # rev: 0.0.8 + # hooks: + # - id: velin + # args: ["--write", "--compact"] + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.910 + hooks: + - id: mypy + # Copied from setup.cfg + exclude: "properties|asv_bench" + additional_dependencies: [ + # Type stubs + types-python-dateutil, + types-pkg_resources, + types-PyYAML, + types-pytz, + # Dependencies that are typed + numpy, + typing-extensions==3.10.0.0, + ] + # run this occasionally, ref discussion https://github.com/pydata/xarray/pull/3194 + # - repo: https://github.com/asottile/pyupgrade + # rev: v1.22.1 + # hooks: + # - id: pyupgrade + # args: + # - "--py3-only" + # # remove on f-strings in Py3.7 + # - "--keep-percent-format" diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 00000000..349f188d --- /dev/null +++ b/dev-requirements.txt @@ -0,0 +1,5 @@ +pytest +flake8 +black +codecov +-r requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..67e19d19 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +xarray>=0.19.0 +netcdf4 +anytree +future diff --git a/setup.py b/setup.py index 1ab01d6d..bbb05355 100644 --- a/setup.py +++ b/setup.py @@ -1,20 +1,16 @@ +from os.path import exists from setuptools import find_packages, setup -install_requires = [ - "xarray>=0.19.0", - "netcdf4" - "anytree", - "future", -] -extras_require = {'tests': - [ - "pytest", - "flake8", - "black", - "codecov", - ] -} +with open('requirements.txt') as f: + install_requires = f.read().strip().split('\n') + +if exists('README.rst'): + with open('README.rst') as f: + long_description = f.read() +else: + long_description = '' + setup( name="datatree", @@ -29,11 +25,13 @@ "Topic :: Scientific/Engineering", "License :: OSI Approved :: Apache License", "Operating System :: OS Independent", + "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", ], packages=find_packages(exclude=["docs", "tests", "tests.*", "docs.*"]), install_requires=install_requires, - extras_require=extras_require, python_requires=">=3.7", setup_requires="setuptools_scm", use_scm_version={ From b2a4a618459336dd75234fe63f15a8f90e6b543e Mon Sep 17 00:00:00 2001 From: Joseph Hamman Date: Tue, 24 Aug 2021 17:30:18 -0700 Subject: [PATCH 2/4] add long description from readme --- datatree/_version.py | 2 +- setup.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/datatree/_version.py b/datatree/_version.py index ef4e01b5..c7d99fbf 100644 --- a/datatree/_version.py +++ b/datatree/_version.py @@ -1 +1 @@ -__version__ = "0.1.dev9+g805d97f.d20210817" \ No newline at end of file +__version__ = "0.1.dev46+g415cbb7.d20210825" \ No newline at end of file diff --git a/setup.py b/setup.py index bbb05355..1110c1a3 100644 --- a/setup.py +++ b/setup.py @@ -15,6 +15,7 @@ setup( name="datatree", description="Hierarchical tree-like data structures for xarray", + long_description=long_description, url="https://github.com/TomNicholas/datatree", author="Thomas Nicholas", author_email="thomas.nicholas@columbia.edu", From c44436a64b7c20dd80d79d81d5748df2601de6a7 Mon Sep 17 00:00:00 2001 From: Joseph Hamman Date: Tue, 24 Aug 2021 17:43:36 -0700 Subject: [PATCH 3/4] switch to conda --- .github/workflows/main.yaml | 66 +++++++++++++++++++++---------------- ci/environment.yml | 12 +++++++ 2 files changed, 50 insertions(+), 28 deletions(-) create mode 100644 ci/environment.yml diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index e8d8f3d4..6d3e7dbe 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -24,30 +24,35 @@ jobs: python-version: [3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2.3.4 - - name: Setup Python - uses: actions/setup-python@v2.2.2 + - uses: conda-incubator/setup-miniconda@v2 with: + mamba-version: "*" + auto-update-conda: true python-version: ${{ matrix.python-version }} - architecture: x64 - - uses: actions/cache@v2.1.6 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/dev-requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - run: | - python -m pip install -r dev-requirements.txt + auto-activate-base: false + activate-environment: datatree + environment-file: ci/environment.yml + - name: Conda info + shell: bash -l {0} + run: conda info + - name: Conda list + shell: bash -l {0} + run: conda list + - name: Install datatree + shell: bash -l {0} + run: | python -m pip install --no-deps -e . python -m pip list - name: Running Tests + shell: bash -l {0} run: | python -m pytest --cov=./ --cov-report=xml --verbose - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2.0.2 - if: ${{ matrix.python-version }} == 3.8 - with: - file: ./coverage.xml - fail_ci_if_error: false + # - name: Upload coverage to Codecov + # uses: codecov/codecov-action@v2.0.2 + # if: ${{ matrix.python-version }} == 3.8 + # with: + # file: ./coverage.xml + # fail_ci_if_error: false test-upstream: name: ${{ matrix.python-version }}-dev-build @@ -57,19 +62,23 @@ jobs: python-version: [3.8, 3.9] steps: - uses: actions/checkout@v2.3.4 - - name: Setup Python - uses: actions/setup-python@v2.2.2 + - uses: conda-incubator/setup-miniconda@v2 with: + mamba-version: "*" + auto-update-conda: true python-version: ${{ matrix.python-version }} - architecture: x64 - - uses: actions/cache@v2.1.6 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/*requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - run: | - python -m pip install -r dev-requirements.txt + auto-activate-base: false + activate-environment: datatree + environment-file: ci/environment.yml + - name: Conda info + shell: bash -l {0} + run: conda info + - name: Conda list + shell: bash -l {0} + run: conda list + - name: Install dev reqs + shell: bash -l {0} + run: | python -m pip install --no-deps --upgrade \ git+https://github.com/pydata/xarray \ git+https://github.com/Unidata/netcdf4-python \ @@ -77,5 +86,6 @@ jobs: python -m pip install --no-deps -e . python -m pip list - name: Running Tests + shell: bash -l {0} run: | python -m pytest --verbose diff --git a/ci/environment.yml b/ci/environment.yml new file mode 100644 index 00000000..7b903d7d --- /dev/null +++ b/ci/environment.yml @@ -0,0 +1,12 @@ +name: datatree +channels: + - conda-forge + - nodefaults +dependencies: + - xarray >=0.19.0 + - netcdf4 + - anytree + - pytest + - flake8 + - black + - codecov From da7a41194e2b891969c3b5a1c87e5e1329aaa805 Mon Sep 17 00:00:00 2001 From: Joseph Hamman Date: Tue, 24 Aug 2021 17:46:15 -0700 Subject: [PATCH 4/4] add pytest-cov --- ci/environment.yml | 1 + dev-requirements.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/ci/environment.yml b/ci/environment.yml index 7b903d7d..8486fc92 100644 --- a/ci/environment.yml +++ b/ci/environment.yml @@ -10,3 +10,4 @@ dependencies: - flake8 - black - codecov + - pytest-cov diff --git a/dev-requirements.txt b/dev-requirements.txt index 349f188d..57209c77 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -2,4 +2,5 @@ pytest flake8 black codecov +pytest-cov -r requirements.txt