Skip to content

Commit

Permalink
testing out uv
Browse files Browse the repository at this point in the history
  • Loading branch information
aceat64 committed Aug 22, 2024
1 parent dbb9a98 commit 92b536a
Show file tree
Hide file tree
Showing 8 changed files with 674 additions and 1,141 deletions.
53 changes: 29 additions & 24 deletions .github/workflows/pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,49 +19,54 @@ jobs:
# Running this action on a fork will likely fail anyway
# unless the forked repo also has access to material for mkdocs insiders
if: github.event.repository.fork == false

env:
# Configure a constant location for the uv cache
UV_CACHE_DIR: /tmp/.uv-cache

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: sudo apt-get install pngquant
- name: Set up uv
# Install a specific uv version using the installer
run: curl -LsSf https://astral.sh/uv/0.3.1/install.sh | sh

- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"

- name: Restore uv cache
uses: actions/cache@v4
with:
path: /tmp/.uv-cache
key: uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
restore-keys: |
uv-${{ runner.os }}-${{ hashFiles('uv.lock') }}
uv-${{ runner.os }}
- name: Install the project
run: uv sync --all-extras --dev

# The .cache directory is used for 3rd party assets, as part of the privacy plugin.
# It is also used to cache the generated social media cards.
# Persisting the cache across builds dramatically speeds up the process.
- name: Load site cache
uses: actions/cache@v4
with:
key: ${{ github.ref }}
key: mkdocs
path: .cache

# We use poetry to manage mkdocs, plugins, etc
- name: Install poetry
run: pipx install poetry

- name: Setup Python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: "3.12"
# This ensures the package cache for poetry/pip is persisted, again speeding up this build action.
cache: "poetry"

# Insiders is the sponsorware version of Material for MkDocs
# https://squidfunk.github.io/mkdocs-material/insiders/
- name: Configure auth for Insiders
run: |
poetry config repositories.github-squidfunk-mkdocs https://github.com/squidfunk/mkdocs-material-insiders.git
poetry config http-basic.github-squidfunk-mkdocs username ${{ secrets.GH_TOKEN }}
- name: Install deps
run: poetry install
- name: Build site
run: poetry run mkdocs build
run: uv run mkdocs build

# Upload the built site as an artifact, this will be used by the deploy job.
- uses: actions/upload-pages-artifact@v3
with:
path: "site"

- name: Minimize uv cache
run: uv cache prune --ci
deploy:
needs: build

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.cache/
.mypy_cache/
site/
site/
.venv/
8 changes: 4 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"search.exclude": {
"**/material": true,
"**/node_modules": true,
"**/package-lock.json": true
"**/.cache": true,
"**/.venv": true,
"**/site": true,
"**/uv.lock": true
},
"search.followSymlinks": false,
"typescript.tsdk": "node_modules/typescript/lib",
"yaml.schemas": {
"https://squidfunk.github.io/mkdocs-material/schema.json": "mkdocs.yml"
},
Expand Down
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"label": "Build",
"type": "shell",
"command": "poetry run mkdocs build",
"command": "uv run mkdocs build",
"group": "build",
"presentation": {
"reveal": "silent"
Expand All @@ -13,7 +13,7 @@
{
"label": "Start and watch for changes",
"type": "shell",
"command": "poetry run mkdocs serve",
"command": "uv run mkdocs serve",
"isBackground": true,
"group": "build",
"presentation": {
Expand Down
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,37 @@ This is my personal website, so all opinions are my own. I made it to better doc

Note: Since I use the Insiders version of Material for MkDocs, you will not able to run this locally unless you are also a sponsor of the project.

Requires [Poetry](https://python-poetry.org/), Python 3.11 or higher and a GitHub personal access token (`$GH_TOKEN`). I recommend using `pyenv` to install Python.
I'm currently testing out [uv](https://docs.astral.sh/uv/getting-started/installation/) for managing dependencies, virtual environments and Python versions.

### Configure access to Insiders
### Dev Server

```shell
poetry config repositories.github-squidfunk-mkdocs https://github.com/squidfunk/mkdocs-material-insiders.git
poetry config http-basic.github-squidfunk-mkdocs username $GH_TOKEN
uv run mkdocs serve
```

### Dev Server
### Build Site

```shell
poetry run mkdocs serve
uv run mkdocs build
```

### Build Site
### Troubleshooting

On my mac, I needed install cairo (`brew install cairo`) and add the following to `~/.zshrc`:

```shell
poetry run mkdocs build
# Needed to let python know where some libs are
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/opt/homebrew/lib/pkgconfig:$PKG_CONFIG_PATH"
export DYLD_LIBRARY_PATH="/usr/local/lib:/opt/homebrew/lib:$DYLD_LIBRARY_PATH"
```

### Dependabot

Dependabot doesn't support `uv` yet:

- <https://github.com/dependabot/dependabot-core/issues/10039>
- <https://github.com/dependabot/dependabot-core/issues/10478>

## Copyright

Copyright (c) 2022-2024 Andrew LeCody
Expand Down
Loading

0 comments on commit 92b536a

Please sign in to comment.