From 43f040687c226bca13771dc52b961940c7005691 Mon Sep 17 00:00:00 2001 From: Sam Andrello Date: Tue, 23 Jul 2024 16:23:29 -0400 Subject: [PATCH 1/4] Added workflow files --- .github/workflows/docs.yml | 43 +++++++++++++++++++++++++ .github/workflows/main.yml | 54 ++++++++++++++++++++++++++++++++ .github/workflows/pre-commit.yml | 19 +++++++++++ 3 files changed, 116 insertions(+) create mode 100644 .github/workflows/docs.yml create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/pre-commit.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..a4661f5c --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,43 @@ +name: Build Documentation + +on: + push: + branches: + - main + release: + +jobs: + test: + runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: build + auto-update-conda: true + + - name: install requirements + run: >- + conda install -n build -c conda-forge + --file requirements/build.txt + --file requirements/run.txt + --file requirements/docs.txt + --quiet --yes + + - name: install the package + run: python -m pip install . --no-deps + + - name: build documents + run: make -C doc html + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./doc/build/html diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..f306d0a8 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,54 @@ +name: CI + +on: + push: + branches: + - main + - CI + pull_request: + workflow_dispatch: + +jobs: + miniconda: + name: Miniconda ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ["ubuntu-latest"] + steps: + - name: check out diffpy.pdffit2 + uses: actions/checkout@v3 + with: + repository: diffpy/diffpy.pdffit2 + path: . + fetch-depth: 0 # avoid shallow clone with no tags + + - 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 + 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-activate-base: false + + - name: install diffpy.pdffit2 requirements + shell: bash -l {0} + 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 . + - name: Validate diffpy.pdffit2 + shell: bash -l {0} + run: | + conda activate test + coverage run -m pytest -vv -s + coverage report -m + codecov diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 00000000..f2ff7e42 --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,19 @@ +name: pre-commit + +on: + pull_request: + push: + workflow_dispatch: + +jobs: + pre-commit: + # pull requests are a duplicate of a branch push if within the same repo. + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + - uses: pre-commit/action@v3.0.0 + with: + extra_args: --all-files From b1dcb4d4b2b0a3b6838091ab138e7e42b0541824 Mon Sep 17 00:00:00 2001 From: Sam Andrello Date: Tue, 23 Jul 2024 16:49:18 -0400 Subject: [PATCH 2/4] update testing in main.yml --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f306d0a8..083672bd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,6 +49,8 @@ jobs: shell: bash -l {0} run: | conda activate test - coverage run -m pytest -vv -s + coverage run src/diffpy/pdffit2/tests/run.py +# uncover this after migrating to pytest +# coverage run -m pytest -vv -s coverage report -m codecov From 57ac92abb90fb88b36c025d5861bf3e34cbece50 Mon Sep 17 00:00:00 2001 From: Sam Andrello Date: Tue, 23 Jul 2024 16:53:09 -0400 Subject: [PATCH 3/4] pre-commit fixes --- .github/workflows/main.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 083672bd..00f20efe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -50,7 +50,14 @@ jobs: run: | conda activate test coverage run src/diffpy/pdffit2/tests/run.py -# uncover this after migrating to pytest -# coverage run -m pytest -vv -s coverage report -m codecov + +# Use this after migrating to pytest +# - name: Validate diffpy.pdffit2 +# shell: bash -l {0} +# run: | +# conda activate test +# coverage run -m pytest -vv -s +# coverage report -m +# codecov From 200318cf8c07c13b7f7d956c865c73f59c5872f6 Mon Sep 17 00:00:00 2001 From: Sam Andrello Date: Tue, 23 Jul 2024 17:00:07 -0400 Subject: [PATCH 4/4] use editable mode w/ main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 00f20efe..73a63006 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,7 +44,7 @@ jobs: conda activate test conda install --file requirements/run.txt conda install --file requirements/test.txt - pip install . + pip install -e . - name: Validate diffpy.pdffit2 shell: bash -l {0} run: |