Compare commits

..

2 Commits

8 changed files with 35 additions and 16 deletions

View File

@ -8,19 +8,19 @@ set -ex
# install dependencies
echo -e '[arcanisrepo]\nServer = https://repo.arcanis.me/$arch\nSigLevel = Never' | tee -a /etc/pacman.conf
# refresh the image
pacman -Syu --noconfirm
pacman -Syyu --noconfirm
# main dependencies
pacman -Sy --noconfirm devtools git pyalpm python-inflection python-passlib python-pyelftools python-requests python-srcinfo python-systemd sudo
pacman -S --noconfirm devtools git pyalpm python-inflection python-passlib python-pyelftools python-requests python-srcinfo python-systemd sudo
# make dependencies
pacman -Sy --noconfirm --asdeps base-devel python-build python-flit python-installer python-tox python-wheel
pacman -S --noconfirm --asdeps base-devel python-build python-flit python-installer python-tox python-wheel
# optional dependencies
if [[ -z $MINIMAL_INSTALL ]]; then
# VCS support
pacman -Sy --noconfirm breezy darcs mercurial subversion
pacman -S --noconfirm breezy darcs mercurial subversion
# web server
pacman -Sy --noconfirm python-aioauth-client python-aiohttp python-aiohttp-apispec-git python-aiohttp-cors python-aiohttp-jinja2 python-aiohttp-security python-aiohttp-session python-cryptography python-jinja
pacman -S --noconfirm python-aioauth-client python-aiohttp python-aiohttp-apispec-git python-aiohttp-cors python-aiohttp-jinja2 python-aiohttp-security python-aiohttp-session python-cryptography python-jinja
# additional features
pacman -Sy --noconfirm gnupg python-boto3 python-cerberus python-matplotlib rsync
pacman -S --noconfirm gnupg python-boto3 python-cerberus python-matplotlib rsync
fi
# FIXME since 1.0.4 devtools requires dbus to be run, which doesn't work now in container
cp "docker/systemd-nspawn.sh" "/usr/local/bin/systemd-nspawn"

View File

@ -4,7 +4,7 @@
set -ex
# install dependencies
pacman --noconfirm -Syu base-devel python-tox
pacman --noconfirm -Syyu base-devel python-tox
# run test and check targets
tox

View File

@ -50,10 +50,10 @@ class Update(Handler):
packages = application.updates(args.package, aur=args.aur, local=args.local, manual=args.manual, vcs=args.vcs,
check_files=args.check_files)
if args.dry_run: # some check specific actions
if args.changes: # generate changes if requested
application.changes(packages)
if args.dry_run: # exit from application if no build requested
Update.check_if_empty(args.exit_code, not packages) # status code check
return

View File

@ -79,8 +79,9 @@ class Executor(PackageInfo, Cleaner):
with self.in_event(single.base, EventType.PackageUpdated, failure=EventType.PackageUpdateFailed):
packager = self.packager(packagers, single.base)
last_commit_sha = build_single(single, Path(dir_name), packager.packager_id)
# clear changes and update commit hash
self.reporter.package_changes_update(single.base, Changes(last_commit_sha))
# update commit hash for changes keeping current diff if there is any
changes = self.reporter.package_changes_get(single.base)
self.reporter.package_changes_update(single.base, Changes(last_commit_sha, changes.changes))
# update dependencies list
package_archive = PackageArchive(self.paths.build_root, single, self.pacman, self.scan_paths)
dependencies = package_archive.depends_on()

View File

