Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions .github/workflows/validate-recipe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Validate Recipe
on:
push:
paths:
- 'recipe.yaml'
- 'packaging/recipe.yaml'
pull_request:
paths:
- 'recipe.yaml'
- 'packaging/recipe.yaml'
workflow_dispatch:

jobs:
Expand All @@ -17,15 +17,15 @@ jobs:

- uses: prefix-dev/setup-pixi@v0.9.3
with:
pixi-version: v0.37.0
pixi-version: latest

- name: Install rattler-build
run: pixi global install rattler-build

- name: Validate recipe schema
run: |
pixi exec rattler-build build \
--recipe recipe.yaml \
--recipe packaging/recipe.yaml \
--channel conda-forge \
--channel https://conda.modular.com/max \
--channel https://prefix.dev/modular-community \
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ repos:
- repo: local
hooks:
- id: validate-recipe
name: Validate recipe.yaml schema
name: Validate packaging/recipe.yaml schema
entry: ./scripts/validate-recipe.sh
language: system
files: ^recipe\.yaml$
files: ^packaging/recipe\\.yaml$
pass_filenames: false
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Changed
- Bumped MAX / Mojo toolchain dependency to `max ">=26.1.0,<27"` and updated recipes to pin `mojo_version = "=0.26.1"`.
- Updated parser string handling to use `codepoint_slices()` and `List[String]` helpers instead of direct `String` indexing, matching Mojo 0.26.1 `__getitem__` semantics while preserving python-dotenv compatibility.
- Adopted a "no warnings" policy for the core library and tests so future migrations surface only new issues.
- Migrated workspace/runtime dependencies and recipe compiler pins to Mojo `1.0.0`.
- Updated source/tests/examples/packaging from legacy `fn` syntax and older imports to Mojo 1.0-compatible forms (`def`, `std.pathlib`, `std.os`, `std.python`).
- Fixed UTF-8-safe string handling for Mojo 1.0 by replacing `len(String)` and direct string slicing with explicit APIs (`byte_length()`, `s[byte=...]`).
- Added missing `raises` annotations through test call chains to satisfy Mojo 1.0 checked-raises behaviour.
- Revalidated migration with `pixi run test-all` (all 11 suites passing) and `pixi run build-package` (success with warnings only).

### Planned for v0.3.0
- Multiple .env file support with precedence handling
Expand Down
30 changes: 15 additions & 15 deletions RECIPE_SETUP.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Recipe Validation Setup - Quick Start

Your mojo-toml repo now has local validation tools that match modular-community CI exactly.
Your mojo-dotenv repo now has local validation tools that match modular-community CI exactly.

## ✅ What's Been Added

Expand All @@ -13,7 +13,7 @@ Your mojo-toml repo now has local validation tools that match modular-community
- Auto-validates on push/PR
- Shows results in Actions tab

3. **recipe.yaml** - Root-level recipe file
3. **packaging/recipe.yaml** - Canonical recipe file
- Validated schema (tests:, documentation:, repository:)
- Mojo 0.25.7 with context variables
- Ready for modular-community submission
Expand All @@ -28,14 +28,14 @@ Your mojo-toml repo now has local validation tools that match modular-community
### Validate Locally (Before Committing)

```bash
cd /Users/mjboothaus/code/github/databooth/mojo-toml
./scripts/validate-recipe.sh recipe.yaml
cd /Users/mjboothaus/code/github/databooth/mojo-dotenv
./scripts/validate-recipe.sh packaging/recipe.yaml
```

**Expected output:**
```
✅ Recipe validation passed!
Your recipe.yaml follows the modular-community schema.
Your packaging/recipe.yaml follows the modular-community schema.
```

### Update Other Packages
Expand All @@ -49,13 +49,13 @@ cp .github/workflows/validate-recipe.yml ../mojo-yaml/.github/workflows/
cp docs/RECIPE_VALIDATION.md ../mojo-yaml/docs/

# Copy recipe from modular-community (already validated)
cp /path/to/modular-community/recipes/mojo-yaml/recipe.yaml ../mojo-yaml/
cp /path/to/modular-community/recipes/mojo-yaml/recipe.yaml ../mojo-yaml/packaging/recipe.yaml
```

### Automated Validation

The GitHub Actions workflow runs automatically when `recipe.yaml` changes. View results at:
`https://github.com/DataBooth/mojo-toml/actions`
The GitHub Actions workflow runs automatically when `packaging/recipe.yaml` changes. View results at:
`https://github.com/DataBooth/mojo-dotenv/actions`

