Skip to content

Commit

Permalink
Merge pull request #487 from moble/github_actions
Browse files Browse the repository at this point in the history
Add github actions CI
  • Loading branch information
utensil authored Mar 28, 2024
2 parents 359b0e1 + 76a3ce3 commit 225e994
Show file tree
Hide file tree
Showing 13 changed files with 132 additions and 53 deletions.
18 changes: 9 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ jobs:
docker:
- image: cimg/python:3.6

"publish":
docker:
- image: cimg/python:3.7
steps:
- checkout
- run:
name: Upload to PyPi
command: |
./circle-build-package
# "publish":
# docker:
# - image: cimg/python:3.7
# steps:
# - checkout
# - run:
# name: Upload to PyPi
# command: |
# ./circle-build-package

workflows:
version: 2
Expand Down
89 changes: 89 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Python CI

on:
push:
branches:
- master
tags: ['*']
pull_request:

concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true

env:
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"

jobs:
build:
name: Python ${{ matrix.python-version }} ${{ matrix.extra-env }}
if: >-
!contains(github.event.head_commit.message, '[skip ci]')
&& !contains(github.event.head_commit.message, '[skip tests]')
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install -r test_requirements.txt
python -m pip install -e .
python -m pip check
- name: Lint
run: |
flake8 -v
- name: Test
run: |
PYTEST_ARGS=();
PYTEST_ARGS+=(-n 2 --dist loadscope);
if [[ ! -z "$PYTEST_K_FILTER" ]]; then
PYTEST_ARGS+=(-k "$PYTEST_K_FILTER");
fi;
pytest \
--cov=galgebra \
--nbval examples/ipython/ \
test \
--current-env \
--sanitize-with test/.nbval_sanitize.cfg \
"${PYTEST_ARGS[@]}"
- name: Upload coverage to Codecov
if: "matrix.python-version == '3.11'"
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}

release:
name: Create release and send to PyPI
needs: build
if: >-
github.ref_type == 'tag'
&& startsWith(github.ref, 'refs/tags/v')
&& !contains(github.event.head_commit.message, '[skip ci]')
&& !contains(github.event.head_commit.message, '[no release]')
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install wheel
run: |
python -m pip install wheel
- name: Build and upload package
if: success()
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
11 changes: 11 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
build:
os: "ubuntu-22.04"
tools:
python: "3.11"

python:
install:
- requirements: doc/readthedocs-pip-requirements.txt
- method: pip
path: .
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Symbolic Geometric Algebra/Calculus package for SymPy.

[![PyPI](https://img.shields.io/pypi/v/galgebra.svg)](https://pypi.org/project/galgebra/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/galgebra.svg)](https://pypi.org/project/galgebra/)
[![Build Status on CircleCI](https://circleci.com/gh/pygae/galgebra.svg?style=shield)](https://circleci.com/gh/pygae/galgebra)
[![Python CI](https://github.com/pygae/galgebra/actions/workflows/ci.yml/badge.svg)](https://github.com/pygae/galgebra/actions/workflows/ci.yml)
[![Documentation Status](https://readthedocs.org/projects/galgebra/badge/?version=latest)](https://galgebra.readthedocs.io/en/latest/?badge=latest)
[![DOI](https://zenodo.org/badge/113447311.svg)](https://zenodo.org/badge/latestdoi/113447311)

Expand Down
22 changes: 0 additions & 22 deletions circle-build-package

This file was deleted.

6 changes: 6 additions & 0 deletions doc/_sphinxext/releases_hack.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ class release_uri:
def __init__(self, releases_github_path):
self._path = releases_github_path

def __contains__(self, item):
return "%s" in "https://github.com/%s/tree/%s"

def __mod__(self, release):
if release[0].isdigit():
release = "v" + release
return 'https://github.com/%s/tree/%s' % (self._path, release)

def format(self, /, number):
return self.__mod__(number)
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
# If your project is hosted on Github, set the releases_github_path setting instead,
# to e.g. account/project. Releases will then use an appropriate Github URL for both
# releases and issues.
releases_github_path = 'pygae/galgebra'
releases_github_path = "pygae/galgebra"
releases_release_uri = releases_hack.release_uri(releases_github_path)

# You may optionally set releases_debug = True to see debug output while building your docs.
Expand Down
6 changes: 3 additions & 3 deletions doc/readthedocs-pip-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ ipython
matplotlib
scipy

# an unreleased commit that will eventually make the 3.1.0 release, with
# type annotations which work on cached_property
-e git+https://[email protected]/sphinx-doc/sphinx.git@5460ad6925199b57b27b7d059825d3560872edbb#egg=sphinx
## an unreleased commit that will eventually make the 3.1.0 release, with
## type annotations which work on cached_property
#-e git+https://[email protected]/sphinx-doc/sphinx.git@5460ad6925199b57b27b7d059825d3560872edbb#egg=sphinx

ipykernel
nbsphinx
Expand Down
11 changes: 6 additions & 5 deletions galgebra/lt.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,16 +754,17 @@ def __init__(self, f, Ga, nargs=None, fct=False):

else:
if isinstance(f, types.FunctionType): # Tensor defined by general multi-linear function
args, _varargs, _kwargs, _defaults = inspect.getargspec(f)
args = inspect.getfullargspec(f)[0]
self.nargs = len(args)
self.f = f
Mlt.increment_slots(self.nargs, Ga)
self.fvalue = f(*tuple(Ga._mlt_a[0:self.nargs]))
else: # Tensor defined by component expression
self.f = None
self.nargs = len(args)
Mlt.increment_slots(self.nargs, Ga)
self.fvalue = f
raise NotImplementedError
# self.f = None
# self.nargs = len(args) # args isn't defined, which is why we raise NotImplementedError
# Mlt.increment_slots(self.nargs, Ga)
# self.fvalue = f

def __call__(self, *args):
"""
Expand Down
10 changes: 0 additions & 10 deletions readthedocs.yml

This file was deleted.

2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Scientific/Engineering :: Mathematics',
'Topic :: Scientific/Engineering :: Physics',
],
Expand Down
4 changes: 2 additions & 2 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ We are primarily using [nbval](https://github.com/computationalmodelling/nbval)

The test notebooks are used as a recorder of outputs (plain text, color ANSI console output, LaTeX), the author of the test notebook will need to visually inspect the outputs in Jupyter or [nbviewer](https://nbviewer.jupyter.org/) to confirm that GAlgebra is working as expected.

Then `nbval` will be run as a plugin of `pytest` in the CI environment for various versions of Python or even of dependencies to ensure the behavior is identical by checking the actual outputs with the recorded outputs. See `.circleci/config.yml` for up-to-date instructions to run them in CI.
Then `nbval` will be run as a plugin of `pytest` in the CI environment for various versions of Python or even of dependencies to ensure the behavior is identical by checking the actual outputs with the recorded outputs. See `.github/workflows/ci.yml` for up-to-date instructions to run them in CI.

### How to maintain the examples

Expand Down Expand Up @@ -68,4 +68,4 @@ These notebooks are to demonstrate individual scenarios of interest and they are
- `inner_product.ipynb`
- Demo for the definition and semantics of Hestenes' inner product adopted in GAlgebra
- `verify_doc_python.ipynb`
- Unfinished verification for examples in `doc/python/`
- Unfinished verification for examples in `doc/python/`
2 changes: 2 additions & 0 deletions test_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# requirements for CI
wheel
sympy == 1.7
flake8
pytest-cov
ipython == 5.8.0; python_version == "2.7"
nbval
Expand Down

0 comments on commit 225e994

Please sign in to comment.