Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f181557dc4 | |||
| f77c9657a3 | |||
| f908f969d3 | |||
| 3cf49c5479 | |||
| b34354f5e5 | |||
| 44826464de | |||
| 3de0ffccb0 | |||
| c6c98b3e26 | |||
| d459f3d675 | |||
| 33e4b37cce | |||
| 2a8e7e7f2b | |||
| 07759353be | |||
| 38fb14520e | |||
| 006ae6079a |
@@ -1,6 +1,7 @@
|
||||
name: pytest
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
@@ -8,6 +8,7 @@ jobs:
|
||||
lockfile:
|
||||
runs-on: self-hosted
|
||||
permissions:
|
||||
actions: write
|
||||
contents: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
|
||||
Generated
+42
-26
@@ -8,11 +8,11 @@
|
||||
},
|
||||
"locked": {
|
||||
"dir": "pkgs/firefox-addons",
|
||||
"lastModified": 1778385775,
|
||||
"narHash": "sha256-n0MUvWA2SML/qBB4hpShQ7i+i961MX4oPtaQfYo0+uU=",
|
||||
"lastModified": 1781270820,
|
||||
"narHash": "sha256-KuDdN/p4UtqUb1wnjo8a/YougmRXEaKvUoGHkYnuAq0=",
|
||||
"owner": "rycee",
|
||||
"repo": "nur-expressions",
|
||||
"rev": "268324916742a48cd03b94fd63f2822d6b66d519",
|
||||
"rev": "5f4259c0c832a93e13c5ec481d3318ce1394a8f9",
|
||||
"type": "gitlab"
|
||||
},
|
||||
"original": {
|
||||
@@ -29,11 +29,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1778365864,
|
||||
"narHash": "sha256-ImoT/wqmgMImf2dAC+E0MverAdA4QXsedOeES9B7Ezw=",
|
||||
"lastModified": 1781305496,
|
||||
"narHash": "sha256-g8Vv4Qfc7n+lgov97REu3X6BeJtvYY0hlSUZR1GrGQQ=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "2f419037039a152448c5f4ae9494154753d1b399",
|
||||
"rev": "c87a39aa979acc4848016d2220c6238390d84779",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -43,12 +43,15 @@
|
||||
}
|
||||
},
|
||||
"nixos-hardware": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1778143761,
|
||||
"narHash": "sha256-lkesY6x2X2qxlqLM7CT2iM/0rP2JB7fruPN3h8POXmI=",
|
||||
"lastModified": 1781168557,
|
||||
"narHash": "sha256-LOnLQ2tpYF9gqIDDr3+j3DbpJJr/QCH6zPRT2GzEUOE=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixos-hardware",
|
||||
"rev": "3bcaa367d4c550d687a17ac792fd5cda214ee871",
|
||||
"rev": "6358ff76821101c178e3ab4919a62799bfe3652e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -60,27 +63,24 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1777954456,
|
||||
"narHash": "sha256-hGdgeU2Nk87RAuZyYjyDjFL6LK7dAZN5RE9+hrDTkDU=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "549bd84d6279f9852cae6225e372cc67fb91a4c1",
|
||||
"type": "github"
|
||||
"lastModified": 1767892417,
|
||||
"narHash": "sha256-8bW3q88CEg2u4hSP66Vf4lpbLonHz7hqDNBMcCY7E9U=",
|
||||
"rev": "3497aa5c9457a9d88d71fa93a4a8368816fbeeba",
|
||||
"type": "tarball",
|
||||
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.05pre924538.3497aa5c9457/nixexprs.tar.xz"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
"type": "tarball",
|
||||
"url": "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz"
|
||||
}
|
||||
},
|
||||
"nixpkgs-master": {
|
||||
"locked": {
|
||||
"lastModified": 1778434251,
|
||||
"narHash": "sha256-TznExR00uHvyeJsQW9cy8aBCW8W8sIvhzoVjAQTEyiw=",
|
||||
"lastModified": 1781306963,
|
||||
"narHash": "sha256-qWZ+XEwsf8pN4DnYyyLbmAyj1a74gOO/VNCff44MuB4=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "4f90e32d9c535072f0a6a9ac4599f1e78b829eab",
|
||||
"rev": "1eee1a273e2e3fdc3db5b1a4a66f06cd5749db69",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -106,12 +106,28 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1781074563,
|
||||
"narHash": "sha256-md8WlXOlfnIeHeOScMTTHFyf2d6iaTwPl2apR5EQ3P4=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9ae611a455b90cf061d8f332b977e387bda8e1ca",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"firefox-addons": "firefox-addons",
|
||||
"home-manager": "home-manager",
|
||||
"nixos-hardware": "nixos-hardware",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"nixpkgs-master": "nixpkgs-master",
|
||||
"nixpkgs-stable": "nixpkgs-stable",
|
||||
"sops-nix": "sops-nix",
|
||||
@@ -125,11 +141,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1777944972,
|
||||
"narHash": "sha256-VfGRo1qTBKOe3s2gOv8LSoA6Fk19PvBlwQ1ECN0Evn8=",
|
||||
"lastModified": 1780547341,
|
||||
"narHash": "sha256-Gq8KNx5A7hBB3uGJaj6eQfLDIz5YdLu92gqBcvHvoUo=",
|
||||
"owner": "Mic92",
|
||||
"repo": "sops-nix",
|
||||
"rev": "c591bf665727040c6cc5cb409079acb22dcce33c",
|
||||
"rev": "9ed65852b6257fbeae4355bc24ecfea307ca759a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
tiktoken
|
||||
tinytuya
|
||||
typer
|
||||
uvicorn
|
||||
websockets
|
||||
]
|
||||
);
|
||||
|
||||
@@ -4,10 +4,12 @@ from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Self
|
||||
from urllib.parse import quote
|
||||
|
||||
import httpx
|
||||
|
||||
DEFAULT_PAGE_SIZE = 100
|
||||
EXPECTED_NO_CONTENT = 204
|
||||
EXPECTED_CREATED = 201
|
||||
EXPECTED_OK = 200
|
||||
|
||||
@@ -222,6 +224,16 @@ class GiteaClient:
|
||||
json=payload,
|
||||
)
|
||||
|
||||
def dispatch_workflow(self, *, owner: str, repo: str, workflow_id: str, ref: str) -> None:
|
||||
"""Trigger a workflow_dispatch run."""
|
||||
workflow_path = quote(workflow_id, safe="")
|
||||
self._request(
|
||||
"POST",
|
||||
f"/api/v1/repos/{owner}/{repo}/actions/workflows/{workflow_path}/dispatches",
|
||||
expected_statuses={EXPECTED_OK, EXPECTED_NO_CONTENT},
|
||||
json={"ref": ref},
|
||||
)
|
||||
|
||||
def list_run_jobs(self, *, owner: str, repo: str, run_id: str | int) -> list[WorkflowJob]:
|
||||
"""List workflow jobs for a specific run."""
|
||||
jobs: list[WorkflowJob] = []
|
||||
|
||||
@@ -14,6 +14,7 @@ DEFAULT_BASE_BRANCH = "main"
|
||||
DEFAULT_BRANCH = "automation/update-flake-lock"
|
||||
DEFAULT_GITEA_URL = "https://gitea.tmmworkshop.com"
|
||||
PR_LABELS = ["dependencies", "automated", "flake_lock_update"]
|
||||
PR_CHECK_WORKFLOWS = ["build_systems.yml", "treefmt.yml", "pytest.yml"]
|
||||
PR_TITLE = "Update flake.lock"
|
||||
PR_BODY = "Automated flake.lock update."
|
||||
|
||||
@@ -57,6 +58,12 @@ def find_flake_lock_pull_request(client: GiteaClient, *, owner: str, repo: str)
|
||||
return pull_requests[0]
|
||||
|
||||
|
||||
def dispatch_pull_request_checks(client: GiteaClient, *, owner: str, repo: str, branch: str) -> None:
|
||||
"""Dispatch the workflows that normally run for pull requests."""
|
||||
for workflow in PR_CHECK_WORKFLOWS:
|
||||
client.dispatch_workflow(owner=owner, repo=repo, workflow_id=workflow, ref=branch)
|
||||
|
||||
|
||||
def has_worktree_changes() -> bool:
|
||||
"""Return whether `flake.lock` has worktree changes."""
|
||||
result = run_cmd(["git", "diff", "--quiet", "--", "flake.lock"], check=False)
|
||||
@@ -113,6 +120,9 @@ def update(
|
||||
branch=branch,
|
||||
base=base,
|
||||
)
|
||||
# We can remove this if Gitea fixes the following issue:
|
||||
# https://github.com/go-gitea/gitea/issues/33963
|
||||
dispatch_pull_request_checks(client, owner=owner, repo=repo_name, branch=branch)
|
||||
typer.echo(pull_request.html_url or f"Pull request #{pull_request.number}")
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,12 @@
|
||||
networking = {
|
||||
hostName = "bob";
|
||||
hostId = "7c678a41";
|
||||
firewall.enable = true;
|
||||
firewall = {
|
||||
enable = true;
|
||||
allowedTCPPorts = [
|
||||
8000
|
||||
];
|
||||
};
|
||||
networkmanager.enable = true;
|
||||
};
|
||||
|
||||
|
||||
@@ -30,6 +30,11 @@
|
||||
keyFile = "/dev/disk/by-id/usb-Samsung_Flash_Drive_FIT_0374620080067131-0:0";
|
||||
};
|
||||
};
|
||||
|
||||
zfs.extraPools = [
|
||||
"storage"
|
||||
];
|
||||
|
||||
kernelModules = [ "kvm-amd" ];
|
||||
extraModulePackages = [ ];
|
||||
};
|
||||
|
||||
@@ -43,11 +43,18 @@
|
||||
};
|
||||
};
|
||||
networks = {
|
||||
"10-1GB_Primary" = {
|
||||
matchConfig.Name = "enp97s0f1";
|
||||
"10-Primary" = {
|
||||
matchConfig.Name = "enp97s0";
|
||||
address = [ "192.168.99.14/24" ];
|
||||
dns = [
|
||||
"192.168.99.1"
|
||||
"2600:4040:abfb:d700::1"
|
||||
];
|
||||
routes = [ { Gateway = "192.168.99.1"; } ];
|
||||
vlan = [ "internet-vlan" ];
|
||||
dhcpV4Config.UseDNS = false;
|
||||
dhcpV6Config.UseDNS = false;
|
||||
ipv6AcceptRAConfig.UseDNS = false;
|
||||
linkConfig.RequiredForOnline = "routable";
|
||||
};
|
||||
"50-internet-vlan" = {
|
||||
|
||||
@@ -3,6 +3,12 @@ let
|
||||
vars = import ../vars.nix;
|
||||
stateDir = "${vars.services}/nornsight";
|
||||
appDir = "${stateDir}/app";
|
||||
binPath = pkgs.lib.makeBinPath [
|
||||
pkgs.binutils
|
||||
pkgs.libpq
|
||||
pkgs.postgresql
|
||||
pkgs.stdenv.cc
|
||||
];
|
||||
libraryPath = pkgs.lib.makeLibraryPath [
|
||||
pkgs.libpq
|
||||
pkgs.postgresql.lib
|
||||
@@ -27,14 +33,20 @@ in
|
||||
|
||||
environment = {
|
||||
HOME = stateDir;
|
||||
UV_CACHE_DIR = "${stateDir}/.cache/uv";
|
||||
UV_PROJECT_ENVIRONMENT = "${appDir}/.venv";
|
||||
UV_PYTHON = "${pkgs.python313}/bin/python3.13";
|
||||
UV_PYTHON_DOWNLOADS = "never";
|
||||
LD_LIBRARY_PATH = libraryPath;
|
||||
PYTHONPATH = appDir;
|
||||
LIBRARY_PATH = libraryPath;
|
||||
PSYCOPG_IMPL = "python";
|
||||
};
|
||||
|
||||
path = with pkgs; [
|
||||
bash
|
||||
coreutils
|
||||
git
|
||||
uv
|
||||
];
|
||||
|
||||
serviceConfig = {
|
||||
@@ -56,6 +68,9 @@ in
|
||||
|
||||
script = ''
|
||||
set -eu
|
||||
export PATH="${binPath}:$PATH"
|
||||
export LD_LIBRARY_PATH="${libraryPath}:''${LD_LIBRARY_PATH:-}"
|
||||
export LIBRARY_PATH="${libraryPath}:''${LIBRARY_PATH:-}"
|
||||
|
||||
: "''${NORN_SIGHT_REPO_URL:?NORN_SIGHT_REPO_URL is required}"
|
||||
branch="''${NORN_SIGHT_BRANCH:-main}"
|
||||
@@ -77,7 +92,16 @@ in
|
||||
fi
|
||||
|
||||
cd "${appDir}"
|
||||
exec ${pkgs.my_python}/bin/python -m uvicorn pipelines.web.main:app --reload --host 0.0.0.0 --port 8001
|
||||
uv sync --upgrade
|
||||
uv run python - <<'PY'
|
||||
import ctypes.util
|
||||
import os
|
||||
|
||||
print(f"LD_LIBRARY_PATH={os.environ.get('LD_LIBRARY_PATH')}")
|
||||
print(f"LIBRARY_PATH={os.environ.get('LIBRARY_PATH')}")
|
||||
print(f"libpq={ctypes.util.find_library('pq')}")
|
||||
PY
|
||||
exec uv run uvicorn pipelines.web.main:app --host 0.0.0.0 --port 8001
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
"""Tests for Gitea flake.lock automation."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from python.gitea import PullRequest
|
||||
from python.gitea_flake_lock import (
|
||||
PR_CHECK_WORKFLOWS,
|
||||
PR_LABELS,
|
||||
dispatch_pull_request_checks,
|
||||
ensure_flake_lock_pull_request,
|
||||
find_flake_lock_pull_request,
|
||||
)
|
||||
|
||||
|
||||
def _pull_request(number=1, head_branch="automation/update-flake-lock"):
|
||||
return PullRequest(
|
||||
number=number,
|
||||
title="Update flake.lock",
|
||||
html_url=f"https://gitea.example.test/pulls/{number}",
|
||||
labels=(),
|
||||
head_branch=head_branch,
|
||||
base_branch="main",
|
||||
)
|
||||
|
||||
|
||||
class FakeGiteaClient:
|
||||
def __init__(self, pull_requests=None):
|
||||
self.pull_requests = pull_requests or []
|
||||
self.dispatch_calls = []
|
||||
self.list_calls = []
|
||||
self.create_calls = []
|
||||
|
||||
def list_open_pull_requests(self, **kwargs):
|
||||
self.list_calls.append(kwargs)
|
||||
return self.pull_requests
|
||||
|
||||
def create_pull_request(self, **kwargs):
|
||||
self.create_calls.append(kwargs)
|
||||
return _pull_request()
|
||||
|
||||
def dispatch_workflow(self, **kwargs):
|
||||
self.dispatch_calls.append(kwargs)
|
||||
|
||||
|
||||
def test_ensure_flake_lock_pull_request_finds_by_branch():
|
||||
pull_request = _pull_request()
|
||||
client = FakeGiteaClient([pull_request])
|
||||
|
||||
result = ensure_flake_lock_pull_request(
|
||||
client,
|
||||
owner="Richie",
|
||||
repo="dotfiles",
|
||||
branch="automation/update-flake-lock",
|
||||
base="main",
|
||||
)
|
||||
|
||||
assert result == pull_request
|
||||
assert client.list_calls == [
|
||||
{"owner": "Richie", "repo": "dotfiles", "head": "automation/update-flake-lock"},
|
||||
]
|
||||
assert client.create_calls == []
|
||||
|
||||
|
||||
def test_ensure_flake_lock_pull_request_creates_with_labels():
|
||||
client = FakeGiteaClient()
|
||||
|
||||
ensure_flake_lock_pull_request(
|
||||
client,
|
||||
owner="Richie",
|
||||
repo="dotfiles",
|
||||
branch="automation/update-flake-lock",
|
||||
base="main",
|
||||
)
|
||||
|
||||
assert client.create_calls == [
|
||||
{
|
||||
"owner": "Richie",
|
||||
"repo": "dotfiles",
|
||||
"title": "Update flake.lock",
|
||||
"body": "Automated flake.lock update.",
|
||||
"head": "automation/update-flake-lock",
|
||||
"base": "main",
|
||||
"labels": PR_LABELS,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def test_find_flake_lock_pull_request_finds_by_label():
|
||||
pull_request = _pull_request()
|
||||
client = FakeGiteaClient([pull_request])
|
||||
|
||||
result = find_flake_lock_pull_request(client, owner="Richie", repo="dotfiles")
|
||||
|
||||
assert result == pull_request
|
||||
assert client.list_calls == [
|
||||
{"owner": "Richie", "repo": "dotfiles", "labels": ["flake_lock_update"]},
|
||||
]
|
||||
|
||||
|
||||
def test_dispatch_pull_request_checks_runs_each_workflow():
|
||||
client = FakeGiteaClient()
|
||||
|
||||
dispatch_pull_request_checks(client, owner="Richie", repo="dotfiles", branch="automation/update-flake-lock")
|
||||
|
||||
assert client.dispatch_calls == [
|
||||
{
|
||||
"owner": "Richie",
|
||||
"repo": "dotfiles",
|
||||
"workflow_id": workflow,
|
||||
"ref": "automation/update-flake-lock",
|
||||
}
|
||||
for workflow in PR_CHECK_WORKFLOWS
|
||||
]
|
||||
@@ -20,6 +20,7 @@
|
||||
qalculate-gtk
|
||||
vlc
|
||||
# browser
|
||||
brave
|
||||
chromium
|
||||
# dev tools
|
||||
gparted
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
home.packages = [
|
||||
pkgs.claude-code
|
||||
pkgs.master.claude-code
|
||||
pkgs.master.codex
|
||||
pkgs.master.opencode
|
||||
pkgs.master.pi-coding-agent
|
||||
|
||||
@@ -2,46 +2,46 @@
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
enableDefaultConfig = false;
|
||||
matchBlocks = {
|
||||
settings = {
|
||||
jeeves = {
|
||||
hostname = "192.168.90.40";
|
||||
user = "richie";
|
||||
identityFile = "~/.ssh/id_ed25519";
|
||||
port = 629;
|
||||
dynamicForwards = [ { port = 9050; } ];
|
||||
compression = true;
|
||||
HostName = "192.168.90.40";
|
||||
User = "richie";
|
||||
IdentityFile = "~/.ssh/id_ed25519";
|
||||
Port = 629;
|
||||
DynamicForward = [ { port = 9050; } ];
|
||||
Compression = true;
|
||||
};
|
||||
unlock-jeeves = {
|
||||
hostname = "192.168.99.14";
|
||||
user = "root";
|
||||
identityFile = "~/.ssh/id_ed25519";
|
||||
port = 2222;
|
||||
HostName = "192.168.99.14";
|
||||
User = "root";
|
||||
IdentityFile = "~/.ssh/id_ed25519";
|
||||
Port = 2222;
|
||||
};
|
||||
brain = {
|
||||
hostname = "192.168.90.35";
|
||||
user = "richie";
|
||||
identityFile = "~/.ssh/id_ed25519";
|
||||
port = 129;
|
||||
dynamicForwards = [ { port = 9050; } ];
|
||||
HostName = "192.168.90.35";
|
||||
User = "richie";
|
||||
IdentityFile = "~/.ssh/id_ed25519";
|
||||
Port = 129;
|
||||
DynamicForward = [ { port = 9050; } ];
|
||||
};
|
||||
unlock-brain = {
|
||||
hostname = "192.168.95.35";
|
||||
user = "root";
|
||||
identityFile = "~/.ssh/id_ed25519";
|
||||
port = 2222;
|
||||
HostName = "192.168.95.35";
|
||||
User = "root";
|
||||
IdentityFile = "~/.ssh/id_ed25519";
|
||||
Port = 2222;
|
||||
};
|
||||
bob = {
|
||||
hostname = "192.168.90.25";
|
||||
user = "richie";
|
||||
identityFile = "~/.ssh/id_ed25519";
|
||||
port = 262;
|
||||
dynamicForwards = [ { port = 9050; } ];
|
||||
HostName = "192.168.90.25";
|
||||
User = "richie";
|
||||
IdentityFile = "~/.ssh/id_ed25519";
|
||||
Port = 262;
|
||||
DynamicForward = [ { port = 9050; } ];
|
||||
};
|
||||
rhapsody-in-green = {
|
||||
hostname = "192.168.90.221";
|
||||
user = "richie";
|
||||
identityFile = "~/.ssh/id_ed25519";
|
||||
port = 922;
|
||||
HostName = "192.168.90.221";
|
||||
User = "richie";
|
||||
IdentityFile = "~/.ssh/id_ed25519";
|
||||
Port = 922;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user