From f7e9c4e73e013952be8650c190ca7e3a3eaa674f Mon Sep 17 00:00:00 2001
From: Heberto Mayorquin <h.mayorquin@gmail.com>
Date: Thu, 12 Sep 2024 18:33:35 -0600
Subject: [PATCH] Github CI only run doctests when tests are not run (#1077)

Co-authored-by: Paul Adkisson <paul.wesley.adkisson@gmail.com>
---
 .github/workflows/assess-file-changes.yml    | 2 +-
 .github/workflows/deploy-tests.yml           | 2 +-
 CHANGELOG.md                                 | 1 +
 docs/conversion_examples_gallery/conftest.py | 2 +-
 4 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/assess-file-changes.yml b/.github/workflows/assess-file-changes.yml
index 2a234659c..6c7887f63 100644
--- a/.github/workflows/assess-file-changes.yml
+++ b/.github/workflows/assess-file-changes.yml
@@ -41,7 +41,7 @@ jobs:
           echo "CHANGELOG_UPDATED=false" >> $GITHUB_OUTPUT
           for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
             echo $file
-            if [[ $file == "src/"* || $file == "tests/"* || $file == "requirements-minimal.txt" || $file == "requirements-testing.txt" || $file == "setup.py" || $file == ".github/"* ]]
+            if [[ $file == "src/"* || $file == "tests/"* || $file == "pyproject.toml"   || $file == "setup.py" || $file == ".github/"* ]]
             then
               echo "Source changed"
               echo "SOURCE_CHANGED=true" >> $GITHUB_OUTPUT
diff --git a/.github/workflows/deploy-tests.yml b/.github/workflows/deploy-tests.yml
index a1a6ae790..49af30be0 100644
--- a/.github/workflows/deploy-tests.yml
+++ b/.github/workflows/deploy-tests.yml
@@ -57,7 +57,7 @@ jobs:
 
   run-doctests-only:
     needs: assess-file-changes
-    if: ${{ needs.assess-file-changes.outputs.CONVERSION_GALLERY_CHANGED == 'true' || needs.assess-file-changes.outputs.SOURCE_CHANGED != 'true' }}
+    if: ${{ needs.assess-file-changes.outputs.CONVERSION_GALLERY_CHANGED == 'true' && needs.assess-file-changes.outputs.SOURCE_CHANGED != 'true' }}
     uses: ./.github/workflows/doctests.yml
 
   check-final-status:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cf4f6bfbb..05d393e9e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@
 * Added automated EFS volume creation and mounting to the `submit_aws_job` helper function. [PR #1018](https://github.com/catalystneuro/neuroconv/pull/1018)
 
 ## Improvements
+* Modified the CI to avoid running doctests twice [PR #1077](https://github.com/catalystneuro/neuroconv/pull/#1077)
 
 ## v0.6.3
 
diff --git a/docs/conversion_examples_gallery/conftest.py b/docs/conversion_examples_gallery/conftest.py
index 134b198b4..21c392bf0 100644
--- a/docs/conversion_examples_gallery/conftest.py
+++ b/docs/conversion_examples_gallery/conftest.py
@@ -17,5 +17,5 @@ def add_data_space(doctest_namespace, tmp_path):
     doctest_namespace["OPHYS_DATA_PATH"] = OPHYS_DATA_PATH
     doctest_namespace["TEXT_DATA_PATH"] = TEXT_DATA_PATH
 
-    doctest_namespace["path_to_save_nwbfile"] = Path(tmp_path) / "file.nwb"
+    doctest_namespace["path_to_save_nwbfile"] = Path(tmp_path) / "doctest_file.nwb"
     doctest_namespace["output_folder"] = Path(tmp_path)