From d8bc7f7a8efe9ed55a340db847545db55cbaaf68 Mon Sep 17 00:00:00 2001 From: Du Phan Date: Wed, 4 Dec 2024 10:53:04 -0500 Subject: [PATCH] Add coveralls to CI (#1925) * Add coveralls to CI * Do not run coverage for docs * add coveralls badge to README * add github token for coveralls * try to set PYTEST_ADDOPTS globally * Use editable installation in CI for coverage --- .github/workflows/ci.yml | 24 +++++++++++++++++++++--- README.md | 1 + setup.py | 1 + 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3192e6ffb..ed4c5eeac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,6 +8,9 @@ on: pull_request: branches: [ master ] +env: + PYTEST_ADDOPTS: "--cov=numpyro" + jobs: lint: @@ -67,7 +70,7 @@ jobs: pip install jaxlib pip install jax pip install https://github.com/pyro-ppl/funsor/archive/master.zip - pip install .[dev,test] + pip install -e .[dev,test] pip freeze - name: Test with pytest run: | @@ -75,6 +78,11 @@ jobs: - name: Test x64 run: | JAX_ENABLE_X64=1 pytest -vs test/test_distributions.py -k powerLaw + - name: Coveralls + if: github.repository == 'pyro-ppl/numpyro' && matrix.python-version == '3.10' + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} test-inference: @@ -99,7 +107,7 @@ jobs: pip install jaxlib pip install jax pip install https://github.com/pyro-ppl/funsor/archive/master.zip - pip install .[dev,test] + pip install -e .[dev,test] pip freeze - name: Test with pytest run: | @@ -121,6 +129,11 @@ jobs: - name: Test nested sampling run: | JAX_ENABLE_X64=1 pytest -vs test/contrib/test_nested_sampling.py + - name: Coveralls + if: github.repository == 'pyro-ppl/numpyro' && matrix.python-version == '3.10' + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} examples: @@ -143,8 +156,13 @@ jobs: pip install jaxlib pip install jax pip install https://github.com/pyro-ppl/funsor/archive/master.zip - pip install .[dev,examples,test] + pip install -e .[dev,examples,test] pip freeze - name: Test with pytest run: | CI=1 XLA_FLAGS="--xla_force_host_platform_device_count=2" pytest -vs -k test_example + - name: Coveralls + if: github.repository == 'pyro-ppl/numpyro' && matrix.python-version == '3.10' + uses: coverallsapp/github-action@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 62a7fc5cd..f50d63600 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![Build Status](https://github.com/pyro-ppl/numpyro/workflows/CI/badge.svg)](https://github.com/pyro-ppl/numpyro/actions) +[![Coverage Status](https://coveralls.io/repos/github/pyro-ppl/numpyro/badge.svg)](https://coveralls.io/github/pyro-ppl/numpyro) [![Documentation Status](https://readthedocs.org/projects/numpyro/badge/?version=latest)](https://numpyro.readthedocs.io/en/latest/?badge=latest) [![Latest Version](https://badge.fury.io/py/numpyro.svg)](https://pypi.python.org/pypi/numpyro) diff --git a/setup.py b/setup.py index 353840a66..4985b7adc 100644 --- a/setup.py +++ b/setup.py @@ -66,6 +66,7 @@ "matplotlib", "optax>=0.0.6", "pylab-sdk", # jaxns dependency + "pytest-cov", "pyyaml", # flax dependency "requests", # pylab dependency "tensorflow_probability>=0.18.0",