From e0aaad1862648bc26e44ed644c65d2bfef2b6951 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sun, 8 Sep 2024 11:03:53 -0400 Subject: [PATCH 1/6] Include latest CI files from cookiecutter --- .github/workflows/codecov.yml | 53 ++++++++++++++++++++++++++++++++ .github/workflows/docs.yml | 49 ++++++++++++++++-------------- .github/workflows/main.yml | 57 ++++++++++++++--------------------- 3 files changed, 102 insertions(+), 57 deletions(-) create mode 100644 .github/workflows/codecov.yml diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 00000000..67c555eb --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,53 @@ +name: Gather coverage report and upload to codecov + +on: + push: + branches: + - main + release: + types: + - prereleased + - published + workflow_dispatch: + +defaults: + run: + shell: bash -l {0} + +jobs: + coverage: + runs-on: ubuntu-latest + steps: + - name: Check out diffpy.utils + uses: actions/checkout@v4 + + - name: Initialize miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + activate-environment: test + auto-update-conda: true + environment-file: environment.yml + auto-activate-base: false + + - name: Conda config + run: >- + conda config --set always_yes yes + --set changeps1 no + + - name: Install diffpy.utils and requirements + run: | + conda install --file requirements/run.txt + conda install --file requirements/test.txt + python -m pip install -r requirements/pip.txt + python -m pip install . --no-deps + + - name: Validate diffpy.utils + run: | + coverage run -m pytest -vv -s + coverage report -m + codecov + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v4 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a4661f5c..2dfe9640 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,43 +1,48 @@ -name: Build Documentation +name: Build and Deploy Documentation on: - push: - branches: - - main release: + types: + - published + workflow_dispatch: + +defaults: + run: + shell: bash -l {0} jobs: - test: + docs: runs-on: ubuntu-latest - defaults: - run: - shell: bash -l {0} steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 + - name: Check out diffpy.utils + uses: actions/checkout@v4 - - uses: conda-incubator/setup-miniconda@v2 + - name: Initialize miniconda + uses: conda-incubator/setup-miniconda@v3 with: activate-environment: build auto-update-conda: true + environment-file: environment.yml + auto-activate-base: false - - name: install requirements + - name: Conda config run: >- - conda install -n build -c conda-forge - --file requirements/build.txt - --file requirements/run.txt - --file requirements/docs.txt - --quiet --yes + conda config --set always_yes yes + --set changeps1 no - - name: install the package - run: python -m pip install . --no-deps + - name: Install diffpy.utils and build requirements + run: | + conda install --file requirements/build.txt + conda install --file requirements/run.txt + conda install --file requirements/docs.txt + python -m pip install -r requirements/pip.txt + python -m pip install . --no-deps - name: build documents run: make -C doc html - name: Deploy - uses: peaceiris/actions-gh-pages@v3 + uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./doc/build/html + publish_dir: ./doc/build/html \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c39ace43..eeffc764 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,55 +1,42 @@ -name: CI +name: Test on: push: branches: - main - - CI pull_request: workflow_dispatch: +defaults: + run: + shell: bash -l {0} + jobs: - miniconda: - name: Miniconda ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: ["ubuntu-latest"] + validate: + runs-on: ubuntu-latest steps: - - name: check out diffpy.utils - uses: actions/checkout@v3 - with: - repository: diffpy/diffpy.utils - path: . - fetch-depth: 0 # avoid shallow clone with no tags + - name: Check out diffpy.utils + uses: actions/checkout@v4 - - name: initialize miniconda - # this uses a marketplace action that sets up miniconda in a way that makes - # it easier to use. I tried setting it up without this and it was a pain - uses: conda-incubator/setup-miniconda@v2 + - name: Initialize miniconda + uses: conda-incubator/setup-miniconda@v3 with: activate-environment: test - # environment.yml file is needed by this action. Because I don't want - # maintain this but rather maintain the requirements files it just has - # basic things in it like conda and pip - environment-file: ./environment.yml - python-version: 3 + auto-update-conda: true + environment-file: environment.yml auto-activate-base: false - - name: install diffpy.utils requirements - shell: bash -l {0} + - name: Conda config + run: >- + conda config --set always_yes yes + --set changeps1 no + + - name: Install diffpy.utils and requirements run: | - conda config --set always_yes yes --set changeps1 no - conda config --add channels conda-forge - conda activate test conda install --file requirements/run.txt conda install --file requirements/test.txt - pip install . + python -m pip install -r requirements/pip.txt + python -m pip install . --no-deps - name: Validate diffpy.utils - shell: bash -l {0} - run: | - conda activate test - coverage run run_tests.py - coverage report -m - codecov + run: python -m pytest \ No newline at end of file From 567429eceb3d3b19fb2f37766e154372f73826e9 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sun, 8 Sep 2024 11:07:45 -0400 Subject: [PATCH 2/6] Include empty pip.txt file to satisfy GH CI --- requirements/pip.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 requirements/pip.txt diff --git a/requirements/pip.txt b/requirements/pip.txt new file mode 100644 index 00000000..e69de29b From e176a37231367440b26406ca91964f7226b745fe Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sun, 8 Sep 2024 11:12:24 -0400 Subject: [PATCH 3/6] Apply pre-commit --- .github/workflows/codecov.yml | 2 +- .github/workflows/docs.yml | 2 +- .github/workflows/main.yml | 2 +- MANIFEST.in | 16 ++++------------ pyproject.toml | 6 +++--- 5 files changed, 10 insertions(+), 18 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 67c555eb..e8bae0c8 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -50,4 +50,4 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 2dfe9640..7b3ac4ce 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -45,4 +45,4 @@ jobs: uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./doc/build/html \ No newline at end of file + publish_dir: ./doc/build/html diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eeffc764..fb0cb88b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,4 +39,4 @@ jobs: python -m pip install . --no-deps - name: Validate diffpy.utils - run: python -m pytest \ No newline at end of file + run: python -m pytest diff --git a/MANIFEST.in b/MANIFEST.in index 1e928c83..56f4a490 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,15 +1,7 @@ recursive-include src * +recursive-include tests * include AUTHORS.txt LICENSE*.txt README.rst -recursive-exclude src *.py[co] -global-exclude .gitattributes .gitignore .gitarchive.cfg -global-exclude .DS_Store -# Avoid user content in setup.cfg to make distribution reproducible. -exclude setup.cfg - -# Exclude git-tracked files spuriously added by setuptools_scm -exclude .coveragerc -exclude .travis* -prune conda-recipe -prune devutils -prune doc +# Exclude all bytecode files and __pycache__ directories +recursive-exclude src *.pyc *.pyo __pycache__/ +recursive-exclude tests *.pyc *.pyo __pycache__/ diff --git a/pyproject.toml b/pyproject.toml index 5d54b46f..5d8d0e57 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,8 +3,8 @@ requires = ["setuptools>=62.0", "setuptools-git-versioning<2"] build-backend = "setuptools.build_meta" [project] -name = "diffpy.utils" -dynamic=['version'] +name = "diffpy.utilstestlee" +version = "3.2.0rc10" authors = [ { name="Simon J.L. Billinge group", email="simon.billinge@gmail.com" }, ] @@ -46,7 +46,7 @@ dirty_template = "{tag}" [tool.setuptools.packages.find] where = ["src"] # list of folders that contain the packages (["."] by default) include = ["diffpy*"] # package names should match these glob patterns (["*"] by default) -exclude = ["diffpy.utils.tests*"] # exclude packages matching these glob patterns (empty by default) +exclude = [] # exclude packages matching these glob patterns (empty by default) namespaces = false # to disable scanning PEP 420 namespaces (true by default) [tool.black] From b1966f106b02fb2dd35dd82b9779628ba2393109 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sun, 8 Sep 2024 11:19:30 -0400 Subject: [PATCH 4/6] Use unmodified MANIFEST, pyproject files --- MANIFEST.in | 16 ++++++++++++---- pyproject.toml | 8 ++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 56f4a490..1e928c83 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,15 @@ recursive-include src * -recursive-include tests * include AUTHORS.txt LICENSE*.txt README.rst +recursive-exclude src *.py[co] +global-exclude .gitattributes .gitignore .gitarchive.cfg +global-exclude .DS_Store -# Exclude all bytecode files and __pycache__ directories -recursive-exclude src *.pyc *.pyo __pycache__/ -recursive-exclude tests *.pyc *.pyo __pycache__/ +# Avoid user content in setup.cfg to make distribution reproducible. +exclude setup.cfg + +# Exclude git-tracked files spuriously added by setuptools_scm +exclude .coveragerc +exclude .travis* +prune conda-recipe +prune devutils +prune doc diff --git a/pyproject.toml b/pyproject.toml index 5d8d0e57..73a50ceb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,8 +3,8 @@ requires = ["setuptools>=62.0", "setuptools-git-versioning<2"] build-backend = "setuptools.build_meta" [project] -name = "diffpy.utilstestlee" -version = "3.2.0rc10" +name = "diffpy.utils" +dynamic=['version'] authors = [ { name="Simon J.L. Billinge group", email="simon.billinge@gmail.com" }, ] @@ -46,7 +46,7 @@ dirty_template = "{tag}" [tool.setuptools.packages.find] where = ["src"] # list of folders that contain the packages (["."] by default) include = ["diffpy*"] # package names should match these glob patterns (["*"] by default) -exclude = [] # exclude packages matching these glob patterns (empty by default) +exclude = ["diffpy.utils.tests*"] # exclude packages matching these glob patterns (empty by default) namespaces = false # to disable scanning PEP 420 namespaces (true by default) [tool.black] @@ -70,4 +70,4 @@ exclude = ''' | blib2to3 | tests/data )/ -''' +''' \ No newline at end of file From f5904fd4d2a312e0b51f944376ea4d0fb50702d6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 8 Sep 2024 15:19:38 +0000 Subject: [PATCH 5/6] [pre-commit.ci] auto fixes from pre-commit hooks --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 73a50ceb..5d54b46f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,4 +70,4 @@ exclude = ''' | blib2to3 | tests/data )/ -''' \ No newline at end of file +''' From 8db3d9db3f4d7273a2646adc735c2386280e4910 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Sun, 8 Sep 2024 11:20:23 -0400 Subject: [PATCH 6/6] Remove unused testhelper.py --- pyproject.toml | 2 +- tests/testhelpers.py | 30 ------------------------------ 2 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 tests/testhelpers.py diff --git a/pyproject.toml b/pyproject.toml index 73a50ceb..5d54b46f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -70,4 +70,4 @@ exclude = ''' | blib2to3 | tests/data )/ -''' \ No newline at end of file +''' diff --git a/tests/testhelpers.py b/tests/testhelpers.py deleted file mode 100644 index aaa2a519..00000000 --- a/tests/testhelpers.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env python -############################################################################## -# -# diffpy.utils by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2011 The Trustees of Columbia University -# in the City of New York. All rights reserved. -# -# File coded by: Pavol Juhas -# -# See AUTHORS.txt for a list of people who contributed. -# See LICENSE_DANSE.txt for license information. -# -############################################################################## - -"""Helper routines for running other unit tests. -""" - -# helper functions - - -def datafile(filename): - from importlib.resources import as_file, files - - ref = files(__package__) / ("testdata/" + filename) - with as_file(ref) as rv: - return rv - - -# End of file