mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-22 10:10:45 -06:00
add new ci command
This commit is contained in:
parent
42e7de22b1
commit
1bb8da0bf1
8 changed files with 1272 additions and 6 deletions
1
othalan-current
Symbolic link
1
othalan-current
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
/nix/store/pznxacprsq9gspmiavldyg1qfyppmqw4-nixos-system-othalan-25.05.20241118.5083ec8
|
1
othalan-updated
Symbolic link
1
othalan-updated
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
/nix/store/qx76kywiz9v85yxck9y64878v0an9q15-nixos-system-othalan-25.05.20241118.5083ec8
|
|
@ -37,7 +37,6 @@ hwylCli:
|
||||||
updateContext(host, flake, debug, resetCache)
|
updateContext(host, flake, debug, resetCache)
|
||||||
|
|
||||||
subcommands:
|
subcommands:
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
... "nix build"
|
... "nix build"
|
||||||
flags:
|
flags:
|
||||||
|
@ -65,8 +64,24 @@ hwylCli:
|
||||||
nixBuildWithCache(name, args, service, jobs)
|
nixBuildWithCache(name, args, service, jobs)
|
||||||
|
|
||||||
[ci]
|
[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:
|
||||||
|
setupLoggers(debug)
|
||||||
|
updateContext(host, flake, debug, resetCache)
|
||||||
|
subcommands:
|
||||||
|
[update]
|
||||||
|
... "build current and updated hosts"
|
||||||
|
run:
|
||||||
|
ciUpdate(args)
|
||||||
|
|
||||||
|
[gha]
|
||||||
... "trigger GHA"
|
... "trigger GHA"
|
||||||
flags:
|
flags:
|
||||||
|
# make a key/value input that is passed to workflows and encoded in json
|
||||||
|
# i.e. --input:ref:main
|
||||||
`ref`:
|
`ref`:
|
||||||
T string
|
T string
|
||||||
? "git ref/branch/tag to trigger workflow on"
|
? "git ref/branch/tag to trigger workflow on"
|
||||||
|
|
|
@ -49,5 +49,3 @@ proc getFlake*(): string = return oc.flake
|
||||||
proc isDebug*(): bool = return oc.debug
|
proc isDebug*(): bool = return oc.debug
|
||||||
proc isResetCache*(): bool = return oc.resetCache
|
proc isResetCache*(): bool = return oc.resetCache
|
||||||
proc isCi*(): bool = return oc.ci
|
proc isCi*(): bool = return oc.ci
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,10 @@ proc runCmdCapt*(
|
||||||
if errstrm.readLine(line):
|
if errstrm.readLine(line):
|
||||||
result.stderr.add line & '\n'
|
result.stderr.add line & '\n'
|
||||||
result.exitCode = peekExitCode(p)
|
result.exitCode = peekExitCode(p)
|
||||||
if result.exitCode != -1: break
|
if result.exitCode != -1:
|
||||||
|
result.stdout.add outstrm.readAll()
|
||||||
|
result.stderr.add errstrm.readAll()
|
||||||
|
break
|
||||||
|
|
||||||
close p
|
close p
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@ proc getOizysLogPath(): string =
|
||||||
createDir(dataDir / "oizys")
|
createDir(dataDir / "oizys")
|
||||||
result = dataDir / "oizys" / "oizys.log"
|
result = dataDir / "oizys" / "oizys.log"
|
||||||
|
|
||||||
|
|
||||||
setLogFilter(lvlAll)
|
setLogFilter(lvlAll)
|
||||||
|
|
||||||
proc setupLoggers*(debug: bool) =
|
proc setupLoggers*(debug: bool) =
|
||||||
|
|
|
@ -14,9 +14,12 @@ proc nixCommand(cmd: string): string =
|
||||||
result.addArg "--log-format multiline"
|
result.addArg "--log-format multiline"
|
||||||
result.addArg cmd
|
result.addArg cmd
|
||||||
|
|
||||||
|
proc nixosConfigAttr(host: string): string =
|
||||||
|
getFlake() & "#nixosConfigurations." & host & ".config.system.build.toplevel"
|
||||||
|
|
||||||
proc nixosConfigAttrs*(): seq[string] =
|
proc nixosConfigAttrs*(): seq[string] =
|
||||||
for host in getHosts():
|
for host in getHosts():
|
||||||
result.add getFlake() & "#nixosConfigurations." & host & ".config.system.build.toplevel"
|
result.add nixosConfigAttr(host)
|
||||||
|
|
||||||
const nixosSubcmds* =
|
const nixosSubcmds* =
|
||||||
"""switch boot test build dry-build dry-activate edit
|
"""switch boot test build dry-build dry-activate edit
|
||||||
|
@ -348,3 +351,84 @@ proc nixBuildWithCache*(name: string, rest:seq[string], service: string, jobs: i
|
||||||
if pushErr != 0:
|
if pushErr != 0:
|
||||||
errorQuit "failed to push build to cache"
|
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)
|
||||||
|
|
||||||
|
proc ciUpdate*(rest: seq[string]) =
|
||||||
|
# TODO: deduplicated logic in this proc
|
||||||
|
for host in getHosts():
|
||||||
|
info "building " & host.bb("bold")
|
||||||
|
var cmd = nixCommand("build")
|
||||||
|
cmd.addArg nixosConfigAttr(host)
|
||||||
|
# TODO: how to get the out link?
|
||||||
|
cmd.addArgs ["--out-link", host & "-current"]
|
||||||
|
cmd.addArg "--quiet"
|
||||||
|
cmd.addArgs rest
|
||||||
|
let code = runCmd cmd
|
||||||
|
if code != 0:
|
||||||
|
# TODO: nix log "attr"?
|
||||||
|
discard runCmd("nix log " & nixosConfigAttr(host))
|
||||||
|
fatalQuit "build failed"
|
||||||
|
|
||||||
|
getUpdatedLockFile()
|
||||||
|
|
||||||
|
for host in getHosts():
|
||||||
|
info "building updated " & host.bb("bold")
|
||||||
|
var cmd = nixCommand("build")
|
||||||
|
cmd.addArg nixosConfigAttr(host)
|
||||||
|
cmd.addArgs ["--out-link", host & "-updated"]
|
||||||
|
cmd.addArg "--quiet"
|
||||||
|
cmd.addArgs ["--reference-lock-file", "updated.lock"]
|
||||||
|
cmd.addArgs rest
|
||||||
|
let code = runCmd cmd
|
||||||
|
if code != 0:
|
||||||
|
# TODO: nix log "attr"?
|
||||||
|
discard runCmd("nix log " & nixosConfigAttr(host))
|
||||||
|
fatalQuit "build failed"
|
||||||
|
|
||||||
|
|
1165
updated.lock
Normal file
1165
updated.lock
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue