339 lines
9.7 KiB
Python
339 lines
9.7 KiB
Python
# -*- python -*-
|
|
# ex: set filetype=python:
|
|
|
|
import os
|
|
|
|
from buildbot.plugins import changes, reporters, schedulers, steps, util, worker
|
|
from buildbot.www.authz.roles import RolesFromBase
|
|
|
|
# This is a sample buildmaster config file. It must be installed as
|
|
# 'master.cfg' in your buildmaster's base directory.
|
|
|
|
# This is the dictionary that the buildmaster pays attention to. We also use
|
|
# a shorter alias to save typing.
|
|
c = BuildmasterConfig = {}
|
|
|
|
GITEA_SECRET = os.environ.get("GITEA_SECRET")
|
|
GITEA_TOKEN = os.environ.get("GITEA_TOKEN")
|
|
|
|
CLIENT_ID = os.environ.get("GITEA_CLIENT_ID")
|
|
assert CLIENT_ID
|
|
CLIENT_SECRET = os.environ.get("GITEA_CLIENT_SECRET")
|
|
assert CLIENT_SECRET
|
|
|
|
####### WORKERS
|
|
|
|
# The 'workers' list defines the set of recognized workers. Each element is
|
|
# a Worker object, specifying a unique worker name and password. The same
|
|
# worker name and password must be configured on the worker.
|
|
|
|
c["workers"] = [
|
|
worker.Worker("worker-rust-1-65", "pass", properties={"rust_version": "1.65"}),
|
|
worker.Worker("worker-rust-1-72", "pass", properties={"rust_version": "1.72"}),
|
|
worker.Worker("worker-rust-mdbook", "pass"),
|
|
]
|
|
rust_workers_1_65 = ["worker-rust-1-65"]
|
|
rust_workers_1_72 = ["worker-rust-1-72"]
|
|
rust_workers_mdbook = ["worker-rust-mdbook"]
|
|
|
|
if "BUILDBOT_MQ_URL" in os.environ:
|
|
c["mq"] = {
|
|
"type": "wamp",
|
|
"router_url": os.environ["BUILDBOT_MQ_URL"],
|
|
"realm": os.environ.get("BUILDBOT_MQ_REALM", "buildbot"),
|
|
"debug": "BUILDBOT_MQ_DEBUG" in os.environ,
|
|
"debug_websockets": "BUILDBOT_MQ_DEBUG" in os.environ,
|
|
"debug_lowlevel": "BUILDBOT_MQ_DEBUG" in os.environ,
|
|
}
|
|
# 'protocols' contains information about protocols which master will use for
|
|
# communicating with workers. You must define at least 'port' option that workers
|
|
# could connect to your master with this protocol.
|
|
# 'port' must match the value configured into the workers (with their
|
|
# --master option)
|
|
c["protocols"] = {"pb": {"port": os.environ.get("BUILDBOT_WORKER_PORT", 9989)}}
|
|
|
|
####### CHANGESOURCES
|
|
|
|
# the 'change_source' setting tells the buildmaster how it should find out
|
|
# about source code changes. Here we point to the buildbot clone of radn.
|
|
|
|
c["change_source"] = []
|
|
c["change_source"].append(
|
|
changes.GitPoller(
|
|
"https://gitea.parrrate.ru/PTV/radn-rs.git",
|
|
workdir="gitpoller/radn-rs",
|
|
branch="main",
|
|
pollinterval=300,
|
|
)
|
|
)
|
|
c["change_source"].append(
|
|
changes.GitPoller(
|
|
"https://gitea.parrrate.ru/PTV/exercises.git",
|
|
workdir="gitpoller/exercises",
|
|
branch="latest",
|
|
pollinterval=300,
|
|
)
|
|
)
|
|
|
|
####### BUILDERS
|
|
|
|
# The 'builders' list defines the Builders, which tell Buildbot how to perform a build:
|
|
# what steps, and which workers can execute them. Note that any particular build will
|
|
# only take place on one worker.
|
|
|
|
# all_repositories = {
|
|
# r"https://gitea.parrrate.ru/PTV/radn-rs.git": "radn-rs",
|
|
# }
|
|
|
|
|
|
# def codebaseGenerator(chdict):
|
|
# return all_repositories.get(chdict["repository"])
|
|
|
|
|
|
# c["codebaseGenerator"] = codebaseGenerator
|
|
|
|
c["builders"] = []
|
|
|
|
radn_builders = []
|
|
exercises_builders = []
|
|
|
|
CARGO_TARGET_DIR = "/buildbot/_rust/radn-rs/target"
|
|
RADN_ENV = {"CARGO_TARGET_DIR": CARGO_TARGET_DIR}
|
|
DOC_DIR = f"{CARGO_TARGET_DIR}/doc"
|
|
|
|
|
|
def radn_rs_factory():
|
|
factory = util.BuildFactory()
|
|
factory.addStep(
|
|
steps.Git(
|
|
repourl="https://gitea.parrrate.ru/PTV/radn-rs.git", mode="incremental"
|
|
)
|
|
)
|
|
return factory
|
|
|
|
|
|
def exercises_factory():
|
|
factory = util.BuildFactory()
|
|
factory.addStep(
|
|
steps.Git(
|
|
repourl="https://gitea.parrrate.ru/PTV/exercises.git", mode="incremental"
|
|
)
|
|
)
|
|
return factory
|
|
|
|
|
|
def radn_append_factory(factory, name: str, workernames: list[str]):
|
|
c["builders"].append(
|
|
util.BuilderConfig(name=name, workernames=workernames, factory=factory)
|
|
)
|
|
radn_builders.append(name)
|
|
|
|
|
|
def exercises_append_factory(factory, name: str, workernames: list[str]):
|
|
c["builders"].append(
|
|
util.BuilderConfig(name=name, workernames=workernames, factory=factory)
|
|
)
|
|
exercises_builders.append(name)
|
|
|
|
|
|
def cargo_test(name: str, workernames: list[str]):
|
|
factory = radn_rs_factory()
|
|
factory.addStep(
|
|
steps.ShellCommand(
|
|
command=["cargo", "test", "--workspace"],
|
|
env=RADN_ENV,
|
|
)
|
|
)
|
|
radn_append_factory(factory, name, workernames)
|
|
|
|
|
|
def cargo_clippy(name: str, workernames: list[str]):
|
|
factory = radn_rs_factory()
|
|
factory.addStep(
|
|
steps.ShellCommand(
|
|
command=[
|
|
"cargo",
|
|
"clippy",
|
|
"--workspace",
|
|
"--examples",
|
|
"--tests",
|
|
"--",
|
|
"--deny=warnings",
|
|
],
|
|
env=RADN_ENV,
|
|
)
|
|
)
|
|
radn_append_factory(factory, name, workernames)
|
|
|
|
|
|
def cargo_fmt(name: str, workernames: list[str]):
|
|
factory = radn_rs_factory()
|
|
factory.addStep(
|
|
steps.ShellCommand(
|
|
command=[
|
|
"cargo",
|
|
"fmt",
|
|
"--check",
|
|
"--all",
|
|
],
|
|
env=RADN_ENV,
|
|
)
|
|
)
|
|
radn_append_factory(factory, name, workernames)
|
|
|
|
|
|
def cargo_doc(name: str, workernames: list[str], specific: bool, latest: bool):
|
|
factory = radn_rs_factory()
|
|
factory.addStep(
|
|
steps.ShellCommand(
|
|
command=[
|
|
"cargo",
|
|
"doc",
|
|
"--workspace",
|
|
"--no-deps",
|
|
],
|
|
env=RADN_ENV,
|
|
)
|
|
)
|
|
if specific:
|
|
factory.addStep(
|
|
steps.DirectoryUpload(
|
|
workersrc=DOC_DIR,
|
|
masterdest=util.Interpolate(
|
|
"/buildbot_share/docs/radn-rs/%(prop:rust_version)s/"
|
|
),
|
|
url=util.Interpolate(
|
|
"https://radn.parrrate.ru/latest/docs/%(prop:rust_version)s/radn/"
|
|
),
|
|
compress="gz",
|
|
)
|
|
)
|
|
if latest:
|
|
factory.addStep(
|
|
steps.DirectoryUpload(
|
|
workersrc=DOC_DIR,
|
|
masterdest="/buildbot_share/docs/radn-rs/",
|
|
url="https://radn.parrrate.ru/latest/docs/radn/",
|
|
compress="gz",
|
|
)
|
|
)
|
|
radn_append_factory(factory, name, workernames)
|
|
|
|
|
|
def mdbook_test(name: str, workernames: list[str]):
|
|
factory = exercises_factory()
|
|
factory.addStep(
|
|
steps.ShellCommand(
|
|
command=["mdbook", "test", "."],
|
|
)
|
|
)
|
|
exercises_append_factory(factory, name, workernames)
|
|
|
|
|
|
cargo_test("cargo test (1.65)", rust_workers_1_65)
|
|
cargo_clippy("cargo clippy (1.65)", rust_workers_1_65)
|
|
cargo_clippy("cargo clippy (1.72)", rust_workers_1_72)
|
|
cargo_fmt("cargo fmt (1.72)", rust_workers_1_72)
|
|
cargo_doc("cargo doc (1.72)", rust_workers_1_72, False, True)
|
|
mdbook_test("mdbook test", rust_workers_mdbook)
|
|
|
|
####### SCHEDULERS
|
|
|
|
# Configure the Schedulers, which decide how to react to incoming changes.
|
|
|
|
c["schedulers"] = []
|
|
c["schedulers"].append(
|
|
schedulers.SingleBranchScheduler(
|
|
name="all-radn",
|
|
change_filter=util.ChangeFilter(branch="main"),
|
|
treeStableTimer=None,
|
|
builderNames=radn_builders,
|
|
)
|
|
)
|
|
c["schedulers"].append(
|
|
schedulers.SingleBranchScheduler(
|
|
name="all-exercises",
|
|
change_filter=util.ChangeFilter(branch="latest"),
|
|
treeStableTimer=None,
|
|
builderNames=exercises_builders,
|
|
)
|
|
)
|
|
c["schedulers"].append(
|
|
schedulers.ForceScheduler(name="force-radn", builderNames=radn_builders)
|
|
)
|
|
c["schedulers"].append(
|
|
schedulers.ForceScheduler(name="force-exercises", builderNames=exercises_builders)
|
|
)
|
|
|
|
####### REPORTER TARGETS
|
|
|
|
# 'services' is a list of Reporter Targets. The results of each build will be
|
|
# pushed to these targets. buildbot/reporters/*.py has a variety to choose from,
|
|
# like IRC bots.
|
|
|
|
c["services"] = []
|
|
|
|
####### PROJECT IDENTITY
|
|
|
|
# the 'title' string will appear at the top of this buildbot installation's
|
|
# home pages (linked to the 'titleURL').
|
|
|
|
c["title"] = "RADN"
|
|
c["titleURL"] = "https://gitea.parrrate.ru/PTV/radn-rs"
|
|
|
|
# the 'buildbotURL' string should point to the location where the buildbot's
|
|
# internal web server is visible. This typically uses the port number set in
|
|
# the 'www' entry below, but with an externally-visible host name which the
|
|
# buildbot cannot figure out without some help.
|
|
|
|
c["buildbotURL"] = os.environ.get("BUILDBOT_WEB_URL", "http://localhost:8010/")
|
|
|
|
|
|
class RolesFromCustom(RolesFromBase):
|
|
def getRolesFromUser(self, userDetails: dict):
|
|
if userDetails.get("is_admin") is True:
|
|
return ["admins"]
|
|
else:
|
|
return []
|
|
|
|
|
|
# minimalistic config to activate new web UI
|
|
c["www"] = {
|
|
"port": os.environ.get("BUILDBOT_WEB_PORT", 8010),
|
|
"plugins": {
|
|
"waterfall_view": {},
|
|
"console_view": {},
|
|
},
|
|
"change_hook_dialects": {},
|
|
"auth": util.GiteaAuth(
|
|
endpoint="https://gitea.parrrate.ru",
|
|
client_id=CLIENT_ID,
|
|
client_secret=CLIENT_SECRET,
|
|
),
|
|
"authz": util.Authz(
|
|
allowRules=[util.AnyControlEndpointMatcher(role="admins")],
|
|
roleMatchers=[RolesFromCustom()],
|
|
),
|
|
}
|
|
if GITEA_SECRET:
|
|
c["www"]["change_hook_dialects"]["gitea"] = {
|
|
"secret": GITEA_SECRET,
|
|
"onlyIncludePushCommit": True,
|
|
}
|
|
if GITEA_TOKEN:
|
|
c["services"].append(
|
|
reporters.GiteaStatusPush(
|
|
"https://gitea.parrrate.ru", token=GITEA_TOKEN, verbose=True
|
|
),
|
|
)
|
|
|
|
####### DB URL
|
|
|
|
c["db"] = {
|
|
# This specifies what database buildbot uses to store its state. You can leave
|
|
# this at its default for all but the largest installations.
|
|
"db_url": os.environ.get("BUILDBOT_DB_URL", "sqlite://").format(**os.environ),
|
|
}
|
|
|
|
c["buildbotNetUsageData"] = None
|