mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-22 10:10:45 -06:00
Compare commits
1 commit
79e8348c84
...
946a645f17
Author | SHA1 | Date | |
---|---|---|---|
946a645f17 |
10 changed files with 137 additions and 145 deletions
123
.github/workflows/update.yml
vendored
123
.github/workflows/update.yml
vendored
|
@ -51,11 +51,9 @@ jobs:
|
|||
nix run .
|
||||
--
|
||||
cache
|
||||
--host,=",othalan,algiz,mannaz,naudiz"
|
||||
--host,=",othalan,algiz"
|
||||
--flake .
|
||||
--debug
|
||||
--
|
||||
--quiet
|
||||
|
||||
- name: Commit Updates
|
||||
uses: daylin-bot/actions/commit-and-push@main
|
||||
|
@ -63,7 +61,7 @@ jobs:
|
|||
push-args: --set-upstream --force origin flake-lock
|
||||
|
||||
|
||||
build-full:
|
||||
build-full-at-once:
|
||||
needs: build-minimal
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
@ -83,34 +81,125 @@ jobs:
|
|||
- uses: ./.github/actions/nix
|
||||
with:
|
||||
attic_token: ${{ secrets.ATTIC_TOKEN }}
|
||||
# clean: true
|
||||
clean: true
|
||||
btrfs: true
|
||||
|
||||
- name: Pre-build oizys
|
||||
run: nix build .
|
||||
|
||||
- name: Build Current and Updated Systems
|
||||
- name: Build
|
||||
run: >
|
||||
nix run .
|
||||
--
|
||||
ci update
|
||||
--host,=othalan,algiz,mannaz,naudiz
|
||||
build
|
||||
"$(nix run . -- output --host,=othalan,algiz,mannaz,naudiz --flake .)"
|
||||
--flake .
|
||||
--debug
|
||||
--
|
||||
--quiet
|
||||
--keep-going
|
||||
--out-link current
|
||||
|
||||
- run: git checkout flake-lock
|
||||
|
||||
- name: Pre-build oizys
|
||||
run: nix build .
|
||||
|
||||
- name: Build Updated
|
||||
run: >
|
||||
nix run .
|
||||
--
|
||||
build
|
||||
"$(nix run . -- output --host,=othalan,algiz,mannaz,naudiz --flake .)"
|
||||
--flake .
|
||||
--debug
|
||||
--
|
||||
--keep-going
|
||||
--out-link updated
|
||||
|
||||
- run: ls
|
||||
# - run: |
|
||||
# echo "# System Diff" >> $GITHUB_STEP_SUMMARY
|
||||
# nix run "nixpkgs#nvd" -- --color always diff ./current ./updated >> summary.md
|
||||
# printf '```\n%s\n```\n' "$(nix run "nixpkgs#nvd" -- diff ./current ./updated)" >> $GITHUB_STEP_SUMMARY
|
||||
#
|
||||
- run: df -h
|
||||
|
||||
# - uses: actions/upload-artifact@v4
|
||||
# with:
|
||||
# name: ${{ matrix.host }}-summary
|
||||
# path: summary.md
|
||||
#
|
||||
build-full:
|
||||
needs: build-minimal
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
host:
|
||||
- othalan
|
||||
- algiz
|
||||
- mannaz
|
||||
- naudiz
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# needed to access ghostty repo for now
|
||||
- name: Setup SSH
|
||||
uses: MrSquaare/ssh-setup-action@v3
|
||||
with:
|
||||
host: github.com
|
||||
private-key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
|
||||
- uses: daylin-bot/actions/setup@main
|
||||
- uses: ./.github/actions/nix
|
||||
with:
|
||||
attic_token: ${{ secrets.ATTIC_TOKEN }}
|
||||
clean: true
|
||||
btrfs: true
|
||||
|
||||
- name: Pre-build oizys
|
||||
run: nix build .
|
||||
|
||||
- name: Build
|
||||
run: >
|
||||
nix run .
|
||||
--
|
||||
build
|
||||
"$(nix run . -- output --host "${{ matrix.host }}" --flake .)"
|
||||
--flake .
|
||||
--debug
|
||||
--
|
||||
--keep-going
|
||||
--out-link current
|
||||
|
||||
- run: git checkout flake-lock
|
||||
|
||||
- name: Pre-build oizys
|
||||
run: nix build .
|
||||
|
||||
- name: Build Updated
|
||||
run: >
|
||||
nix run .
|
||||
--
|
||||
build
|
||||
"$(nix run . -- output --host "${{ matrix.host }}" --flake .)"
|
||||
--flake .
|
||||
--debug
|
||||
--
|
||||
--keep-going
|
||||
--out-link updated
|
||||
|
||||
- run: |
|
||||
echo "# system diffs" >> $GITHUB_STEP_SUMMARY
|
||||
for host in othalan algiz mannaz naudiz; do
|
||||
echo "## $host" >> $GITHUB_STEP_SUMMARY
|
||||
nix run "nixpkgs#nvd" -- --color always diff ./$host-current ./$host-updated >> $host-summary.md
|
||||
printf '```\n%s\n```\n' "$(nix run "nixpkgs#nvd" -- diff ./$host-current ./$host-updated)" >> $GITHUB_STEP_SUMMARY
|
||||
done
|
||||
echo "# System Diff" >> $GITHUB_STEP_SUMMARY
|
||||
nix run "nixpkgs#nvd" -- --color always diff ./current ./updated >> summary.md
|
||||
printf '```\n%s\n```\n' "$(nix run "nixpkgs#nvd" -- diff ./current ./updated)" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
- run: df -h
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: summary
|
||||
path: '*-summary.md'
|
||||
name: ${{ matrix.host }}-summary
|
||||
path: summary.md
|
||||
|
|
14
flake.lock
14
flake.lock
|
@ -240,11 +240,11 @@
|
|||
"zig": "zig"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1732039947,
|
||||
"narHash": "sha256-LgLGpeyimlCyHWzsQZ5xL0GJv+14zTVsAPTOuwL/qkA=",
|
||||
"lastModified": 1731971697,
|
||||
"narHash": "sha256-6JNMcpy0z19yOLBRt3eE4Rk4A96kcEsRv5+ym1hkv1c=",
|
||||
"ref": "refs/heads/main",
|
||||
"rev": "14f603e691e13cb14855a4af8e9760a578f7aefd",
|
||||
"revCount": 8023,
|
||||
"rev": "29c3a52e964a97dddaed876ce472aeb167774acf",
|
||||
"revCount": 8021,
|
||||
"type": "git",
|
||||
"url": "ssh://git@github.com/ghostty-org/ghostty"
|
||||
},
|
||||
|
@ -745,11 +745,11 @@
|
|||
"nixpkgs": "nixpkgs_6"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1732040857,
|
||||
"narHash": "sha256-nwbtI77CGa6AclGOmNXKLZFboxeAJWqX0IVgT2Ezo1Y=",
|
||||
"lastModified": 1732026056,
|
||||
"narHash": "sha256-ZXYNxTYD3uWtWrU/SMH43w1QRygDSoX1KEMhpwRrB5Y=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs-wayland",
|
||||
"rev": "1e388cad31a52c4dc25613484b3591298b105935",
|
||||
"rev": "5181aa924e9e322d2dcb610ec73d8bae73c1286d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -33,10 +33,11 @@ hwylCli:
|
|||
? "set minimal"
|
||||
- m
|
||||
preSub:
|
||||
setupLoggers()
|
||||
setupLoggers(debug)
|
||||
updateContext(host, flake, debug, resetCache)
|
||||
|
||||
subcommands:
|
||||
|
||||
[build]
|
||||
... "nix build"
|
||||
flags:
|
||||
|
@ -64,23 +65,8 @@ hwylCli:
|
|||
nixBuildWithCache(name, args, service, jobs)
|
||||
|
||||
[ci]
|
||||
... "builtin ci"
|
||||
# current behavior adds this block twice...
|
||||
# when really I want it to only happen in the lowest "subcommand"
|
||||
# needs to be fixed in hwylterm
|
||||
preSub:
|
||||
updateContext(host, flake, debug, resetCache)
|
||||
subcommands:
|
||||
[update]
|
||||
... "build current and updated hosts"
|
||||
run:
|
||||
ciUpdate(args)
|
||||
|
||||
[gha]
|
||||
... "trigger GHA"
|
||||
flags:
|
||||
# make a key/value input that is passed to workflows and encoded in json
|
||||
# i.e. --input:ref:main
|
||||
`ref`:
|
||||
T string
|
||||
? "git ref/branch/tag to trigger workflow on"
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import std/[logging, os, strformat, strutils]
|
||||
from std/nativesockets import getHostname
|
||||
import hwylterm, hwylterm/logging
|
||||
import ./logging
|
||||
|
||||
type
|
||||
OizysContext* = object
|
||||
|
@ -37,8 +36,6 @@ proc updateContext*(
|
|||
) =
|
||||
if host.len > 0: oc.hosts = host
|
||||
oc.debug = debug
|
||||
if debug:
|
||||
consoleLogger.levelThreshold = lvlAll
|
||||
oc.resetCache = resetCache
|
||||
if flake != "":
|
||||
oc.flake =
|
||||
|
@ -52,3 +49,5 @@ proc getFlake*(): string = return oc.flake
|
|||
proc isDebug*(): bool = return oc.debug
|
||||
proc isResetCache*(): bool = return oc.resetCache
|
||||
proc isCi*(): bool = return oc.ci
|
||||
|
||||
|
||||
|
|
|
@ -47,10 +47,7 @@ proc runCmdCapt*(
|
|||
if errstrm.readLine(line):
|
||||
result.stderr.add line & '\n'
|
||||
result.exitCode = peekExitCode(p)
|
||||
if result.exitCode != -1:
|
||||
result.stdout.add outstrm.readAll()
|
||||
result.stderr.add errstrm.readAll()
|
||||
break
|
||||
if result.exitCode != -1: break
|
||||
|
||||
close p
|
||||
|
||||
|
|
|
@ -137,17 +137,17 @@ proc getArtifacts(runId: int): seq[GhArtifact] =
|
|||
let response = getGhApi(fmt"https://api.github.com/repos/daylinmorgan/oizys/actions/runs/{runId}/artifacts")
|
||||
fromJson(response.body, ListGhArtifactResponse).artifacts
|
||||
|
||||
proc getUpdateSummaryArtifact(runId: int): GhArtifact =
|
||||
let name = "summary"
|
||||
proc getUpdateSummaryArtifact(runId: int, host: string): GhArtifact =
|
||||
let name = fmt"{host}-summary"
|
||||
let artifacts = getArtifacts(runId)
|
||||
for artifact in artifacts:
|
||||
if artifact.name == name:
|
||||
return artifact
|
||||
fatalQuit fmt"failed to find summary for run id: {runID}"
|
||||
|
||||
proc getUpdateSummaryUrl(runID: int): string =
|
||||
proc getUpdateSummaryUrl(runID: int, host: string): string =
|
||||
## https://api.github.com/repos/OWNER/REPO/actions/artifacts/ARTIFACT_ID/ARCHIVE_FORMAT
|
||||
let artifact = getUpdateSummaryArtifact(runID)
|
||||
let artifact = getUpdateSummaryArtifact(runID, host)
|
||||
# httpclient was forwarding the Authorization headers,
|
||||
# which confused Azure where the archive lives...
|
||||
var response: Response
|
||||
|
@ -164,20 +164,20 @@ proc getUpdateSummaryUrl(runID: int): string =
|
|||
if location.len == 0: errorQuit fmt("location header missing url?")
|
||||
return location[0]
|
||||
|
||||
proc fetchUpdateSummaryFromUrl(url: string, host: string): string =
|
||||
proc fetchUpdateSummaryFromUrl(url: string): string =
|
||||
withTmpDir:
|
||||
let client = newHttpClient()
|
||||
client.downloadFile(url, tmpDir / "summary.zip")
|
||||
let reader = openZipArchive(tmpDir / "summary.zip")
|
||||
try:
|
||||
result = reader.extractFile(host & "-summary.md")
|
||||
result = reader.extractFile("summary.md")
|
||||
finally:
|
||||
reader.close()
|
||||
|
||||
proc getUpdateSummary*(runId: int, host: string): string =
|
||||
withSpinner("fetching update summary"):
|
||||
let url = getUpdateSummaryUrl(runId)
|
||||
result = fetchUpdateSummaryFromUrl(url, host)
|
||||
let url = getUpdateSummaryUrl(runId, host)
|
||||
result = fetchUpdateSummaryFromUrl(url)
|
||||
|
||||
type
|
||||
GitRepo = object
|
||||
|
|
|
@ -24,5 +24,3 @@ comma-with-db
|
|||
nix-index-with-db
|
||||
python
|
||||
net.conf
|
||||
llm
|
||||
rofi
|
||||
|
|
|
@ -23,18 +23,19 @@ proc getOizysLogPath(): string =
|
|||
createDir(dataDir / "oizys")
|
||||
result = dataDir / "oizys" / "oizys.log"
|
||||
|
||||
|
||||
setLogFilter(lvlAll)
|
||||
|
||||
var consoleLogger* =
|
||||
newHwylConsoleLogger(
|
||||
proc setupLoggers*(debug: bool) =
|
||||
let logLevel =
|
||||
if not debug: lvlInfo
|
||||
else: lvlAll
|
||||
addHandler(
|
||||
newHwylConsoleLogger(
|
||||
fmtPrefix = $bb"[b magenta]oizys",
|
||||
fmtSuffix = " ",
|
||||
levelThreshold = lvlInfo
|
||||
)
|
||||
|
||||
proc setupLoggers*() =
|
||||
addHandler(
|
||||
consoleLogger
|
||||
levelThreshold = logLevel
|
||||
)
|
||||
)
|
||||
addHandler(
|
||||
newRollingFileLogger(
|
||||
|
|
|
@ -14,12 +14,9 @@ proc nixCommand(cmd: string): string =
|
|||
result.addArg "--log-format multiline"
|
||||
result.addArg cmd
|
||||
|
||||
proc nixosConfigAttr(host: string): string =
|
||||
getFlake() & "#nixosConfigurations." & host & ".config.system.build.toplevel"
|
||||
|
||||
proc nixosConfigAttrs*(): seq[string] =
|
||||
for host in getHosts():
|
||||
result.add nixosConfigAttr(host)
|
||||
result.add getFlake() & "#nixosConfigurations." & host & ".config.system.build.toplevel"
|
||||
|
||||
const nixosSubcmds* =
|
||||
"""switch boot test build dry-build dry-activate edit
|
||||
|
@ -351,78 +348,3 @@ proc nixBuildWithCache*(name: string, rest:seq[string], service: string, jobs: i
|
|||
if pushErr != 0:
|
||||
errorQuit "failed to push build to cache"
|
||||
|
||||
#[
|
||||
- name: Build
|
||||
run: >
|
||||
nix run .
|
||||
--
|
||||
build
|
||||
"$(nix run . -- output --host,=othalan,algiz,mannaz,naudiz --flake .)"
|
||||
--flake .
|
||||
--debug
|
||||
--
|
||||
--keep-going
|
||||
--no-link
|
||||
|
||||
- run: git show origin/flake-lock:flake.lock > updated.lock
|
||||
|
||||
- name: Pre-build oizys
|
||||
run: nix build . --reference-lock-file updated.lock
|
||||
|
||||
- name: Build Updated
|
||||
run: >
|
||||
nix run .
|
||||
--
|
||||
build
|
||||
"$(nix run . -- output --host,=othalan,algiz,mannaz,naudiz --flake .)"
|
||||
--flake .
|
||||
--debug
|
||||
--
|
||||
--keep-going
|
||||
--no-link
|
||||
--reference-lock-file updated.lock
|
||||
|
||||
- run: |
|
||||
for host in othalan algiz mannaz naudiz; do
|
||||
for rev in current updated; do
|
||||
args="\"$(nix run . -- output --host $host)\" --out-link \"${host}-${rev}\""
|
||||
[[ "$rev" == "updated" ]] && args="$args --reference-lock-file updated.lock"
|
||||
nix build $args
|
||||
done
|
||||
done
|
||||
]#
|
||||
|
||||
|
||||
proc getUpdatedLockFile() =
|
||||
info "getting updated flake.lock as updated.lock"
|
||||
let res = runCmdCapt("git --no-pager show origin/flake-lock:flake.lock")
|
||||
if res.exitCode != 0:
|
||||
fatalQuit "failed to fetch updated lock file using git"
|
||||
writeFile("updated.lock", res.stdout)
|
||||
|
||||
# probably duplicating logic above ¯\_(ツ)_/¯
|
||||
proc buildSystem(host: string, rest: seq[string]) =
|
||||
var cmd = nixCommand("build")
|
||||
cmd.addArg nixosConfigAttr(host)
|
||||
cmd.addArgs rest
|
||||
let code = runCmd cmd
|
||||
if code != 0:
|
||||
fatalQuit "build failed"
|
||||
|
||||
proc ciUpdate*(rest: seq[string]) =
|
||||
for host in getHosts():
|
||||
info "building " & host.bb("bold")
|
||||
buildSystem(
|
||||
host,
|
||||
@["--out-link", host & "-current", "--quiet"] & rest
|
||||
)
|
||||
|
||||
getUpdatedLockFile()
|
||||
|
||||
for host in getHosts():
|
||||
info "building updated " & host.bb("bold")
|
||||
buildSystem(
|
||||
host,
|
||||
@["--out-link", host & "-updated", "--quiet", "--reference-lock-file", "updated.lock"] & rest
|
||||
)
|
||||
|
||||
|
|
2
todo.md
2
todo.md
|
@ -3,10 +3,10 @@
|
|||
## oizys
|
||||
|
||||
- [ ] write a flake template that includes the systems boilerplate
|
||||
- [ ] get the running action url after `oizys ci {workflow}.yml`
|
||||
|
||||
## software
|
||||
|
||||
- [ ] why is my update ci always building llm and rofi?
|
||||
- [ ] include langservers for enabled languages?
|
||||
<!--[tracking issue](https://github.com/wez/wezterm/issues/5990)-->
|
||||
- [ ] ~wezterm is broken...something to do with fonts?~ using ghostty
|
||||
|
|
Loading…
Reference in a new issue