From ac7dfe13b758065c49f6c1cce6454d912dce73ec Mon Sep 17 00:00:00 2001 From: Floweynt <50057682+Floweynt@users.noreply.github.com> Date: Thu, 10 Sep 2026 17:27:27 -0500 Subject: [PATCH] try fixing gitea ci: v24 --- .github/workflows/lint.yml | 16 +++------- ci.py | 54 ++++++++++++++++++++++++++++++++++ tests/server-n0/integration.py | 5 ++-- 3 files changed, 61 insertions(+), 14 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cfa1b95..feabeae 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,14 +19,6 @@ jobs: steps: - uses: actions/checkout@v4 - - name: pick reporter - run: | - if [ "${{ github.event_name }}" = pull_request ]; then - echo "REPORTER=gitea-pr-review" >> "$GITHUB_ENV" - else - echo "REPORTER=local" >> "$GITHUB_ENV" - fi - - name: run linters run: nix run -L .#ci -- lint . "$RUNNER_TEMP/findings" @@ -35,9 +27,9 @@ jobs: env: REVIEWDOG_GITEA_API_TOKEN: ${{ secrets.GITEA_TOKEN }} run: | - if [ "$REPORTER" = local ]; then - nix run -L .#ci -- lint-report "$REPORTER" "$RUNNER_TEMP/findings" \ - | tee -a "$GITHUB_STEP_SUMMARY" + if [ "${{ github.event_name }}" = pull_request ]; then + nix run -L .#ci -- lint-report gitea-pr-review "$RUNNER_TEMP/findings" else - nix run -L .#ci -- lint-report "$REPORTER" "$RUNNER_TEMP/findings" + nix run -L .#ci -- lint-summary "$RUNNER_TEMP/findings" \ + | tee -a "$GITHUB_STEP_SUMMARY" fi diff --git a/ci.py b/ci.py index c4cdfc3..b83f958 100644 --- a/ci.py +++ b/ci.py @@ -367,6 +367,59 @@ def lint_report(args): sys.exit(1 if any(codes) else 0) +def has_findings(path): + return os.path.isfile(path) and os.path.getsize(path) > 0 + + +def fmt_rdjsonl(path): + lines = [] + with open(path) as f: + for raw in f: + rec = json.loads(raw) + loc = rec["location"] + r = loc.get("range", {}).get("start") + pos = f"{loc['path']}:{r['line']}:{r['column']}" if r else loc["path"] + lines.append(f"- `{pos}`: {rec['message']}") + return "\n".join(lines) + + +def fmt_errfmt(path): + lines = [] + with open(path) as f: + for raw in f: + parts = raw.strip().split(">", 1) + if len(parts) == 2: + lines.append(f"- `{parts[0]}:{parts[1].split(':', 3)[-1].strip()}`" if ":" in parts[1] else f"- `{raw.strip()}`") + elif raw.strip(): + lines.append(f"- `{raw.strip()}`") + return "\n".join(lines) + + +def lint_summary(args): + sections = [] + d = args.dir + + if has_findings(f"{d}/nixfmt.diff"): + with open(f"{d}/nixfmt.diff") as f: + sections.append(f"## nixfmt\n\n```diff\n{f.read().rstrip()}\n```") + + if has_findings(f"{d}/statix.errfmt"): + sections.append(f"## statix\n\n{fmt_errfmt(f'{d}/statix.errfmt')}") + + if has_findings(f"{d}/deadnix.rdjsonl"): + sections.append(f"## deadnix\n\n{fmt_rdjsonl(f'{d}/deadnix.rdjsonl')}") + + if has_findings(f"{d}/cycles.rdjsonl"): + sections.append(f"## systemd ordering cycles\n\n{fmt_rdjsonl(f'{d}/cycles.rdjsonl')}") + + if sections: + print("\n\n".join(["# Lint findings"] + sections)) + sys.exit(1) + else: + print("No lint findings.") + sys.exit(0) + + def post_comment(args): body = args.marker + "\n" + Path(args.body_file).read_text() pr = os.environ["PR"] @@ -439,6 +492,7 @@ def main(): command("vulnix", vulnix, "ref", "body_out") command("lint", lint, "target", "out") command("lint-report", lint_report, "reporter", "dir") + command("lint-summary", lint_summary, "dir") command("post-comment", post_comment, "marker", "body_file") command("upsert-issue", upsert_issue, "label", "title", "body_file") command("close-issue", close_issue, "label") diff --git a/tests/server-n0/integration.py b/tests/server-n0/integration.py index 265ccf9..fbbb5ab 100644 --- a/tests/server-n0/integration.py +++ b/tests/server-n0/integration.py @@ -205,11 +205,12 @@ with subtest("(isolation): edges are one-way"): server.fail(ct_connect("git", ADDR["nginx"], 443, timeout=2)) with subtest("(isolation): host access allowlist"): - server.succeed( + server.wait_until_succeeds( net_cmd( "overseer", f"{CURL} -sf --max-time 5 http://{HOST_ADDR['overseer']}:{HOST_EXPORTER_PORT}/metrics >&2", - ) + ), + timeout=60, ) for port in (HOST_EXPORTER_PORT, HOST_CADVISOR_PORT): server.fail(ct_connect("git", HOST_ADDR["git"], port, timeout=2))