Skip to content

Commit

Permalink
select package by random
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Jan 11, 2024
1 parent 87f5344 commit bbee5da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/autoupdate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ jobs:

- name: Auto-update packages
run: |
xmake l -vD scripts/autoupdate.lua 1
xmake l -vD scripts/autoupdate.lua 3
6 changes: 4 additions & 2 deletions scripts/autoupdate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ function main(maxcount)
local count = 0
local maxcount = tonumber(maxcount or 10)
local instances = _get_all_packages()
for _, instance in ipairs(instances) do
math.randomseed(os.time())
while count < maxcount do
local instance = instances[math.random(#instances)]
local checkupdate_filepath = path.join(instance:scriptdir(), "checkupdate.lua")
if not os.isfile(checkupdate_filepath) then
checkupdate_filepath = path.join(os.scriptdir(), "checkupdate.lua")
end
if os.isfile(checkupdate_filepath) and count < maxcount then
if os.isfile(checkupdate_filepath) then
local checkupdate = import("checkupdate", {rootdir = path.directory(checkupdate_filepath), anonymous = true})
local version, shasum = checkupdate(instance)
if version and shasum and not _is_pending(instance, version) then
Expand Down

0 comments on commit bbee5da

Please sign in to comment.