Closed fantom-x closed 11 months ago
I'm guessing that's very hard to implement. A PR on GitHub would have to inform the Buildbots to then notify GitHub actions to build something.
Yeah, I realize that. My workaround is to just delete all files and folders under /builder/
, download the latest IB file, untar it, then run make
. Works very well for me.
Could the official image also download the latest file?
Yea I thought about that, too. At least for snapshot a script inside the image builder could just download the latest image builder an unpack it. Mind creating a PR?
I could do a PR, but I am not sure where to get all the info to generate a URL to an appropriate IB file. Any advice?
BTW, why only snapshots? Even stable releases could download the IB tar file: it does not change.
Would not it be simpler to generate images every second day like in master?
High resource usage...
Then there could be just one Docker image for all releases (or one per a release) and it downloads the latest IB tar. This will save even more resources: this image will not have to be rebuilt over and over...
for all snapshots, yea. I think that could be a viable solution for snapshots as well as nightly builds of releases.
import requests
from time import sleep
from os import getenv
dispatch_url = "https://api.github.com/repos/openwrt/docker/actions/workflows/containers.yml/dispatches"
last_completed_at = 1696021746
def webhook(ref, target):
req = requests.post(
dispatch_url,
headers={
"Accept": "application/vnd.github.v3+json",
"X-GitHub-Api-Version": "2022-11-28",
"Authorization": f"Bearer {getenv('GITHUB_TOKEN')}",
},
json={
"ref": "main",
"inputs": {
"ref": ref,
"target": target,
},
},
)
req.raise_for_status()
sleep(2)
while True:
builds = requests.get(
"https://buildbot.staging.openwrt.org/images/api/v2/builds?complete=true&limit=20&order=-buildid"
).json()["builds"]
for build in reversed(builds):
properties = requests.get(
f"https://buildbot.staging.openwrt.org/images/api/v2/builds/{build['buildid']}/properties"
).json()["properties"][0]
if "tag" in properties:
ref = properties["tag"][0]
else:
ref = properties["branch"][0]
target = properties["buildername"][0].split("_", maxsplit=1)[1]
if build.get("state_string") == "build successful" and target != "force_build":
completed_at = build["complete_at"]
if completed_at > last_completed_at:
print(
f"New successful build found for {target} on {ref} at {completed_at}"
)
webhook(ref, target)
last_completed_at = completed_at
sleep(60)
This script checks every 60 seconds the last builds and triggers docker rebuilds in case something finished. I'll deploy this script until Buildbot web hooks are available.
If the first build in builds
completes at 1400, then you start a docker build and save 1400 to last_completed_at
. Then you go to the second build and it happens to complete at 1355: this will be skipped because it is less than last_completed_at
. I think you need a dictionary for last_completed_at
...
Yes I've figured this issue and switch to completed_at
only. See the PR. Thanks for reviewing :)!
Just looked at #123 and it still the code like above: did you not push your latest changes?
I understand that 22.03 (SNAPHOT) images are built once week, but they periodically break for up to seven days when a kernel is refreshed: below is an attempt to generate a 22.03-SNAPSHOT image right now. The issue will resolve itself in five days or so when a new image builder image is generated.
Is it possible to refresh these images each time a new kernel is built?