From 35deff0e0d0cd2483c64b06735215c3445111df1 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Tue, 19 Nov 2024 14:03:36 -0600 Subject: [PATCH] finish gha update/ci update refactor --- .github/workflows/update.yml | 82 ++------------------------------- pkgs/oizys/src/oizys/github.nim | 16 +++---- 2 files changed, 12 insertions(+), 86 deletions(-) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 9f480b2..a0e3260 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -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 diff --git a/pkgs/oizys/src/oizys/github.nim b/pkgs/oizys/src/oizys/github.nim index 6eb2f64..033056f 100644 --- a/pkgs/oizys/src/oizys/github.nim +++ b/pkgs/oizys/src/oizys/github.nim @@ -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