From 0feac0c7d4d1a737dea5b578a0c63fff94613089 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 16 Sep 2024 22:01:11 -0400 Subject: [PATCH 1/7] Create codecov.yml for coverage testing --- .github/workflows/codecov.yml | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) 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..7b58122f --- /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.snmf + 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.snmf 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.snmf + 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 }} From 1bb657f6407343f9c21768dd9d3a776a9cd3d739 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 16 Sep 2024 22:07:26 -0400 Subject: [PATCH 2/7] Remove codecov in main.yml --- .github/workflows/main.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 581821ea..a90aaeb7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -50,6 +50,4 @@ jobs: shell: bash -l {0} run: | conda activate test - coverage run -m pytest -vv -s - coverage report -m - codecov + pytest From d81f5a1eef78bf70165fc9270299a8e8c0510569 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 16 Sep 2024 22:10:39 -0400 Subject: [PATCH 3/7] Upload to codecov to PR --- .github/workflows/codecov.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index 7b58122f..bf19c224 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -4,10 +4,7 @@ on: push: branches: - main - release: - types: - - prereleased - - published + pull_request: workflow_dispatch: defaults: From 4b73be92bdf917c99de3766f67835e1f36dc2ad1 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 16 Sep 2024 22:37:26 -0400 Subject: [PATCH 4/7] Use pytest --cov instead of codecov --- .github/workflows/codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml index bf19c224..0297142c 100644 --- a/.github/workflows/codecov.yml +++ b/.github/workflows/codecov.yml @@ -40,7 +40,7 @@ jobs: - name: Validate diffpy.snmf run: | - coverage run -m pytest -vv -s + pytest --cov coverage report -m codecov From 7e5e5473bb611e8725a419a69d40811cd374ff6e Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 16 Sep 2024 22:37:58 -0400 Subject: [PATCH 5/7] Update .coveragerc to remove src --- .coveragerc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.coveragerc b/.coveragerc index fa3fa528..427c7934 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,6 +1,4 @@ [run] -source = - src [report] omit = */python?.?/* @@ -11,3 +9,4 @@ omit = exclude_lines = if __name__ == '__main__': + From 46e5e263568ab19ff3487f687a0a6ecdb71bf515 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 17 Sep 2024 02:38:33 +0000 Subject: [PATCH 6/7] [pre-commit.ci] auto fixes from pre-commit hooks --- .coveragerc | 1 - 1 file changed, 1 deletion(-) diff --git a/.coveragerc b/.coveragerc index 427c7934..bd53f7e6 100644 --- a/.coveragerc +++ b/.coveragerc @@ -9,4 +9,3 @@ omit = exclude_lines = if __name__ == '__main__': - From e41e218dc7771e1678bf1f250ed330d0f3e5013c Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 16 Sep 2024 22:42:43 -0400 Subject: [PATCH 7/7] Add pytest-cov for test.txt --- requirements/test.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/test.txt b/requirements/test.txt index 6f9ccf84..d808074d 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,5 +1,5 @@ flake8 pytest codecov -coverage pytest-env +pytest-cov