Skip to content

Commit

Permalink
🧪 Add CI test workflow (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell authored Jan 24, 2024
1 parent fb40780 commit 06fb5dd
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 10 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: continuous-integration

on:
push:
branches: [main]
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
pull_request:

jobs:

docs-html:

name: Build docs (sphinx${{matrix.sphinx}})

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
sphinx: ["", "~=7.0", "~=6.0", "~=5.0"]

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install sphinx${{matrix.sphinx}} -e ".[docs]"
- name: Run sphinx-build
run: sphinx-build -nW --keep-going -b html docs/ docs/_build/html

check:
# https://github.com/marketplace/actions/alls-green#why
# This job does nothing and is only used for the branch protection

if: always()

needs:
- docs-html

runs-on: ubuntu-latest

steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}


publish:

name: Publish to PyPI
needs:
- check
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: install flit
run: |
pip install flit~=3.4
- name: Build and publish
run: |
flit publish
env:
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ secrets.PYPI_KEY }}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pre-commit install
To build the documentation via `tox`, install it and run:

```bash
tox -e docs
tox -e docs-sphinx-latest
```

## Running the tests
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ that can be clicked to peek at the target of the reference.

See documentation at <https://sphinx-peek.readthedocs.io/>


## Development notes

Yet another sphinx-extension for previewing links!
Expand Down
6 changes: 3 additions & 3 deletions src/sphinx_peek/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def setup(app: Sphinx) -> dict[str, Any]:
# only if in _static folder
for asset_js in assets.glob("*.js"):
app.add_js_file(asset_js.name)
copy_asset(asset_js, Path(app.outdir, "_static"))
copy_asset(str(asset_js), Path(app.outdir, "_static"))
for asset_css in assets.glob("*.css"):
app.add_css_file(asset_css.name)
copy_asset(asset_css, Path(app.outdir, "_static"))
copy_asset(str(asset_css), Path(app.outdir, "_static"))

# add a private directive to document the configuration
app.add_directive("peek-config", PeekConfigDirective)
Expand Down Expand Up @@ -68,7 +68,7 @@ class PeekConfig:
preview_height: int = f("Height of preview window", 300)
offset_x: int = f("Distance of preview window from icon (horizontal)", 20)
offset_y: int = f("Distance of preview window from icon (vertical)", 20)
open_delay: int = f("Delay (milliseconds) before opening preview window", 50)
open_delay: int = f("Delay (milliseconds) before displaying preview window", 100)

@classmethod
def from_config(cls, config: Config) -> PeekConfig:
Expand Down
15 changes: 9 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ envlist = py38-sphinx-latest
[testenv]
usedevelop = true

[testenv:py{37,38,39,310,311}-sphinx-{5,6,7,8,latest}]
[testenv:py{37,38,39,310,311}-sphinx-{5,6,7,latest}]
deps =
sphinx5: sphinx>=5,<6
sphinx6: sphinx>=6,<7
sphinx7: sphinx>=7,<8
sphinx8: sphinx>=8,<9
sphinx-5: sphinx>=5,<6
sphinx-6: sphinx>=6,<7
sphinx-7: sphinx>=7,<8
extras =
testing
commands = pytest {posargs}

[testenv:docs]
[testenv:docs-sphinx-{5,6,7,latest}]
deps =
sphinx-5: sphinx>=5,<6
sphinx-6: sphinx>=6,<7
sphinx-7: sphinx>=7,<8
extras =
docs
passenv =
Expand Down

0 comments on commit 06fb5dd

Please sign in to comment.