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 7eb2d29
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/autoupdate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ name: Auto-update packages
on:
schedule: # execute every 24 hours
- cron: "0 */24 * * *"
pull_request:
branches:
- dev

jobs:
build:
Expand Down Expand Up @@ -40,6 +37,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 7eb2d29

Please sign in to comment.