Skip to content

Commit ad8fce4

Browse files
authored
chore: migrate to Nix-based development and CI workflows [ENG-11657] (#43)
* chore(nix): add flake * chore(ci): migrate to Nix-based CI workflows Migrate all CI workflows to use Nix for consistent, reproducible builds following the pattern from stackone-ai-node repository. Changes: - Add .github/actions/setup-nix for reusable Nix setup - Create unified ci.yml workflow (replaces test.yml and lint.yml) - Add nix-flake.yml for flake validation - Update docs.yml and release.yml to use Nix - Enhance flake.nix shellHook to auto-install dependencies - Remove separate test.yml and lint.yml workflows Benefits: - Consistent environment between local dev and CI - Faster builds with Cachix caching - Single unified CI workflow - Automatic dependency installation via shellHook * chore(nix): migrate to git-hooks.nix and treefmt Replace pre-commit with Nix-native git-hooks.nix and treefmt for better integration with the Nix development environment. Changes: - Add git-hooks.nix and treefmt-nix flake inputs - Configure treefmt with ruff (check + format) and nixfmt - Set up git-hooks with treefmt and mypy pre-commit hooks - Remove .pre-commit-config.yaml - Remove pre-commit from dev dependencies - Update Makefile to remove pre-commit install step - Format code with treefmt (ruff) Benefits: - Consistent formatting via `nix fmt` - Automatic git hook installation in nix develop - No Python-based pre-commit dependency - Faster hook execution - Better Nix ecosystem integration * docs: add Nix installation and development setup to README Add Nix as the recommended development setup with instructions for entering the dev environment, formatting, and running checks. Benefits of using Nix: - Automatic dependency installation - Git hooks auto-configured - Consistent environment across platforms * chore: add .pre-commit-config.yaml to .gitignore This file is auto-generated by git-hooks.nix and should not be tracked. * fix(nix): disable pre-commit check in flake check, keep mypy hook Configure git-hooks to skip the check during 'nix flake check' because mypy requires the Python environment which isn't available in the Nix sandbox. The mypy hook still works locally in 'nix develop' where the Python environment is available. Mypy is also run in CI via ci.yml. Changes: - Set pre-commit.check.enable = false to skip flake check - Keep mypy hook enabled for local development - Treefmt check still runs in flake check * chore: migrate from Makefile to justfile Replace Makefile with justfile for better command runner experience. Add just to Nix devShell for development environment. * chore: enable prettier for markdown/json * chore: format with treefmt Apply consistent formatting across the repository using nix fmt: - YAML files: standardise string quoting to double quotes - Markdown files: add blank lines before lists for proper rendering - Remove trailing whitespace in CLAUDE.md
1 parent d50d5fb commit ad8fce4

File tree

19 files changed

+447
-226
lines changed

19 files changed

+447
-226
lines changed

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: "Setup Nix"
2+
description: "Install Nix and configure Cachix"
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Install Nix
7+
uses: cachix/install-nix-action@0b0e072294b088b73964f1d72dfdac0951439dbd # v31.8.4
8+
with:
9+
github_access_token: ${{ github.token }}
10+
11+
- name: Setup Cachix (numtide)
12+
uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16
13+
with:
14+
name: numtide
15+
authToken: ""
16+
17+
- name: Load Nix development environment
18+
shell: bash
19+
run: nix develop --command true

.github/workflows/ci.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
branches:
7+
- main
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
ci:
18+
runs-on: ubuntu-latest
19+
strategy:
20+
matrix:
21+
python-version: ["3.9", "3.10", "3.13"]
22+
include:
23+
- python-version: "3.9"
24+
sync-extras: "--all-extras --no-extra mcp"
25+
- python-version: "3.10"
26+
sync-extras: "--all-extras"
27+
- python-version: "3.13"
28+
sync-extras: "--all-extras"
29+
env:
30+
STACKONE_API_KEY: ${{ secrets.STACKONE_API_KEY }}
31+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
35+
36+
- name: Setup Nix
37+
uses: ./.github/actions/setup-nix
38+
39+
- name: Install dependencies
40+
run: nix develop --command uv sync ${{ matrix.sync-extras }}
41+
42+
- name: Run Lint
43+
run: nix develop --command uv run ruff check .
44+
45+
- name: Run Mypy
46+
run: |
47+
if [[ "${{ matrix.python-version }}" == "3.9" ]]; then
48+
nix develop --command uv run mypy stackone_ai --exclude stackone_ai/server.py
49+
else
50+
nix develop --command uv run mypy stackone_ai
51+
fi
52+
53+
- name: Run Tests
54+
run: nix develop --command uv run pytest

.github/workflows/docs.yml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,19 @@ jobs:
1212
deploy:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
15+
- name: Checkout repository
16+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1617

17-
- name: Install uv
18-
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v6.6.1
19-
with:
20-
python-version: "3.11"
21-
enable-cache: true
18+
- name: Setup Nix
19+
uses: ./.github/actions/setup-nix
2220

2321
- name: Install all dependencies
24-
run: uv sync --all-extras
22+
run: nix develop --command uv sync --all-extras
2523

2624
- name: Build documentation
2725
run: |
28-
uv run scripts/build_docs.py
29-
uv run mkdocs build
26+
nix develop --command uv run scripts/build_docs.py
27+
nix develop --command uv run mkdocs build
3028
3129
- name: Deploy to GitHub Pages
3230
if: github.ref == 'refs/heads/main'

.github/workflows/lint.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

.github/workflows/nix-flake.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "CI: Flake check"
2+
3+
on:
4+
push:
5+
paths:
6+
- "flake.nix"
7+
- "flake.lock"
8+
- ".github/workflows/nix-flake.yml"
9+
- ".github/actions/setup-nix/**"
10+
pull_request:
11+
paths:
12+
- "flake.nix"
13+
- "flake.lock"
14+
- ".github/workflows/nix-flake.yml"
15+
- ".github/actions/setup-nix/**"
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
# Check flake syntax and structure
23+
flake-check:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
28+
29+
- name: Setup Nix
30+
uses: ./.github/actions/setup-nix
31+
32+
- name: Check flake
33+
run: nix flake check --all-systems --show-trace

.github/workflows/release.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,22 @@ jobs:
2020
manifest-file: .release-please-manifest.json
2121

2222
# Only release to PyPI when a new release is created
23-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
23+
- name: Checkout repository
24+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
2425
if: ${{ steps.release.outputs.release_created }}
2526

26-
- name: Install uv
27+
- name: Setup Nix
2728
if: ${{ steps.release.outputs.release_created }}
28-
uses: astral-sh/setup-uv@557e51de59eb14aaaba2ed9621916900a91d50c6 # v6.6.1
29-
with:
30-
python-version: "3.11"
31-
enable-cache: true
29+
uses: ./.github/actions/setup-nix
3230

3331
- name: Update version in __init__.py
3432
if: ${{ steps.release.outputs.release_created }}
35-
run: |
36-
uv run scripts/update_version.py
33+
run: nix develop --command uv run scripts/update_version.py
3734

3835
- name: Build and publish package
3936
if: ${{ steps.release.outputs.release_created }}
4037
env:
4138
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
4239
run: |
43-
uv build
44-
uv publish
40+
nix develop --command uv build
41+
nix develop --command uv publish

.github/workflows/test.yml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ site/
1515
*.egg-info
1616
dist/
1717
build/
18+
19+
# Git hooks (managed by Nix)
20+
.pre-commit-config.yaml

.pre-commit-config.yaml

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)