Skip to content
Snippets Groups Projects
Verified Commit 45bbc29a authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

cgit/tasks: Allow passing extra parameters to task

This unifies with other lister tasks modules. And this allow the cgit task to
be scheduled by the add-forge-now scheduler cli.

Refs. swh/infra/sysadm-environment#4813
parent 571d69f9
No related branches found
No related tags found
No related merge requests found
# Copyright (C) 2019-2021 The Software Heritage developers # Copyright (C) 2019 The Software Heritage developers
# License: GNU General Public License version 3, or any later version # License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information # See top-level LICENSE file for more information
from typing import Dict, Optional from typing import Dict
from celery import shared_task from celery import shared_task
...@@ -10,13 +10,9 @@ from .lister import CGitLister ...@@ -10,13 +10,9 @@ from .lister import CGitLister
@shared_task(name=__name__ + ".CGitListerTask") @shared_task(name=__name__ + ".CGitListerTask")
def list_cgit( def list_cgit(**lister_args) -> Dict[str, str]:
url: str, instance: Optional[str] = None, base_git_url: Optional[str] = None
) -> Dict[str, str]:
"""Lister task for CGit instances""" """Lister task for CGit instances"""
lister = CGitLister.from_configfile( lister = CGitLister.from_configfile(**lister_args)
url=url, instance=instance, base_git_url=base_git_url
)
return lister.run().dict() return lister.run().dict()
......
# Copyright (C) 2019-2021 The Software Heritage developers # Copyright (C) 2019 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution # See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version # License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information # See top-level LICENSE file for more information
...@@ -22,7 +22,9 @@ def test_cgit_lister_task( ...@@ -22,7 +22,9 @@ def test_cgit_lister_task(
lister.from_configfile.return_value = lister lister.from_configfile.return_value = lister
lister.run.return_value = ListerStats(pages=10, origins=500) lister.run.return_value = ListerStats(pages=10, origins=500)
kwargs = dict(url="https://git.kernel.org/", instance="kernel", base_git_url=None) kwargs = dict(
url="https://git.kernel.org/", instance="kernel", base_git_url=None, max_pages=1
)
res = swh_scheduler_celery_app.send_task( res = swh_scheduler_celery_app.send_task(
"swh.lister.cgit.tasks.CGitListerTask", "swh.lister.cgit.tasks.CGitListerTask",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment