Browse Source

CI: Create issues for packages that failed to auto-update (#8567)

* add deleted repo handling

* fix typo

* update

* update
Willaaaaaaa 1 month ago
parent
commit
52ef76f14e
2 changed files with 26 additions and 3 deletions
  1. 18 1
      scripts/autoupdate.lua
  2. 8 2
      scripts/checkupdate.lua

+ 18 - 1
scripts/autoupdate.lua

@@ -108,6 +108,21 @@ function _update_version(instance, version, shasum)
     os.vexec("git checkout %s", branch_current)
     os.vexec("git checkout %s", branch_current)
 end
 end
 
 
+function _report_issue(instance)
+    local package_name = instance:name()
+    local curr_open_issue = os.iorun("gh issue list --label \"help wanted\" --label \"auto-update\" --search \"in:title [auto-update] %s requires manual handling\" -R xmake-io/xmake-repo --json number",
+        package_name)
+    if curr_open_issue == "[]\n" then
+        local body = string.format("Failed to get tags of %s, which may be due to changes in repository visibility.",
+            package_name)
+        local title = "[auto-update] " .. package_name .. " requires manual handling."
+        os.vexec("gh issue create --title \"%s\" --body \"%s\" --label \"help wanted,auto-update\" -R xmake-io/xmake-repo",
+            title, body)
+    else
+        print("Found a known open issue #%s for package %s", curr_open_issue:trim(), package_name)
+    end
+end
+
 function main(pattern)
 function main(pattern)
     local count = 0
     local count = 0
     local maxcount = 5
     local maxcount = 5
@@ -127,7 +142,9 @@ function main(pattern)
         if os.isfile(checkupdate_filepath) then
         if os.isfile(checkupdate_filepath) then
             local checkupdate = import("checkupdate", {rootdir = path.directory(checkupdate_filepath), anonymous = true})
             local checkupdate = import("checkupdate", {rootdir = path.directory(checkupdate_filepath), anonymous = true})
             local version, shasum = checkupdate(instance)
             local version, shasum = checkupdate(instance)
-            if version and shasum and not _is_pending(instance, version) then
+            if version == false then
+                _report_issue(instance)
+            elseif version and shasum and not _is_pending(instance, version) then
                 cprint("package(%s): new version ${bright}%s${clear} found, shasum: ${bright}%s", instance:name(), version, shasum)
                 cprint("package(%s): new version ${bright}%s${clear} found, shasum: ${bright}%s", instance:name(), version, shasum)
                 _update_version(instance, version, shasum)
                 _update_version(instance, version, shasum)
                 updated = true
                 updated = true

+ 8 - 2
scripts/checkupdate.lua

@@ -61,7 +61,10 @@ function _check_version_from_github_tags(package, url)
     if repourl then
     if repourl then
         print("checking version from github tags %s ..", repourl)
         print("checking version from github tags %s ..", repourl)
         local version_latest
         local version_latest
-        local tags = git.tags(repourl)
+        local tags = try {function() return git.tags(repourl) end}
+        if not tags then
+            return false  -- failed to get tags
+        end
         for _, tag in ipairs(tags) do
         for _, tag in ipairs(tags) do
             if _is_valid_version(tag) and (not version_latest or semver.compare(tag, version_latest) > 0) then
             if _is_valid_version(tag) and (not version_latest or semver.compare(tag, version_latest) > 0) then
                 version_latest = tag
                 version_latest = tag
@@ -79,7 +82,10 @@ function _check_version_from_github_releases(package, url)
         print("checking version from github releases %s ..", repourl)
         print("checking version from github releases %s ..", repourl)
         local list = try {function() return os.iorunv("gh", {"release", "list", "--exclude-drafts", "--exclude-pre-releases", "-R", repourl}) end}
         local list = try {function() return os.iorunv("gh", {"release", "list", "--exclude-drafts", "--exclude-pre-releases", "-R", repourl}) end}
         if not list then
         if not list then
-            list = os.iorunv("gh", {"release", "list", "-R", repourl})
+            list = try {function() return os.iorunv("gh", {"release", "list", "-R", repourl}) end}
+        end
+        if not list then
+            return false  -- failed to get tags
         end
         end
         if list then
         if list then
             local version_latest
             local version_latest