Skip to content

Commit

Permalink
Simplify build system and revert mkdocs (#45)
Browse files Browse the repository at this point in the history
* Move to hatch
* Revert: Move documentation from sphinx to mkdocs
  • Loading branch information
dirmeier authored Jul 20, 2024
1 parent 3b472b1 commit a3c7370
Show file tree
Hide file tree
Showing 45 changed files with 764 additions and 532 deletions.
6 changes: 0 additions & 6 deletions .bumpversion.cfg

This file was deleted.

102 changes: 62 additions & 40 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ on:
branches: [ main ]

jobs:
build:
precommit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: pre-commit/[email protected]

lint:
name: lints
build:
runs-on: ubuntu-latest
needs:
- build
- precommit
strategy:
matrix:
python-version: [3.11]
Expand All @@ -30,58 +29,81 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install tox
- name: Run format, lints and types
pip install hatch
- name: Build package
run: |
tox -e format,lints,types
hatch build
test:
name: unit tests
lints:
runs-on: ubuntu-latest
needs:
- build
- precommit
strategy:
matrix:
python-version: [3.11]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install tox
- name: Run tests and coverage
run: |
tox -e tests
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Run codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage.xml
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install hatch
- name: Run lints
run: |
hatch run test:lints
tests:
runs-on: ubuntu-latest
needs:
- lints
strategy:
matrix:
python-version: [3.11]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install hatch
- name: Build package
run: |
pip install jaxlib==0.4.24 jax==0.4.24
- name: Run tests
run: |
hatch run test:tests
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

examples:
name: examples
runs-on: ubuntu-latest
needs:
- test
strategy:
matrix:
python-version: [3.11]
steps:
runs-on: ubuntu-latest
needs:
- tests
strategy:
matrix:
python-version: [3.11]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install tox
pip install hatch
- name: Build package
run: |
pip install jaxlib==0.4.24 jax==0.4.24
- name: Run examples
run: |
tox -e examples
hatch run test:examples
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
11 changes: 0 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/pycqa/bandit
rev: 1.7.1
hooks:
- id: bandit
language: python
language_version: python3
types: [python]
args: ["-c", "pyproject.toml"]
additional_dependencies: ["toml"]
files: "(ramsey|examples)"

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.910-1
hooks:
Expand Down
6 changes: 4 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ build:
tools:
python: "3.11"

mkdocs:
configuration: mkdocs.yaml
sphinx:
builder: html
configuration: docs/conf.py
fail_on_warning: false

python:
install:
Expand Down
23 changes: 20 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
PKG_VERSION=`python setup.py --version`
.PHONY: tag, tests, lints, docs, format, examples

PKG_VERSION=`hatch version`

tag:
git tag -a "v$(PKG_VERSION)" -m "v$(PKG_VERSION)"
git push --tag
git tag -a v${PKG_VERSION} -m v${PKG_VERSION}
git push --tag

tests:
hatch run test:tests

lints:
hatch run test:lints

format:
hatch run test:format

docs:
cd docs && make html

examples:
hatch run test:examples
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Ramsey

[![active](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![ci](https://github.com/dirmeier/ramsey/actions/workflows/ci.yaml/badge.svg)](https://github.com/dirmeier/ramsey/actions/workflows/ci.yaml)
[![codecov](https://codecov.io/gh/ramsey-devs/ramsey/branch/main/graph/badge.svg?token=dn1xNBSalZ)](https://codecov.io/gh/ramsey-devs/ramsey)
[![Codacy quality](https://app.codacy.com/project/badge/Grade/ed13460537fd4ac099c8534b1d9a0202)](https://app.codacy.com/gh/ramsey-devs/ramsey/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![ci](https://github.com/ramsey-devs/ramsey/actions/workflows/ci.yaml/badge.svg)](https://github.com/ramsey-devs/ramsey/actions/workflows/ci.yaml)
[![coverage](https://codecov.io/gh/ramsey-devs/ramsey/branch/main/graph/badge.svg?token=dn1xNBSalZ)](https://codecov.io/gh/ramsey-devs/ramsey)
[![quality](https://app.codacy.com/project/badge/Grade/ed13460537fd4ac099c8534b1d9a0202)](https://app.codacy.com/gh/ramsey-devs/ramsey/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
[![documentation](https://readthedocs.org/projects/ramsey/badge/?version=latest)](https://ramsey.readthedocs.io/en/latest/?badge=latest)
[![version](https://img.shields.io/pypi/v/ramsey.svg?colorB=black&style=flat)](https://pypi.org/project/ramsey/)

Expand Down Expand Up @@ -80,8 +80,11 @@ Contributions in the form of pull requests are more than welcome. A good way to

In order to contribute:

1) Install Ramsey and dev dependencies via `pip install -e '.[dev]'`,
2) test your contribution/implementation by calling `tox` on the (Unix) command line before submitting a PR.
1) Clone Ramsey and install the package manager `hatch` via `pip install hatch`,
2) create a new branch locally `git checkout -b feature/my-new-feature` or `git checkout -b issue/fixes-bug`,
3) implement your contribution and ideally a test case,
4) test it by calling `make format`, `make lints` and `make tests` on the (Unix) command line,
5) submit a PR 🙂

## Why Ramsey

Expand Down
21 changes: 21 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Minimal makefile for Sphinx documentation

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = ./
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
rm -rf build
rm -rf source/examples
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 changes: 14 additions & 0 deletions docs/_pygments/style.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from pygments.style import Style
from pygments.token import Error, Text, Whitespace, Other


class MyStyle(Style):
background_color = "black"
highlight_color = "#49483e"

styles = {
Text: "#f8f8f2", # class: ''
Whitespace: "", # class: 'w'
Error: "#960050 bg:#1e0010", # class: 'err'
Other: "", # class 'x'
}
84 changes: 76 additions & 8 deletions docs/_static/theme.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,79 @@
:root {
--md-primary-fg-color: #b26679;
--md-primary-bg-color: #ffe9dd;
--pst-color-secondary: rgb(121, 40, 161);
--pst-color-inline-code-links: rgb(121, 40, 161);
--md-accent-fg-color: rgb(121, 40, 161);
html[data-theme="light"] {
--pst-color-primary: rgb(121, 40, 161);
--pst-color-secondary: #b26679;
--pst-color-inline-code-links: #b26679;
}

html {
font-size: 130%;
pre > span {
line-height: 20px;
}

span.kn {
color: rgb(0, 120, 161) !important;
}

span.ml, span.mi, span.nb {
color: lightcoral !important;
}

span.k, span.nn {
color: rgb(168, 70, 185) !important;
}

h1 > code > span {
font-weight: 700 !important;
}

pre {
border: 0;
font-size: 13px;
background-color: rgb(245, 245, 245) !important;
}

h1 {
margin-bottom: 50px;
}
h3, h2, h1 {
font-weight: 300 !important;
}

nav > li > a > code.literal {
padding-top: 0;
padding-bottom: 0;
background-color: white;
border: 0;
}

nav.bd-links p.caption {
text-transform: uppercase;
}

code.literal {
background-color: white;
border: 0;
border-radius: 0;
}

a > code {
font-weight: 575;
}

a:hover {
text-decoration-thickness: 1px !important;
}

ul.bd-breadcrumbs li.breadcrumb-item a:hover {
text-decoration-thickness: 1px;
}

nav.bd-links li > a:hover {
text-decoration-thickness: 1px;
}

.prev-next-area a p.prev-next-title {
text-decoration: none !important;
}

button.theme-switch-button {
display: none !important;
}
Loading

0 comments on commit a3c7370

Please sign in to comment.