From a101ab48d8e9fcc6be5dc3fdc491afe971beda4e Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Wed, 18 Sep 2024 11:28:31 +0100 Subject: [PATCH 1/5] gh-170: add traditional pygrep hooks (#236) Adds several misc `pygrep` hooks recommended by scientific python. Refs: #170, #187 --- .pre-commit-config.yaml | 7 +++++++ docs/examples.rst | 2 +- docs/manual/releases.rst | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5bf13d53..c9f3d4a0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,11 @@ repos: + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.10.0 + hooks: + - id: python-check-blanket-type-ignore + - id: rst-backticks + - id: rst-directive-colons + - id: rst-inline-touching-normal - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.6.3 hooks: diff --git a/docs/examples.rst b/docs/examples.rst index 0d24cd4f..76e722e7 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -13,7 +13,7 @@ and for the cosmological background. Make sure you have CAMB installed: $ python -c 'import camb' # should not give an error If you want to compute the angular matter power spectra in the examples, you -need the `glass.ext.camb` package: +need the ``glass.ext.camb`` package: .. code-block:: console diff --git a/docs/manual/releases.rst b/docs/manual/releases.rst index e4a00794..69c0e3d0 100644 --- a/docs/manual/releases.rst +++ b/docs/manual/releases.rst @@ -75,7 +75,7 @@ These notes document the changes between individual *GLASS* releases. power spectra by index from a list using GLASS ordering. * The :func:`~glass.galaxies.gaussian_phz()` function now accepts bounds using - `lower=` and `upper=` keyword parameters. + ``lower=`` and ``upper=`` keyword parameters. 2023.6 (30 Jun 2023) @@ -157,7 +157,7 @@ These notes document the changes between individual *GLASS* releases. by window functions using :func:`glass.shells.restrict` and :func:`glass.shells.partition`. - - The ``zmin`` and ``zmax`` parameters of `glass.galaxies.redshifts_from_nz` + - The ``zmin`` and ``zmax`` parameters of ``glass.galaxies.redshifts_from_nz`` have been removed for the same reason. - The ``glass.lensing.multi_plane_weights`` function, which computed all From f7cedc9e5289f0505a15aff742ca0ff8bb4c180e Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Wed, 18 Sep 2024 12:22:48 +0100 Subject: [PATCH 2/5] gh-170: add traditional pre-commit-hooks (#235) Adds several misc `pre-commit-hooks` recommended by scientific python. Refs: #170, #187 --------- Co-authored-by: Patrick J. Roddy --- .github/test-constraints.txt | 2 +- .pre-commit-config.yaml | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/test-constraints.txt b/.github/test-constraints.txt index 70a2563a..e01dbe3e 100644 --- a/.github/test-constraints.txt +++ b/.github/test-constraints.txt @@ -1,2 +1,2 @@ ---prefer-binary --only-binary numpy,scipy,healpy,healpix +--prefer-binary diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c9f3d4a0..7929029c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,4 +1,18 @@ repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-merge-conflict + - id: check-symlinks + - id: check-yaml + - id: debug-statements + - id: end-of-file-fixer + - id: mixed-line-ending + args: + - --fix=lf + - id: trailing-whitespace - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.10.0 hooks: From 7c1d9d297f2d0c48899613fc920b4fea11856011 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Wed, 18 Sep 2024 13:46:05 +0100 Subject: [PATCH 3/5] gh-204: split examples job and run it only on code changes (#237) Makes example tests a standalone job that executes only if something is changed in `glass/`. Closes: #204 --- .github/workflows/examples.yml | 29 +++++++++++++++++++++++++++++ .github/workflows/test.yml | 13 ------------- 2 files changed, 29 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/examples.yml diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml new file mode 100644 index 00000000..0ce03ffa --- /dev/null +++ b/.github/workflows/examples.yml @@ -0,0 +1,29 @@ +name: Test examples + +on: + push: + paths: + - "glass/**" + pull_request: + paths: + - "glass/**" + +concurrency: + # Skip intermediate builds: always. + # Cancel intermediate builds: only if it is a pull request build. + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }} + +jobs: + test-examples: + name: Test examples + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-python@v5 + with: + python-version: "3.x" + cache: pip + - run: pipx run --spec '.[examples]' jupyter execute examples/**/*.ipynb diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e6493ad7..6d628ffe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -62,16 +62,3 @@ jobs: sudo apt-get update sudo apt-get install pandoc - run: pipx run --spec '.[docs]' sphinx-build -W -b html docs _build/html - - examples: - name: Examples - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-python@v5 - with: - python-version: "3.x" - cache: pip - - run: pipx run --spec '.[examples]' jupyter execute examples/**/*.ipynb From 465f72ac7c3527cfe23e84d899ee0b4d3e10e347 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Wed, 18 Sep 2024 13:49:12 +0100 Subject: [PATCH 4/5] gh-176: revamp publishing workflow (#209) The developers will now be able to download wheels as artifacts from GH Actions without actually publishing a release. This helps in checking if everything is working well or if you want to distribute a pre-release wheel. Anyways, it is a good practice to keep these 2 jobs separate. Closes: #176 Refs: #187 --- .github/workflows/release.yml | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 762a1cc3..7b983dd0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,20 +1,47 @@ name: Release on: + workflow_dispatch: release: types: - published jobs: + dist: + runs-on: ubuntu-latest + permissions: + id-token: write + contents: read + steps: + - uses: actions/checkout@v4 + + - name: Build SDist and wheel + run: pipx run build + + - name: Check metadata + run: pipx run twine check dist/* + + - uses: actions/upload-artifact@v4 + with: + path: dist/* + publish: - name: Publish on PyPI + needs: [dist] runs-on: ubuntu-latest + if: github.event_name == 'release' && github.event.action == 'published' environment: name: publish url: https://pypi.org/p/glass permissions: id-token: write + steps: - - uses: actions/checkout@v4 - - run: pipx run build - - uses: pypa/gh-action-pypi-publish@v1.10.1 + - uses: actions/download-artifact@v4 + with: + name: artifact + path: dist + + - name: List distributions to be deployed + run: ls -l dist/ + + - uses: pypa/gh-action-pypi-publish@release/v1 From d7bd1e2f76bea37c67050c6acdae06fb18cfc71f Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Wed, 18 Sep 2024 15:30:20 +0100 Subject: [PATCH 5/5] gh-222: add infrastructure for testpypi uploads (#244) The workflow now makes a PyPI upload if a release is created on GitHub, or if the workflow is triggered manually with an explicit "pypi" input. For default manual triggers, it will now upload to TestPyPI. Closes: #222 --- .github/workflows/release.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7b983dd0..a86bb32f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,6 +2,10 @@ name: Release on: workflow_dispatch: + inputs: + target: + description: 'Deployment target. Can be "pypi" or "testpypi"' + default: "testpypi" release: types: - published @@ -28,7 +32,6 @@ jobs: publish: needs: [dist] runs-on: ubuntu-latest - if: github.event_name == 'release' && github.event.action == 'published' environment: name: publish url: https://pypi.org/p/glass @@ -44,4 +47,10 @@ jobs: - name: List distributions to be deployed run: ls -l dist/ - - uses: pypa/gh-action-pypi-publish@release/v1 + - if: github.event.inputs.target == 'pypi' || (github.event_name == 'release' && github.event.action == 'published') + uses: pypa/gh-action-pypi-publish@release/v1 + + - if: github.event.inputs.target == 'testpypi' + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/