mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-22 06:00:45 -06:00
finish gha update/ci update refactor
This commit is contained in:
parent
7baf2fc303
commit
35deff0e0d
2 changed files with 12 additions and 86 deletions
80
.github/workflows/update.yml
vendored
80
.github/workflows/update.yml
vendored
|
@ -63,7 +63,7 @@ jobs:
|
||||||
push-args: --set-upstream --force origin flake-lock
|
push-args: --set-upstream --force origin flake-lock
|
||||||
|
|
||||||
|
|
||||||
build-full-at-once:
|
build-full:
|
||||||
needs: build-minimal
|
needs: build-minimal
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
@ -101,8 +101,9 @@ jobs:
|
||||||
--quiet
|
--quiet
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
|
echo "# system diffs" >> $GITHUB_STEP_SUMMARY
|
||||||
for host in othalan algiz mannaz naudiz; do
|
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
|
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
|
printf '```\n%s\n```\n' "$(nix run "nixpkgs#nvd" -- diff ./$host-current ./$host-updated)" >> $GITHUB_STEP_SUMMARY
|
||||||
done
|
done
|
||||||
|
@ -113,78 +114,3 @@ jobs:
|
||||||
with:
|
with:
|
||||||
name: summary
|
name: summary
|
||||||
path: '*-summary.md'
|
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
|
|
||||||
|
|
|
@ -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")
|
let response = getGhApi(fmt"https://api.github.com/repos/daylinmorgan/oizys/actions/runs/{runId}/artifacts")
|
||||||
fromJson(response.body, ListGhArtifactResponse).artifacts
|
fromJson(response.body, ListGhArtifactResponse).artifacts
|
||||||
|
|
||||||
proc getUpdateSummaryArtifact(runId: int, host: string): GhArtifact =
|
proc getUpdateSummaryArtifact(runId: int): GhArtifact =
|
||||||
let name = fmt"{host}-summary"
|
let name = "summary"
|
||||||
let artifacts = getArtifacts(runId)
|
let artifacts = getArtifacts(runId)
|
||||||
for artifact in artifacts:
|
for artifact in artifacts:
|
||||||
if artifact.name == name:
|
if artifact.name == name:
|
||||||
return artifact
|
return artifact
|
||||||
fatalQuit fmt"failed to find summary for run id: {runID}"
|
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
|
## 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,
|
# httpclient was forwarding the Authorization headers,
|
||||||
# which confused Azure where the archive lives...
|
# which confused Azure where the archive lives...
|
||||||
var response: Response
|
var response: Response
|
||||||
|
@ -164,20 +164,20 @@ proc getUpdateSummaryUrl(runID: int, host: string): string =
|
||||||
if location.len == 0: errorQuit fmt("location header missing url?")
|
if location.len == 0: errorQuit fmt("location header missing url?")
|
||||||
return location[0]
|
return location[0]
|
||||||
|
|
||||||
proc fetchUpdateSummaryFromUrl(url: string): string =
|
proc fetchUpdateSummaryFromUrl(url: string, host: string): string =
|
||||||
withTmpDir:
|
withTmpDir:
|
||||||
let client = newHttpClient()
|
let client = newHttpClient()
|
||||||
client.downloadFile(url, tmpDir / "summary.zip")
|
client.downloadFile(url, tmpDir / "summary.zip")
|
||||||
let reader = openZipArchive(tmpDir / "summary.zip")
|
let reader = openZipArchive(tmpDir / "summary.zip")
|
||||||
try:
|
try:
|
||||||
result = reader.extractFile("summary.md")
|
result = reader.extractFile(host & "-summary.md")
|
||||||
finally:
|
finally:
|
||||||
reader.close()
|
reader.close()
|
||||||
|
|
||||||
proc getUpdateSummary*(runId: int, host: string): string =
|
proc getUpdateSummary*(runId: int, host: string): string =
|
||||||
withSpinner("fetching update summary"):
|
withSpinner("fetching update summary"):
|
||||||
let url = getUpdateSummaryUrl(runId, host)
|
let url = getUpdateSummaryUrl(runId)
|
||||||
result = fetchUpdateSummaryFromUrl(url)
|
result = fetchUpdateSummaryFromUrl(url, host)
|
||||||
|
|
||||||
type
|
type
|
||||||
GitRepo = object
|
GitRepo = object
|
||||||
|
|
Loading…
Reference in a new issue