## 📋 Integration Options

Expand All @@ -67,10 +67,10 @@ Add to `.pre-commit-config.yaml`:
- repo: local
hooks:
- id: validate-recipe
name: Validate recipe.yaml
name: Validate packaging/recipe.yaml
entry: ./scripts/validate-recipe.sh
language: system
files: ^recipe\.yaml$
files: ^packaging/recipe\\.yaml$
pass_filenames: false
```

Expand All @@ -82,7 +82,7 @@ Add to `justfile`:

```just
validate-recipe:
./scripts/validate-recipe.sh recipe.yaml
./scripts/validate-recipe.sh packaging/recipe.yaml
```

Usage: `just validate-recipe`
Expand All @@ -93,15 +93,15 @@ Add to `pixi.toml`:

```toml
[tasks]
validate-recipe = "./scripts/validate-recipe.sh recipe.yaml"
validate-recipe = "./scripts/validate-recipe.sh packaging/recipe.yaml"
```

Usage: `pixi run validate-recipe`

## 🔄 Workflow

1. **Update recipe.yaml** - Make your changes
2. **Validate locally** - `./scripts/validate-recipe.sh recipe.yaml`
1. **Update packaging/recipe.yaml** - Make your changes
2. **Validate locally** - `./scripts/validate-recipe.sh packaging/recipe.yaml`
3. **Fix issues** - If validation fails
4. **Commit** - Once validation passes
5. **Submit PR** - To modular-community with confidence
Expand All @@ -124,7 +124,7 @@ See `docs/RECIPE_VALIDATION.md` for:

## 🔗 Next Steps

1. Test validation: `./scripts/validate-recipe.sh recipe.yaml`
1. Test validation: `./scripts/validate-recipe.sh packaging/recipe.yaml`
2. Add to pre-commit: Edit `.pre-commit-config.yaml`
3. Replicate to other packages: Copy files as shown above
4. Read full guide: `docs/RECIPE_VALIDATION.md`
31 changes: 31 additions & 0 deletions docs/JUST_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Just setup
This repository uses `just` to expose self-documented workflows.

## What is Just?
Just is a command runner similar to `make`, with a simpler syntax.

Official site:
- https://just.systems

Installation instructions:
- https://just.systems/man/en/chapter_4.html

Install options:
- macOS (Homebrew): `brew install just`
- Linux (Cargo): `cargo install just`
- Windows (Chocolatey): `choco install just`
- Windows (Scoop): `scoop install just`

## Quick start
From the repository root:

```shell
just --list
```

## Key recipes
- `just pixi-tasks`
- `just test`
- `just build`
- `just examples`
- `just run <task>`
4 changes: 2 additions & 2 deletions docs/PLATFORM_BUILDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ All your mojo-* packages contain **pure Mojo source code** with no platform-spec

### What You're Running Locally
When you run `./scripts/validate-recipe.sh`, it performs:
- **Schema validation** - Checks recipe.yaml structure
- **Schema validation** - Checks `packaging/recipe.yaml` structure
- **Dependency resolution** - Verifies channels and requirements
- **Render-only mode** - Doesn't actually compile/build

Expand Down Expand Up @@ -114,7 +114,7 @@ build:
```bash
docker run -it --rm -v $(pwd):/workspace condaforge/miniforge3:latest bash
cd /workspace
./scripts/validate-recipe.sh recipe.yaml
./scripts/validate-recipe.sh packaging/recipe.yaml
```

### Test on Linux (via GitHub Actions)
Expand Down
26 changes: 13 additions & 13 deletions docs/RECIPE_VALIDATION.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Recipe Validation for modular-community

This guide explains how to validate your `recipe.yaml` locally before submitting to modular-community, ensuring it passes CI on the first try.
This guide explains how to validate your `packaging/recipe.yaml` locally before submitting to modular-community, ensuring it passes CI on the first try.

## Why Validate Locally?

Expand All @@ -27,27 +27,27 @@ modular-community uses `rattler-build` to parse and build packages. Running the
Run the validation script from your package root:

```bash
./scripts/validate-recipe.sh recipe.yaml
./scripts/validate-recipe.sh packaging/recipe.yaml
```

This runs the exact same validation as modular-community CI in `--render-only` mode (no actual build).

**Example output:**
```
🔍 Validating recipe.yaml against modular-community schema...
🔍 Validating packaging/recipe.yaml against modular-community schema...