@ -153,6 +153,8 @@ class UpdateHandler(PackageInfo, Cleaner):
local = packages.get(remote.base)
if local is None:
continue # we don't add packages automatically
if local.remote.is_remote:
continue # avoid checking AUR packages
if local.is_outdated(remote, self.paths,
vcs_allowed_age=self.vcs_allowed_age,

View File

@ -64,7 +64,7 @@ def test_run(args: argparse.Namespace, package_ahriman: Package, configuration:
bump_pkgrel=args.increment)
updates_mock.assert_called_once_with(
args.package, aur=args.aur, local=args.local, manual=args.manual, vcs=args.vcs, check_files=args.check_files)
changes_mock.assert_not_called()
changes_mock.assert_called_once_with([package_ahriman])
dependencies_mock.assert_called_once_with([package_ahriman], process_dependencies=args.dependencies)
check_mock.assert_called_once_with(False, False)
on_start_mock.assert_called_once_with()
@ -100,12 +100,11 @@ def test_run_update_empty_exception(args: argparse.Namespace, package_ahriman: P
mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
mocker.patch("ahriman.application.application.Application.with_dependencies", return_value=[package_ahriman])
mocker.patch("ahriman.application.application.Application.print_updates")
changes_mock = mocker.patch("ahriman.application.application.Application.changes")
mocker.patch("ahriman.application.application.Application.changes")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
_, repository_id = configuration.check_loaded()
Update.run(args, repository_id, configuration, report=False)
changes_mock.assert_not_called()
check_mock.assert_called_once_with(True, True)

View File

@ -23,6 +23,8 @@ def test_process_build(executor: Executor, package_ahriman: Package, passwd: Any
init_mock = mocker.patch("ahriman.core.build_tools.task.Task.init", return_value="sha")
move_mock = mocker.patch("shutil.move")
status_client_mock = mocker.patch("ahriman.core.status.Client.set_building")
changes_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_get",
return_value=Changes("commit", "change"))
commit_sha_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_update")
depends_on_mock = mocker.patch("ahriman.core.build_tools.package_archive.PackageArchive.depends_on",
return_value=Dependencies())
@ -36,7 +38,7 @@ def test_process_build(executor: Executor, package_ahriman: Package, passwd: Any
move_mock.assert_called_once_with(Path(package_ahriman.base), executor.paths.packages / package_ahriman.base)
# must update status
status_client_mock.assert_called_once_with(package_ahriman.base)
commit_sha_mock.assert_called_once_with(package_ahriman.base, Changes("sha"))
commit_sha_mock.assert_called_once_with(package_ahriman.base, Changes("sha", "change"))
def test_process_build_bump_pkgrel(executor: Executor, package_ahriman: Package, mocker: MockerFixture) -> None:

View File

@ -212,6 +212,7 @@ def test_updates_local(update_handler: UpdateHandler, package_ahriman: Package,
"""
must check for updates for locally stored packages
"""
package_ahriman.remote = RemoteSource(source=PackageSource.Local, git_url="", web_url="", path="", branch="")
mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman])
mocker.patch("pathlib.Path.iterdir", return_value=[Path(package_ahriman.base)])
fetch_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.fetch")
@ -237,6 +238,7 @@ def test_updates_local_ignore_vcs(update_handler: UpdateHandler, package_ahriman
"""
must skip VCS packages check if requested for locally stored packages
"""
package_ahriman.remote = RemoteSource(source=PackageSource.Local, git_url="", web_url="", path="", branch="")
mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman])
mocker.patch("pathlib.Path.iterdir", return_value=[Path(package_ahriman.base)])
mocker.patch("ahriman.core.build_tools.sources.Sources.fetch")
@ -263,6 +265,19 @@ def test_updates_local_unknown(update_handler: UpdateHandler, package_ahriman: P
assert update_handler.updates_local(vcs=True) == []
def test_updates_local_remote(update_handler: UpdateHandler, package_ahriman: Package, mocker: MockerFixture) -> None:
"""
must skip packages with remote source
"""
mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman])
mocker.patch("pathlib.Path.iterdir", return_value=[Path(package_ahriman.base)])
mocker.patch("ahriman.models.package.Package.is_outdated", return_value=True)
mocker.patch("ahriman.core.build_tools.sources.Sources.fetch")
mocker.patch("ahriman.models.package.Package.from_build", return_value=package_ahriman)
assert update_handler.updates_local(vcs=True) == []
def test_updates_local_with_failures(update_handler: UpdateHandler, package_ahriman: Package,
mocker: MockerFixture) -> None:
"""