Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 15c717f9fe |
@@ -1,7 +1,6 @@
|
|||||||
name: pytest
|
name: pytest
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ jobs:
|
|||||||
lockfile:
|
lockfile:
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
permissions:
|
permissions:
|
||||||
actions: write
|
|
||||||
contents: write
|
contents: write
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
Generated
+15
-15
@@ -8,11 +8,11 @@
|
|||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"dir": "pkgs/firefox-addons",
|
"dir": "pkgs/firefox-addons",
|
||||||
"lastModified": 1781270820,
|
"lastModified": 1780733803,
|
||||||
"narHash": "sha256-KuDdN/p4UtqUb1wnjo8a/YougmRXEaKvUoGHkYnuAq0=",
|
"narHash": "sha256-QBJPq12P1DAXFGezoEJaSO/xPUrPlnaI3ddSaMG2JpM=",
|
||||||
"owner": "rycee",
|
"owner": "rycee",
|
||||||
"repo": "nur-expressions",
|
"repo": "nur-expressions",
|
||||||
"rev": "5f4259c0c832a93e13c5ec481d3318ce1394a8f9",
|
"rev": "c80b0aa94392c5f3612ac797108f6d952752036d",
|
||||||
"type": "gitlab"
|
"type": "gitlab"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -29,11 +29,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1781305496,
|
"lastModified": 1780679734,
|
||||||
"narHash": "sha256-g8Vv4Qfc7n+lgov97REu3X6BeJtvYY0hlSUZR1GrGQQ=",
|
"narHash": "sha256-KmRNvpNOb7QEORa06bVgjW9kITcx0VhsI7w0vhmZyD8=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "c87a39aa979acc4848016d2220c6238390d84779",
|
"rev": "b2b7db486e06e098711dc291bb25db82850e1d16",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -47,11 +47,11 @@
|
|||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1781168557,
|
"lastModified": 1780310866,
|
||||||
"narHash": "sha256-LOnLQ2tpYF9gqIDDr3+j3DbpJJr/QCH6zPRT2GzEUOE=",
|
"narHash": "sha256-fPBRVf6A5xlACYcOI59shGrjURuvwu0lRsDoSCEXt/I=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixos-hardware",
|
"repo": "nixos-hardware",
|
||||||
"rev": "6358ff76821101c178e3ab4919a62799bfe3652e",
|
"rev": "4ed851c979641e28597a05086332d75cdc9e395f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -76,11 +76,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs-master": {
|
"nixpkgs-master": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1781306963,
|
"lastModified": 1780798858,
|
||||||
"narHash": "sha256-qWZ+XEwsf8pN4DnYyyLbmAyj1a74gOO/VNCff44MuB4=",
|
"narHash": "sha256-4KLc5ZMjfMQosXA2JasUgZTk3i+c/i1zMH4custtmI0=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "1eee1a273e2e3fdc3db5b1a4a66f06cd5749db69",
|
"rev": "92840095e65b9970125843175f4be974b71a92ad",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -108,11 +108,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1781074563,
|
"lastModified": 1780243769,
|
||||||
"narHash": "sha256-md8WlXOlfnIeHeOScMTTHFyf2d6iaTwPl2apR5EQ3P4=",
|
"narHash": "sha256-x5UQuRsH3MqI0U9afaXSNqzTPSeZlRLvFAav2Ux1pNw=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "9ae611a455b90cf061d8f332b977e387bda8e1ca",
|
"rev": "331800de5053fcebacf6813adb5db9c9dca22a0c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -4,12 +4,10 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Self
|
from typing import Self
|
||||||
from urllib.parse import quote
|
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
|
||||||
DEFAULT_PAGE_SIZE = 100
|
DEFAULT_PAGE_SIZE = 100
|
||||||
EXPECTED_NO_CONTENT = 204
|
|
||||||
EXPECTED_CREATED = 201
|
EXPECTED_CREATED = 201
|
||||||
EXPECTED_OK = 200
|
EXPECTED_OK = 200
|
||||||
|
|
||||||
@@ -224,16 +222,6 @@ class GiteaClient:
|
|||||||
json=payload,
|
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]:
|
def list_run_jobs(self, *, owner: str, repo: str, run_id: str | int) -> list[WorkflowJob]:
|
||||||
"""List workflow jobs for a specific run."""
|
"""List workflow jobs for a specific run."""
|
||||||
jobs: list[WorkflowJob] = []
|
jobs: list[WorkflowJob] = []
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ DEFAULT_BASE_BRANCH = "main"
|
|||||||
DEFAULT_BRANCH = "automation/update-flake-lock"
|
DEFAULT_BRANCH = "automation/update-flake-lock"
|
||||||
DEFAULT_GITEA_URL = "https://gitea.tmmworkshop.com"
|
DEFAULT_GITEA_URL = "https://gitea.tmmworkshop.com"
|
||||||
PR_LABELS = ["dependencies", "automated", "flake_lock_update"]
|
PR_LABELS = ["dependencies", "automated", "flake_lock_update"]
|
||||||
PR_CHECK_WORKFLOWS = ["build_systems.yml", "treefmt.yml", "pytest.yml"]
|
|
||||||
PR_TITLE = "Update flake.lock"
|
PR_TITLE = "Update flake.lock"
|
||||||
PR_BODY = "Automated flake.lock update."
|
PR_BODY = "Automated flake.lock update."
|
||||||
|
|
||||||
@@ -58,12 +57,6 @@ def find_flake_lock_pull_request(client: GiteaClient, *, owner: str, repo: str)
|
|||||||
return pull_requests[0]
|
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:
|
def has_worktree_changes() -> bool:
|
||||||
"""Return whether `flake.lock` has worktree changes."""
|
"""Return whether `flake.lock` has worktree changes."""
|
||||||
result = run_cmd(["git", "diff", "--quiet", "--", "flake.lock"], check=False)
|
result = run_cmd(["git", "diff", "--quiet", "--", "flake.lock"], check=False)
|
||||||
@@ -120,9 +113,6 @@ def update(
|
|||||||
branch=branch,
|
branch=branch,
|
||||||
base=base,
|
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}")
|
typer.echo(pull_request.html_url or f"Pull request #{pull_request.number}")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,12 +28,7 @@
|
|||||||
networking = {
|
networking = {
|
||||||
hostName = "bob";
|
hostName = "bob";
|
||||||
hostId = "7c678a41";
|
hostId = "7c678a41";
|
||||||
firewall = {
|
firewall.enable = true;
|
||||||
enable = true;
|
|
||||||
allowedTCPPorts = [
|
|
||||||
8000
|
|
||||||
];
|
|
||||||
};
|
|
||||||
networkmanager.enable = true;
|
networkmanager.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -30,11 +30,6 @@
|
|||||||
keyFile = "/dev/disk/by-id/usb-Samsung_Flash_Drive_FIT_0374620080067131-0:0";
|
keyFile = "/dev/disk/by-id/usb-Samsung_Flash_Drive_FIT_0374620080067131-0:0";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
zfs.extraPools = [
|
|
||||||
"storage"
|
|
||||||
];
|
|
||||||
|
|
||||||
kernelModules = [ "kvm-amd" ];
|
kernelModules = [ "kvm-amd" ];
|
||||||
extraModulePackages = [ ];
|
extraModulePackages = [ ];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,113 +0,0 @@
|
|||||||
"""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
|
|
||||||
]
|
|
||||||
Reference in New Issue
Block a user