Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate project setup to pixi #10

Merged
merged 11 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# GitHub syntax highlighting
pixi.lock linguist-language=YAML linguist-generated=true
15 changes: 7 additions & 8 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
- package-ecosystem: github-actions
directory: /
schedule:
interval: "weekly"
interval: monthly
groups:
actions:
patterns:
- "*"
45 changes: 45 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build package

on:
push:
branches:
- main
tags:
- v*
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Setup pixi
uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659 # v0.8.1
with:
environments: build
- name: Build package
run: |
pixi run -e build python -m build --no-isolation .
- name: Upload package
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: artifact
path: dist/*
if-no-files-found: error

release:
name: Publish package
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
needs: [build]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
environment: pypi
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mscolnick you need to create a github environment for this: https://github.com/marimo-team/mkdocs-marimo/settings/environments/new

feel free to add proper protection rules there

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be gated until i make this repo public, but will do once we make it public.

steps:
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: artifact
path: dist
- name: Publish package on PyPi
uses: pypa/gh-action-pypi-publish@f7600683efdcb7656dec5b29656edb7bc586e597 # v1.10.3
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mscolnick you need to add OIDC trusted publishers in the pypi package for this package to be able to upload tokenless.

https://pypi.org/manage/project/mkdocs-marimo/settings/publishing/

Owner: marimo-team
Repository name: mkdocs-marimo
Workflow name: build.yml
Environment name: pypi

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you will do!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

55 changes: 27 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,47 @@
name: CI

on: [push, pull_request]
on:
push:
branches:
- main
pull_request:

jobs:
test:
strategy:
max-parallel: 5
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
os: [ubuntu-latest, windows-latest, macos-latest]
# Just to slim down the test matrix:
exclude:
- python-version: 3.9
os: ubuntu-latest
- python-version: 3.10
os: macos-latest
- python-version: 3.10
os: windows-latest
env:
- py39
- py310
- py311
- py312
os:
- ubuntu-latest
- windows-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Setup pixi
uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659 # v0.8.1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
environments: ${{ matrix.env }}
- name: Install repository
run: |
python -m pip install --upgrade hatch
pixi run -e ${{ matrix.env }} postinstall
- name: Run tests
run: |
hatch run +py=${{ matrix.py || matrix.python-version }} test:test
shell: bash
pixi run -e ${{ matrix.env }} test

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Setup pixi
uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659 # v0.8.1
with:
python-version: '3.12'
- name: Install Python dependencies
environments: lint default
- name: Lint
run: |
python -m pip install hatch
- name: Check style
if: always()
run: hatch run style:check
pixi run lint-all-check
28 changes: 0 additions & 28 deletions .github/workflows/deploy-release.yml

This file was deleted.

17 changes: 9 additions & 8 deletions .github/workflows/deploy-docs.yml → .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,27 @@ on:
push:
branches:
- main
pull_request:

jobs:
build:
name: Deploy docs
runs-on: ubuntu-latest
steps:
- name: Download source
uses: actions/checkout@v3
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Install Python
uses: actions/setup-python@v4
uses: prefix-dev/setup-pixi@ba3bb36eb2066252b2363392b7739741bb777659 # v0.8.1
with:
python-version: '3.x'
- name: Install Python dependencies
run: |
python -m pip install --upgrade hatch
environments: docs
- name: Install repository
run: pixi run -e docs postinstall
- name: Build site
run: hatch -e doc run mkdocs build
run: pixi run -e docs mkdocs build
- name: Deploy to gh-pages
# TODO: replace with a maintained action
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: oprypin/push-to-gh-pages@v3
with:
publish_dir: site
commit_message: 'Generate docs: '
commit_message: 'Generate docs: '
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ site/
.pytest_cache/
.venv/
__pycache__/
.pixi
24 changes: 0 additions & 24 deletions Makefile

This file was deleted.

10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,19 @@ Feel free to ask questions, enhancements and to contribute to this project!

## Development

Install `hatch`:

- for macOS: `brew install hatch`
Install `pixi`: see [pixi docs](https://pixi.sh)

Run the tests:

```bash
hatch run test:test
hatch run style:check
pixi run postinstall
pixi run test
```

Serve the documentation:

```bash
hatch run doc:serve
pixi run docs
```

## Credits
Expand Down
4 changes: 3 additions & 1 deletion docs/getting-started/installation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Installation

Add `mkdocs-marimo` to your `pyproject.toml` or `requirements.txt` file or simply install it using `pip`. The plugin will automatically install the minimally required version of `mkdocs` it is compatible with.
Add `mkdocs-marimo` to your `pyproject.toml` or `requirements.txt` file or simply install it using `pip` or `pixi`. The plugin will automatically install the minimally required version of `mkdocs` it is compatible with.

```bash
pip install mkdocs-marimo
# or
pixi add mkdocs-marimo
```
9 changes: 8 additions & 1 deletion mkdocs_marimo/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
version = "0.1.0"
import importlib.metadata
import warnings

try:
__version__ = importlib.metadata.version(__name__)
except importlib.metadata.PackageNotFoundError as e:
warnings.warn(f"Could not determine version of {__name__}\n{e!s}", stacklevel=2)
__version__ = "unknown"
2 changes: 1 addition & 1 deletion mkdocs_marimo/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def match_equal(first: re.Match[str], second: re.Match[str]) -> bool:
def marimo_repl(match: re.Match[str], outputs: list[Any]) -> str:
if is_inside_four_backticks(markdown, match.start()):
return match.group(0)
options = match.group(1)
options = match.group(1) # noqa: F841
index = next(i for i, m in enumerate(matches) if match_equal(m, match))
output = outputs[index]
html = output.render()
Expand Down
Loading
Loading