launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #33011
[Merge] ~artemstreltsov/launchpad-buildd:add_launchpad_yaml into launchpad-buildd:master
Artem Streltsov has proposed merging ~artemstreltsov/launchpad-buildd:add_launchpad_yaml into launchpad-buildd:master.
Commit message:
Add .launchpad.yaml and a lint job
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~artemstreltsov/launchpad-buildd/+git/launchpad-buildd/+merge/493223
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~artemstreltsov/launchpad-buildd:add_launchpad_yaml into launchpad-buildd:master.
diff --git a/.flake8 b/.flake8
new file mode 100644
index 0000000..d0d5013
--- /dev/null
+++ b/.flake8
@@ -0,0 +1,4 @@
+[flake8]
+max-line-length = 79
+# These conflict with black
+ignore = E203, W503
diff --git a/.launchpad.yaml b/.launchpad.yaml
new file mode 100644
index 0000000..f913bf9
--- /dev/null
+++ b/.launchpad.yaml
@@ -0,0 +1,18 @@
+pipeline:
+ - docs
+ - lint
+
+jobs:
+ docs:
+ architectures: amd64
+ packages:
+ - tox
+ run: tox -e docs
+ series: focal
+ lint:
+ architectures: amd64
+ packages:
+ - tox
+ - git
+ run: tox -e lint
+ series: focal
diff --git a/lpbuildd/binarypackage.py b/lpbuildd/binarypackage.py
index 493567f..eca06fd 100644
--- a/lpbuildd/binarypackage.py
+++ b/lpbuildd/binarypackage.py
@@ -198,19 +198,21 @@ class BinaryPackageBuildManager(DebianBuildManager):
env["DEB_BUILD_OPTIONS"] = "noautodbgsym"
if self.isa_tag != self.abi_tag:
env["DEB_HOST_ARCH_VARIANT"] = self.isa_tag
- # By default when DEB_HOST_ARCH_VARIANT is set, dpkg will name the changes
- # file after the variant. But sbuild expects it to be named after the
- # underlying architecture, and if it can't find the changes file it it can't
- # find any of the other build artifacts either and so everything fails. It's
- # not possible to tell sbuild directly what changes filename to expect, but
- # you can supply a suffix. On the assumption abi_tag is a prefix of isa_tag
- # this works fine and this is not a totally unreasonable assumption.
+ # By default when DEB_HOST_ARCH_VARIANT is set, dpkg will name the
+ # changes file after the variant. But sbuild expects it to be
+ # named after the underlying architecture, and if it can't find
+ # the changes file it it can't find any of the other build
+ # artifacts either and so everything fails. It's not possible to
+ # tell sbuild directly what changes filename to expect, but you
+ # can supply a suffix. On the assumption abi_tag is a prefix of
+ # isa_tag this works fine and this is not a totally unreasonable
+ # assumption.
#
# (The cleanest way to avoid this assumption would be to patch
- # sbuild. Another would be to set the suffix to something arbitrary like
- # "foo" , which would result in a changes file called
- # "{spkg}_{version}_{abi_tag}foo.changes" which we could rename. But that
- # sounds gross.)
+ # sbuild. Another would be to set the suffix to something
+ # arbitrary like "foo" , which would result in a changes file
+ # called "{spkg}_{version}_{abi_tag}foo.changes" which we could
+ # rename. But that sounds gross.)
assert self.isa_tag.startswith(self.abi_tag)
suffix = self.isa_tag.replace(self.abi_tag, "", 1)
args.append("--dpkg-file-suffix=" + suffix)
diff --git a/lpbuildd/charm.py b/lpbuildd/charm.py
index 6101d96..02b5be2 100644
--- a/lpbuildd/charm.py
+++ b/lpbuildd/charm.py
@@ -38,7 +38,7 @@ class CharmBuildManager(BuildManagerProxyMixin, DebianBuildManager):
self.proxy_service = None
self.craft_platform = extra_args.get("craft_platform")
self.secrets = extra_args.get("secrets")
- self.use_fetch_service= extra_args.get("use_fetch_service")
+ self.use_fetch_service = extra_args.get("use_fetch_service")
super().initiate(files, chroot, extra_args)
diff --git a/lpbuildd/target/build_charm.py b/lpbuildd/target/build_charm.py
index 4210d0f..72541b1 100644
--- a/lpbuildd/target/build_charm.py
+++ b/lpbuildd/target/build_charm.py
@@ -44,7 +44,7 @@ class BuildCharm(
parser.add_argument(
"--craft-platform",
type=str,
- help="craft platform name used by the craft tool"
+ help="craft platform name used by the craft tool",
)
parser.add_argument(
"--use-fetch-service",
@@ -124,7 +124,7 @@ class BuildCharm(
logger.info("Running repo phase...")
env = self.build_proxy_environment(
proxy_url=self.args.proxy_url,
- use_fetch_service=self.args.use_fetch_service
+ use_fetch_service=self.args.use_fetch_service,
)
# using the fetch service requires shallow clones
git_shallow_clone = bool(self.args.use_fetch_service)
@@ -144,7 +144,7 @@ class BuildCharm(
check_path_escape(self.buildd_path, build_context_path)
env = self.build_proxy_environment(
proxy_url=self.args.proxy_url,
- use_fetch_service=self.args.use_fetch_service,
+ use_fetch_service=self.args.use_fetch_service,
)
if self.args.craft_platform:
env["CRAFT_PLATFORM"] = self.args.craft_platform
diff --git a/lpbuildd/target/build_craft.py b/lpbuildd/target/build_craft.py
index b36a661..25d5d1b 100644
--- a/lpbuildd/target/build_craft.py
+++ b/lpbuildd/target/build_craft.py
@@ -220,12 +220,12 @@ class BuildCraft(
# and the suffix(_URL or _READ_AUTH)
if key.endswith("_URL"):
# Remove CARGO_ prefix and _URL suffix
- name = key[len("CARGO_"):-len("_URL")]
+ name = key[len("CARGO_") : -len("_URL")]
# Convert URL to registry index
cargo_vars[f"CARGO_REGISTRIES_{name}_INDEX"] = value
elif key.endswith("_READ_AUTH"):
# Remove CARGO_ prefix and _READ_AUTH suffix
- name = key[len("CARGO_"):-len("_READ_AUTH")]
+ name = key[len("CARGO_") : -len("_READ_AUTH")]
# Extract token from user:token format
token = value.split(":", 1)[1]
cargo_vars[f"CARGO_REGISTRIES_{name}_TOKEN"] = (
@@ -278,7 +278,7 @@ class BuildCraft(
repository["url"] = value
# Extract repository name
# (e.g., MAVEN_ARTIFACTORY_URL -> artifactory)
- repo_name = key[6:-4].lower() # Remove MAVEN_ and _URL
+ repo_name = key[6:-4].lower() # Remove MAVEN_ and _URL
elif key.endswith("_READ_AUTH"):
user, token = value.split(":")
repository["username"] = user
@@ -293,12 +293,16 @@ class BuildCraft(
proxy_url = proxy_env["http_proxy"]
# Generate Maven settings.xml
- settings_xml = self._generate_maven_settings_xml(repo_name, repository, proxy_url)
+ settings_xml = self._generate_maven_settings_xml(
+ repo_name, repository, proxy_url
+ )
with self.backend.open(os.path.join(m2_dir, "settings.xml"), "w") as f:
f.write(settings_xml)
- def _generate_maven_settings_xml(self, repo_name, repository, proxy_url=None):
+ def _generate_maven_settings_xml(
+ self, repo_name, repository, proxy_url=None
+ ):
"""Generate Maven settings.xml for single virtual repository.
:param repo_name: Name/ID of the repository
@@ -336,7 +340,7 @@ class BuildCraft(
if proxy_url:
# Parse proxy URL to extract host, port, and credentials
parsed_proxy = urlparse(proxy_url)
-
+
proxies += (
" <proxy>\n"
" <id>default</id>\n"
@@ -384,7 +388,15 @@ class BuildCraft(
)
# Combine all parts
- return header + schema + servers + proxies + profiles + mirrors + "</settings>"
+ return (
+ header
+ + schema
+ + servers
+ + proxies
+ + profiles
+ + mirrors
+ + "</settings>"
+ )
def build(self):
"""Running build phase..."""
@@ -392,7 +404,7 @@ class BuildCraft(
proxy_url=self.args.proxy_url,
use_fetch_service=self.args.use_fetch_service,
)
-
+
# Set up credential files before building
cargo_env = self.setup_cargo_credentials()
self.setup_maven_credentials(proxy_env=env)
@@ -402,7 +414,7 @@ class BuildCraft(
"/home/buildd", self.args.name, self.args.build_path
)
check_path_escape(self.buildd_path, build_context_path)
-
+
if cargo_env:
env.update(cargo_env)
if self.args.launchpad_instance:
diff --git a/lpbuildd/target/lxd.py b/lpbuildd/target/lxd.py
index 65afbb5..ebf4392 100644
--- a/lpbuildd/target/lxd.py
+++ b/lpbuildd/target/lxd.py
@@ -145,7 +145,9 @@ class LXD(Backend):
"series": self.series,
"architecture": self.abi_tag,
"description": (
- f"Launchpad chroot for Ubuntu {self.series} ({self.abi_tag})"
+ "Launchpad chroot for Ubuntu "
+ f"{self.series} "
+ f"({self.abi_tag})"
),
},
}
diff --git a/lpbuildd/target/tests/test_build_craft.py b/lpbuildd/target/tests/test_build_craft.py
index 8fcdb81..465c0ae 100644
--- a/lpbuildd/target/tests/test_build_craft.py
+++ b/lpbuildd/target/tests/test_build_craft.py
@@ -1,3 +1,4 @@
+# flake8: noqa: E501
import json
import os
import stat
diff --git a/lpbuildd/tests/test_builder.py b/lpbuildd/tests/test_builder.py
index b43e7e1..f492c71 100644
--- a/lpbuildd/tests/test_builder.py
+++ b/lpbuildd/tests/test_builder.py
@@ -6,16 +6,15 @@
Most tests are done on subclasses instead.
"""
-from datetime import datetime, timezone
import io
import re
+from datetime import datetime, timezone
from fixtures import MockPatch, TempDir
from testtools import TestCase
from testtools.twistedsupport import AsynchronousDeferredRunTest
from twisted.internet import defer
from twisted.logger import FileLogObserver, formatEvent, globalLogPublisher
-from unittest import mock
from lpbuildd.builder import Builder, BuildManager, _sanitizeURLs
from lpbuildd.tests.fakebuilder import FakeConfig
@@ -89,9 +88,7 @@ class TestBuildManager(TestCase):
# Mock datetime.datetime.now() method
now = datetime.now()
mock_datetime = self.useFixture(
- MockPatch(
- "lpbuildd.builder.datetime"
- )
+ MockPatch("lpbuildd.builder.datetime")
).mock
mock_datetime.now = lambda: now
@@ -100,17 +97,19 @@ class TestBuildManager(TestCase):
manager.runSubProcess("echo", ["echo", "hello world"])
code = yield d
self.assertEqual(0, code)
-
+
# Prepare the same timestamp format as the buildlogs
timestamp = f"[{now.replace(tzinfo=timezone.utc).ctime()}]\n"
self.assertEqual(
- timestamp.encode() + "RUN: echo 'hello world'\n" "hello world\n".encode(),
+ timestamp.encode() + b"RUN: echo 'hello world'\n" b"hello world\n",
builder._log.getvalue(),
)
-
+
self.assertEqual(
- f"Build log: {timestamp}" + "Build log: RUN: echo 'hello world'\n" + "Build log: hello world\n",
+ f"Build log: {timestamp}"
+ + "Build log: RUN: echo 'hello world'\n"
+ + "Build log: hello world\n",
self.log_file.getvalue(),
)
@@ -125,9 +124,7 @@ class TestBuildManager(TestCase):
# Mock datetime.datetime.now() method
now = datetime.now()
mock_datetime = self.useFixture(
- MockPatch(
- "lpbuildd.builder.datetime"
- )
+ MockPatch("lpbuildd.builder.datetime")
).mock
mock_datetime.now = lambda: now
@@ -141,15 +138,16 @@ class TestBuildManager(TestCase):
timestamp = f"[{now.replace(tzinfo=timezone.utc).ctime()}]\n"
self.assertEqual(
- timestamp.encode() + "RUN: echo '\N{SNOWMAN}'\n" "\N{SNOWMAN}\n".encode(),
+ timestamp.encode() + "RUN: echo '\N{SNOWMAN}'\n"
+ "\N{SNOWMAN}\n".encode(),
builder._log.getvalue(),
)
- # Separated the tests with self.log_file to ensure the regex tests of
+ # Separated the tests with self.log_file to ensure the regex tests of
# the second part don't mix with timestamp equality test.
self.assertEqual(
- f"Build log: {timestamp}"[:-1], # Excluding the newline character
- self.log_file.getvalue().splitlines()[0]
+ f"Build log: {timestamp}"[:-1], # Excluding the newline character
+ self.log_file.getvalue().splitlines()[0],
)
self.assertEqual(
diff --git a/tox.ini b/tox.ini
index 83137f5..600819c 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,7 @@
[tox]
-env_list = docs
+env_list =
+ docs
+ lint
[testenv:docs]
description = Build documentation via Sphinx.
@@ -7,3 +9,12 @@ basepython = python3
extras = docs
commands =
sphinx-build -W -b html -d docs/_build/doctrees docs docs/_build/html
+
+[testenv:lint]
+skip_install = true
+deps = pre-commit
+commands = pre-commit run --all-files --show-diff-on-failure
+passenv =
+ HOME
+ http_proxy
+ https_proxy