Merge updates from master

This commit is contained in:
Repository mirror & CI committed 2026-09-07 10:31:04 +00:00
commit a7d3c0f4ed
11 files changed
+354 -5

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env python3
# A quick and dirty Python script to send a message to an IRC channel.
import os
import socket
import ssl
nick = bytes(os.getenv("IRC_NICK", "notguru-cicd"), "ascii")
host = os.getenv("IRC_HOST", "irc.libera.chat")
port = int(os.getenv("IRC_PORT", "6697"))
channel = bytes(os.getenv("IRC_CHANNEL", "##notgentoo-guru"), "ascii")
message = bytes(os.getenv("IRC_MESSAGE", "Howdy!"), "ascii")
context = ssl.create_default_context()
def main():
print("Connecting to IRC network...")
sock = socket.create_connection((host, port))
ssock = context.wrap_socket(sock, server_hostname=host)
# Let the server speak up first before we send anything
buf = ssock.recv()
if len(buf) == 0:
raise Exception("Unexpected disconnect")
# Identify ourselves to the server, then join a channel to send a message.
# We send VERSION last since the response (351) is predictable and used as
# an indicator that everything was received.
print("Sending commands...")
command = (
b"NICK " + nick + b"\n" +
b"USER " + nick + b" 0 0 :" + nick + b"\n" +
b"JOIN " + channel + b"\n" +
b"PRIVMSG " + channel + b" :" + message + b"\n" +
b"VERSION\n"
)
ssock.sendall(command)
print("Waiting for response...")
while True:
buf = ssock.recv()
if len(buf) == 0:
raise Exception("Unexpected disconnect")
lines = buf.split(b"\n")
for line in lines:
parts = line.split()
if len(parts) > 1 and parts[1] == b"351":
print("Message sent!")
return
main()
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env python3
# Quick and dirty Python script to replace the behavior of a `gh`
# command that got the last CI/CD status of a given workflow.
import http.client
import json
import os
host = "codeberg.org"
owner = os.getenv("REPO_OWNER")
name = os.getenv("REPO_NAME")
workflow = os.getenv("REPO_WORKFLOW")
path = (
f"/api/v1/repos/{owner}/{name}/actions/runs/?workflow_id={workflow}"
"&page=1&limit=1"
)
def main():
conn = http.client.HTTPSConnection(host)
conn.request("GET", path)
response = conn.getresponse()
if response.status != 200:
print(f"Didn't get 200 OK! Got {response.status} instead.")
print(
"The response body may be helpful: "
f"{response.read().decode('utf-8')}"
)
exit(1)
j = json.loads(response.read())
# The first workflow run should be the most recent one
print(j["workflow_runs"][0]["status"])
main()
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env python3
# Similar to last_status.py, this is just a script to replace the `gh`
# cli behavior with the forgejo/codeberg equivalent. Gets the last
# commit that had a successful run for the given job.
import http.client
import json
import os
host = "codeberg.org"
owner = os.getenv("REPO_OWNER")
name = os.getenv("REPO_NAME")
workflow = os.getenv("REPO_WORKFLOW")
path = (
f"/api/v1/repos/{owner}/{name}/actions/runs/?workflow_id={workflow}"
f"&status=success&page=1&limit=1"
)
def main():
conn = http.client.HTTPSConnection(host)
conn.request("GET", path)
response = conn.getresponse()
if response.status != 200:
print(f"Didn't get 200 OK! Got {response.status} instead.")
print(
"The response body may be helpful: "
f"{response.read().decode('utf-8')}"
)
exit(1)
j = json.loads(response.read())
# If run has literally never succeeded before, assume failure
if j["total_count"] == 0:
print("none") # this'll cause VALID=false later?
else:
# The first workflow run should be the most recent one
print(j["workflow_runs"][0]["commit_sha"])
main()
+31
View File
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# All of this is lifted from pkgcore/pkgcheck-action; please see [1] for
# the real brains behind this work. All I've done is moved the logic
# into a standalone bash script so that we're as forge-agnostic as
# possible.
# [1]: https://github.com/pkgcore/pkgcheck-action/graphs/contributors?all=1
# ::(end)group:: is used to mark sections of collapsible CI/CD logs.
runner() {
echo "::group::${1}"
shift 1
"$@"
local exit=$?
echo
echo "::endgroup::"
return $exit
}
runner "Sync gentoo repo" \
pmaint sync gentoo
runner "Update repo metadata" \
pmaint regen --dir ~/.cache/pkgcheck/repos .
runner "Marking workspace safe for git" \
git config --global --add safe.directory '*'
runner "Run pkgcheck" \
pkgcheck --color y ci --failures failures.json --exit GentooCI \
"${PKGCHECK_ARGS}"
scan_exit_status=$?
pkgcheck replay --color y failures.json
exit $scan_exit_status