From 33cdca65439908c98b720fcbeb8dfca272d7319d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 12 May 2025 16:27:46 -0700 Subject: [PATCH 1/9] MAINT: adding testing requirements (should probably go into a separate file) --- requirements.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/requirements.txt b/requirements.txt index df354a5..108144e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,7 @@ ipympl sphinx-copybutton # For tutorials matplotlib +# for testing +pytest +nbval +pytest-custom_exit_code From 60f39977b699bab36ab161cd56915645e302bcb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 12 May 2025 16:29:40 -0700 Subject: [PATCH 2/9] MAINT: adding ipynb to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 9d64d4f..3f37e4c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ _build/* .ipynb_checkpoints /.pixi/* +*.ipynb + # We treat this repository as a library, not an application, and thus we do not # include the lockfile in source control. For a specific event, like a # workshop, we suggest committing the lockfile on a branch dedicated to the From 75555640d8b91cf8df41c051eee6e4cdb25961a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 12 May 2025 16:31:00 -0700 Subject: [PATCH 3/9] Adding ignore skeletons --- ignore_osx_testing | 0 ignore_windows_testing | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 ignore_osx_testing create mode 100644 ignore_windows_testing diff --git a/ignore_osx_testing b/ignore_osx_testing new file mode 100644 index 0000000..e69de29 diff --git a/ignore_windows_testing b/ignore_windows_testing new file mode 100644 index 0000000..e69de29 From 1b3e67ace43934e71f2c5a1d5435a68462d4366f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 12 May 2025 16:32:27 -0700 Subject: [PATCH 4/9] CI: adding tox and testing --- tox.ini | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tox.ini diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..2acae11 --- /dev/null +++ b/tox.ini @@ -0,0 +1,61 @@ +[tox] +envlist = + py{311, 312, 313}-test{,-oldestdeps,-devdeps,-predeps}{,-buildhtml} +requires = + pip >= 19.3.1 + +[testenv] + +description = run tests + +setenv = + devdeps: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/scientific-python-nightly-wheels/simple + +passenv = CI, CIRCLECI, GITHUB_EVENT_NAME, GITHUB_EVENT_PATH + +deps = + # We use these files to specify all the dependencies, and below we override + # versions for specific testing schenarios + -rrequirements.txt + #-rsite_requirements.txt + #-r.binder/requirements.txt + + # Notebooks may set minimums for some dependencies, the others are set for a supported minimum + # following e.g. SPEC0 or some other considerations. + oldestdeps: numpy==1.24.0 + oldestdeps: matplotlib==3.7.0 + + # TODO: add pure python dependency, so we can add an example for the github install + devdeps: git+https://github.com/astropy/pyvo.git#egg=pyvo + +allowlist_externals = bash, sed + +commands = + pip freeze + + ## Some of the these could be factored out to a separate shell script, + ## but so far it's simple enought to keep it here. + + + # Ignore testing the tutorials listed in ignore_testing file. We have some OS specific ignores, + # too due to issues with e.g. multiprocessing and problems in upstream dependency + !buildhtml: bash -c 'if python -c "import platform; print(platform.platform())" | grep -i macos; then cat ignore_osx_testing >> ignore_testing; fi' + !buildhtml: bash -c 'if python -c "import platform; print(platform.platform())" | grep -i win; then cat ignore_windows_testing >> ignore_testing; fi' + + !buildhtml: bash -c 'if [[ $CI == true ]]; then cat ignore_gha_testing >> ignore_testing; fi' + + # We only want to run CI in PRs for the notebooks we touched + !buildhtml: bash -c 'if [[ $GITHUB_EVENT_NAME == pull_request && -z "$(grep force_run:all_tests ${GITHUB_EVENT_PATH})" ]]; then git fetch origin main --depth=1; git diff origin/main --name-only tutorials | grep .md; else find tutorials -name "*.md"; fi | grep -vf ignore_testing | xargs jupytext --to notebook ' + + !buildhtml: pytest --nbval-lax -vv --suppress-no-test-exit-code --durations=10 tutorials + + buildhtml: sphinx-build -b html . _build/html -nWT --keep-going + # SED magic to remove the toctree captions from the rendered index page while keeping them in the sidebar TOC + buildhtml: sed -E -i.bak '/caption-text/{N; s/.+caption-text.+\n
    /
      /; P;D;}' _build/html/index.html + buildhtml: bash -c 'rm _build/html/index.html.bak' + +pip_pre = + predeps: true + !predeps: false + +skip_install = true From acaec7e0fc117bd199b244809015802c9492578c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 12 May 2025 16:38:11 -0700 Subject: [PATCH 5/9] CI: adding first draft for the GHA workflow, copied as is from irsa-tutorials --- .github/workflows/ci_tests_run_notebooks.yml | 77 ++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .github/workflows/ci_tests_run_notebooks.yml diff --git a/.github/workflows/ci_tests_run_notebooks.yml b/.github/workflows/ci_tests_run_notebooks.yml new file mode 100644 index 0000000..cbcd71c --- /dev/null +++ b/.github/workflows/ci_tests_run_notebooks.yml @@ -0,0 +1,77 @@ +name: Test notebooks + +on: + push: + branches: + - main + pull_request: + branches: + - main + schedule: + - cron: '0 5 * * 1' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + tests: + # Do not run the test matrix on PRs affecting the rendering + if: ${{ !(github.event_name == 'pull_request') || !contains(github.event.pull_request.labels.*.name, 'html rendering / skip testing') }} + + name: ${{ matrix.os }} ${{ matrix.name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + # Run all supported OS for one Python version, then add a few extra scenarios + os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ['3.12'] + toxenv: [py312-test] + name: ['with Python 3.12',] + + include: + - python-version: '3.10' + toxenv: py310-test-oldestdeps + name: with Python 3.10 and oldest versioned dependencies + os: ubuntu-latest + + - python-version: '3.13' + toxenv: py313-test-devdeps + name: with Python 3.13 and developer versioned dependencies + os: ubuntu-latest + + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d #v5.1.0 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: python -m pip install --upgrade tox + + - name: Test with tox + run: tox ${{ matrix.toxargs }} -e ${{ matrix.toxenv }} -- ${{ matrix.toxposargs }} + + + gha_buildhtml: + # When label is used, we do run buildhtml on GHA to check if the publishing job will run or not. + # Use in case when new content has run into troubles on CircleCI. + if: ${{ (github.event_name == 'pull_request') && contains(github.event.pull_request.labels.*.name, 'GHA buildhtml') }} + name: Buildhtml testing + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install dependencies + run: python -m pip install --upgrade tox + + - name: Execute notebooks as testing + run: tox -e py311-buildhtml From e16c8748745f76b9560e76dd6fca9d81d12b18ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 12 May 2025 16:39:47 -0700 Subject: [PATCH 6/9] Adding more ignore files --- ignore_gha_testing | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 ignore_gha_testing diff --git a/ignore_gha_testing b/ignore_gha_testing new file mode 100644 index 0000000..e69de29 From 6401f926fb352fb44de20ace477073e716ee455f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 12 May 2025 16:43:38 -0700 Subject: [PATCH 7/9] More requirements --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 108144e..a1e6cc1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,3 +10,4 @@ matplotlib pytest nbval pytest-custom_exit_code +jupytext From 221bd3b0865e88d1443bf900eb9ff3d5896a0289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 12 May 2025 17:06:35 -0700 Subject: [PATCH 8/9] Removing the OS dependent ignore logic --- ignore_gha_testing | 0 ignore_osx_testing | 0 ignore_windows_testing | 0 tox.ini | 8 -------- 4 files changed, 8 deletions(-) delete mode 100644 ignore_gha_testing delete mode 100644 ignore_osx_testing delete mode 100644 ignore_windows_testing diff --git a/ignore_gha_testing b/ignore_gha_testing deleted file mode 100644 index e69de29..0000000 diff --git a/ignore_osx_testing b/ignore_osx_testing deleted file mode 100644 index e69de29..0000000 diff --git a/ignore_windows_testing b/ignore_windows_testing deleted file mode 100644 index e69de29..0000000 diff --git a/tox.ini b/tox.ini index 2acae11..81ee08a 100644 --- a/tox.ini +++ b/tox.ini @@ -36,14 +36,6 @@ commands = ## Some of the these could be factored out to a separate shell script, ## but so far it's simple enought to keep it here. - - # Ignore testing the tutorials listed in ignore_testing file. We have some OS specific ignores, - # too due to issues with e.g. multiprocessing and problems in upstream dependency - !buildhtml: bash -c 'if python -c "import platform; print(platform.platform())" | grep -i macos; then cat ignore_osx_testing >> ignore_testing; fi' - !buildhtml: bash -c 'if python -c "import platform; print(platform.platform())" | grep -i win; then cat ignore_windows_testing >> ignore_testing; fi' - - !buildhtml: bash -c 'if [[ $CI == true ]]; then cat ignore_gha_testing >> ignore_testing; fi' - # We only want to run CI in PRs for the notebooks we touched !buildhtml: bash -c 'if [[ $GITHUB_EVENT_NAME == pull_request && -z "$(grep force_run:all_tests ${GITHUB_EVENT_PATH})" ]]; then git fetch origin main --depth=1; git diff origin/main --name-only tutorials | grep .md; else find tutorials -name "*.md"; fi | grep -vf ignore_testing | xargs jupytext --to notebook ' From f39887c0435b437ba19f664277fb281e49d71b66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Brigitta=20Sip=C5=91cz?= Date: Mon, 12 May 2025 17:26:33 -0700 Subject: [PATCH 9/9] No need to pin to hashes Co-authored-by: Dan Allan --- .github/workflows/ci_tests_run_notebooks.yml | 4 ++-- .gitignore | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_tests_run_notebooks.yml b/.github/workflows/ci_tests_run_notebooks.yml index cbcd71c..5f106c6 100644 --- a/.github/workflows/ci_tests_run_notebooks.yml +++ b/.github/workflows/ci_tests_run_notebooks.yml @@ -43,9 +43,9 @@ jobs: os: ubuntu-latest steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d #v5.1.0 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} diff --git a/.gitignore b/.gitignore index 3f37e4c..6154ca0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ _build/* .ipynb_checkpoints /.pixi/* +# Notebooks are stored in the text-based Markdown format. +# No .ipynb files should be stored in this repository. *.ipynb # We treat this repository as a library, not an application, and thus we do not