From 28032f84dfd479d1b42287902fcd0c27f9568172 Mon Sep 17 00:00:00 2001 From: Avimitin Date: Mon, 30 Dec 2024 18:32:05 +0800 Subject: [PATCH] [ci] attach fail job HTML page URL to summary --- script/build.sc | 3 ++- script/ci/src/Main.scala | 17 +++++++++++++++++ script/default.nix | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/script/build.sc b/script/build.sc index 6bda821a4..24d5497b9 100644 --- a/script/build.sc +++ b/script/build.sc @@ -12,10 +12,11 @@ trait ScriptModule extends ScalaModule with ScalafmtModule { val mainargs = ivy"com.lihaoyi::mainargs:0.5.0" val oslib = ivy"com.lihaoyi::os-lib:0.10.0" val upickle = ivy"com.lihaoyi::upickle:3.3.1" + val requests = ivy"com.lihaoyi::requests:0.9.0" def scalaVersion = scala3 def scalacOptions = Seq("-new-syntax", "-deprecation") - override def ivyDeps = Agg(mainargs, oslib, upickle) + override def ivyDeps = Agg(mainargs, oslib, upickle, requests) } object emu extends ScriptModule {} diff --git a/script/ci/src/Main.scala b/script/ci/src/Main.scala index e998fa9b5..dd1b8faea 100644 --- a/script/ci/src/Main.scala +++ b/script/ci/src/Main.scala @@ -204,11 +204,28 @@ object Main: os.Path(sys.env("GITHUB_STEP_SUMMARY")), failedTests.map(s => s"* ${s}\n").mkString ) + os.write.append(os.Path(sys.env("GITHUB_STEP_SUMMARY")), s"Job URL: ${findCurrentJobURL()}") Logger.fatal( s"${BOLD}${failedTests.length} tests failed${RESET}" ) end runTests + // Search job HTML page by github run id + def findCurrentJobURL() = + val runID = sys.env("GITHUB_RUN_ID") + val jobName = sys.env("GITHUB_JOB") + Logger.info(s"Getting URL for Run ID: ${runID}, job ${jobName}") + val response = ujson.read( + requests.get.stream(s"https://api.github.com/repos/chipsalliance/t1/actions/runs/${runID}/jobs") + ) + response + .obj("jobs") + .arr + .filter(job => job.obj("name").str == jobName) + .map(job => job.obj("html_url").str) + .head + end findCurrentJobURL + // PostCI do the below four things: // * read default.json at .github/cases/$config/default.json // * generate case information for each entry in default.json (cycle, run success) diff --git a/script/default.nix b/script/default.nix index ded4d6e44..a839b099a 100644 --- a/script/default.nix +++ b/script/default.nix @@ -30,7 +30,7 @@ let ./build.sc ]; }; - millDepsHash = "sha256-QQ5gCbvovC55t9MmfCNTvNFdD6FcNqmLmfhT9qJhQQc="; + millDepsHash = "sha256-DAEgWFDUX22IfQ0N7j3icPjjrND3612leUT0qqXp+Zc="; }; passthru.withLsp = self.overrideAttrs (old: {