From 2a4af293559dc5249f1c3cc2dd1a25f5cd2a0cad Mon Sep 17 00:00:00 2001
From: Mingyi Xue <mxue33@wisc.edu>
Date: Tue, 8 Oct 2024 17:20:51 -0500
Subject: [PATCH] add codecov action and config file

---
 .github/workflows/coverage.yml | 73 ++++++++++++++++++++++++++++++++++
 codecov.yml                    |  6 +++
 2 files changed, 79 insertions(+)
 create mode 100644 .github/workflows/coverage.yml
 create mode 100644 codecov.yml

diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
new file mode 100644
index 00000000..eb43c612
--- /dev/null
+++ b/.github/workflows/coverage.yml
@@ -0,0 +1,73 @@
+name: Build msmbuilder2022 codecov
+
+on:
+  push:
+    branches:
+      - main
+    # ignore changes to docs
+    paths-ignore:
+      - ./docs/*
+  pull_request:
+    branches:
+      - main
+    # ignore changes to docs
+    paths-ignore:
+      - ./docs/*
+  workflow_dispatch:
+
+jobs:
+  build-code:
+    runs-on: ${{ matrix.os }}
+    strategy:
+      max-parallel: 6
+      matrix:
+        python-version: ["3.12"]
+        include:
+        - os: ubuntu-latest
+          path: ~/.cache/pip
+    defaults:
+      run:
+        shell: bash -el {0}
+
+    steps:
+    - uses: actions/checkout@v4
+    - uses: actions/cache@v4
+      with:
+        path: ${{ matrix.path }}
+        key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
+        restore-keys: |
+          ${{ runner.os }}-pip-
+    - uses: conda-incubator/setup-miniconda@v3
+      with:
+        auto-activate-base: true
+        auto-update-conda: true
+        python-version: ${{ matrix.python-version }}
+        activate-environment: test
+    - name: Install required packages 
+      run: |
+        conda config --add channels conda-forge 
+        # conda install -yq conda-build jinja2 conda-verify
+        conda install -yq zlib
+        conda install h5py
+        python -m pip install --upgrade pip
+        # conda update conda-build
+    - name: Pip install
+      run: |
+        python -m pip install .
+    - name: Test with pytest
+      run: |
+        conda install -yq numdifftools hmmlearn
+        pip install pytest
+        pip install pytest-cov
+        mkdir ../../pkgs
+        cp -r msmbuilder/tests ../../pkgs/
+        cd ../../pkgs
+        python tests/data_init.py
+        pytest tests --cov=msmbuilder --cov-report=xml:coverage.xml
+    - name: Upload coverage reports to Codecov
+      uses: codecov/codecov-action@v4
+      with:
+        token: ${{ secrets.CODECOV_TOKEN }}
+        file: ../../pkgs/coverage.xml
+        fail_ci_if_error: True
+        verbose: True
\ No newline at end of file
diff --git a/codecov.yml b/codecov.yml
new file mode 100644
index 00000000..c6d92b64
--- /dev/null
+++ b/codecov.yml
@@ -0,0 +1,6 @@
+ignore:
+  - "msmbuilder/tests"
+
+comment:
+  layout: "reach, diff, flags, files" 
+