finish gha update/ci update refactor

This commit is contained in:
Daylin Morgan 2024-11-19 14:03:36 -06:00
parent 7baf2fc303
commit 35deff0e0d
Signed by: daylin
GPG key ID: 950D13E9719334AD
2 changed files with 12 additions and 86 deletions

View file

@ -63,7 +63,7 @@ jobs:
push-args: --set-upstream --force origin flake-lock
build-full-at-once:
build-full:
needs: build-minimal
runs-on: ubuntu-latest
steps:
@ -92,7 +92,7 @@ jobs:
- name: Build Current and Updated Systems
run: >
nix run .
--
--
ci update
--host,=othalan,algiz,mannaz,naudiz
--flake .
@ -101,8 +101,9 @@ jobs:
--quiet
- run: |
echo "# system diffs" >> $GITHUB_STEP_SUMMARY
for host in othalan algiz mannaz naudiz; do
echo "# System Diff" >> $GITHUB_STEP_SUMMARY
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
@ -113,78 +114,3 @@ jobs:
with:
name: 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 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

View file

@ -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, host: string): GhArtifact =
let name = fmt"{host}-summary"
proc getUpdateSummaryArtifact(runId: int): GhArtifact =
let name = "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, host: string): string =
proc getUpdateSummaryUrl(runID: int): string =
## https://api.github.com/repos/OWNER/REPO/actions/artifacts/ARTIFACT_ID/ARCHIVE_FORMAT
let artifact = getUpdateSummaryArtifact(runID, host)
let artifact = getUpdateSummaryArtifact(runID)
# httpclient was forwarding the Authorization headers,
# which confused Azure where the archive lives...
var response: Response
@ -164,20 +164,20 @@ proc getUpdateSummaryUrl(runID: int, host: string): string =
if location.len == 0: errorQuit fmt("location header missing url?")
return location[0]
proc fetchUpdateSummaryFromUrl(url: string): string =
proc fetchUpdateSummaryFromUrl(url: string, host: string): string =
withTmpDir:
let client = newHttpClient()
client.downloadFile(url, tmpDir / "summary.zip")
let reader = openZipArchive(tmpDir / "summary.zip")
try:
result = reader.extractFile("summary.md")
result = reader.extractFile(host & "-summary.md")
finally:
reader.close()
proc getUpdateSummary*(runId: int, host: string): string =
withSpinner("fetching update summary"):
let url = getUpdateSummaryUrl(runId, host)
result = fetchUpdateSummaryFromUrl(url)
let url = getUpdateSummaryUrl(runId)
result = fetchUpdateSummaryFromUrl(url, host)
type
GitRepo = object