From 7eb2d2999c789ce3fef6606924d6f03cd6bc27e6 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 11 Jan 2024 22:57:17 +0800 Subject: [PATCH] select package by random --- .github/workflows/autoupdate.yml | 5 +---- scripts/autoupdate.lua | 6 ++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/autoupdate.yml b/.github/workflows/autoupdate.yml index 03661b0dfb2..22493b4c55b 100644 --- a/.github/workflows/autoupdate.yml +++ b/.github/workflows/autoupdate.yml @@ -3,9 +3,6 @@ name: Auto-update packages on: schedule: # execute every 24 hours - cron: "0 */24 * * *" - pull_request: - branches: - - dev jobs: build: @@ -40,6 +37,6 @@ jobs: - name: Auto-update packages run: | - xmake l -vD scripts/autoupdate.lua 1 + xmake l -vD scripts/autoupdate.lua 3 diff --git a/scripts/autoupdate.lua b/scripts/autoupdate.lua index 4519d889f75..5af9771a472 100644 --- a/scripts/autoupdate.lua +++ b/scripts/autoupdate.lua @@ -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