🏗️ Running rattler-build validation...
✅ Recipe validation passed!

Your recipe.yaml follows the modular-community schema.
Your packaging/recipe.yaml follows the modular-community schema.
It should pass CI when submitted.
```

### Method 2: GitHub Actions (Automated)

The `.github/workflows/validate-recipe.yml` workflow runs automatically when you:
- Push changes to `recipe.yaml`
- Create a PR that modifies `recipe.yaml`
- Push changes to `packaging/recipe.yaml`
- Create a PR that modifies `packaging/recipe.yaml`

View results in the "Actions" tab of your repo.

Expand All @@ -57,7 +57,7 @@ For advanced users who want full control:

```bash
pixi exec rattler-build build \
--recipe recipe.yaml \
--recipe packaging/recipe.yaml \
--channel conda-forge \
--channel https://conda.modular.com/max \
--channel https://prefix.dev/modular-community \
Expand Down Expand Up @@ -123,10 +123,10 @@ repos:
- repo: local
hooks:
- id: validate-recipe
name: Validate recipe.yaml
name: Validate packaging/recipe.yaml
entry: ./scripts/validate-recipe.sh
language: system
files: ^recipe\.yaml$
files: ^packaging/recipe\\.yaml$
pass_filenames: false
```

Expand All @@ -137,9 +137,9 @@ Then install: `pre-commit install`
Add to `justfile`:

```just
# Validate recipe.yaml against modular-community schema
# Validate packaging/recipe.yaml against modular-community schema
validate-recipe:
./scripts/validate-recipe.sh recipe.yaml
./scripts/validate-recipe.sh packaging/recipe.yaml
```

Usage: `just validate-recipe`
Expand All @@ -150,7 +150,7 @@ Add to `pixi.toml`:

```toml
[tasks]
validate-recipe = "./scripts/validate-recipe.sh recipe.yaml"
validate-recipe = "./scripts/validate-recipe.sh packaging/recipe.yaml"
```

Usage: `pixi run validate-recipe`
Expand All @@ -172,7 +172,7 @@ Read the error output carefully - it tells you exactly which line/field is probl
### Need more details?
Run with verbose output:
```bash
RATTLER_BUILD_LOG=debug ./scripts/validate-recipe.sh recipe.yaml
RATTLER_BUILD_LOG=debug ./scripts/validate-recipe.sh packaging/recipe.yaml
```

## Reference
Expand Down
2 changes: 1 addition & 1 deletion docs/pixi-pre-submit.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ There are two equivalent tasks:
Both run `python scripts/pre_submit_checklist.py`, which performs:

1. **Tests** – `pixi run test-all` for the full test suite.
2. **Recipe validation** – `./scripts/validate-recipe.sh recipe.yaml` against the modular-community schema.
2. **Recipe validation** – `./scripts/validate-recipe.sh packaging/recipe.yaml` against the modular-community schema.
3. **Package build** – `./scripts/build-recipe.sh`, using `rattler-build` with tests disabled (tests are already covered by `test-all`).
4. **Git tag check** – ensures a `v<version>` tag exists and matches `HEAD`.
5. **Install check** – creates a temporary pixi project, adds a file:// channel pointing at `output/`, and verifies that the built package can be installed and that the expected files appear under `.pixi/envs/default/lib/mojo`.
Expand Down
4 changes: 2 additions & 2 deletions examples/simple.mojo
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Simple example using mojo-dotenv."""

from dotenv import dotenv_values, load_dotenv
from os import getenv
from std.os import getenv


fn main() raises:
def main() raises:
print("=" * 60)
print("mojo-dotenv Example")
print("=" * 60)
Expand Down
17 changes: 17 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
default:
@just --list

pixi-tasks:
@pixi task list

run task:
pixi run {{task}}

test:
pixi run test-all

build:
pixi run build-package

examples:
pixi run examples-all
Loading
Loading