From 2b6ee690609d77040c4cd856ebf3e6c727a0c0fe Mon Sep 17 00:00:00 2001 From: Julien Moura Date: Wed, 3 Jun 2026 12:17:29 +0200 Subject: [PATCH 1/2] add(option): 'repository_plugin_url' to set the custom plugin repository (plugins.xml) base URL It allows the user to set it once for all in the config file instead of specifying it for every package command run. It still can be overriden by the -u/--plugin-repo-url CLI option. Funded by Oslandia --- .qgis-plugin-ci | 1 + docs/configuration/options.md | 3 ++- qgispluginci/cli.py | 4 +++- qgispluginci/parameters.py | 10 +++++++++- test/fixtures/.qgis-plugin-ci | 1 + test/test_parameters.py | 10 ++++++++++ test/test_release.py | 33 +++++++++++++++++++++++++++++++++ 7 files changed, 59 insertions(+), 3 deletions(-) diff --git a/.qgis-plugin-ci b/.qgis-plugin-ci index 908a4bb8..337eb9cb 100644 --- a/.qgis-plugin-ci +++ b/.qgis-plugin-ci @@ -3,6 +3,7 @@ github_organization_slug: opengisch plugin_path: qgis_plugin_CI_testing project_slug: qgis-plugin-ci repository_plugin_id: "demo.qgis-plugins.ci:99999" +repository_plugin_url: https://opengisch.github.io/qgis-plugin-ci/ repository_url_raw: https://raw.githubusercontent.com/opengisch/qgis-plugin-ci repository_url: https://github.com/opengisch/qgis-plugin-ci/ timezone: Europe/Paris diff --git a/docs/configuration/options.md b/docs/configuration/options.md index 86bf3ca1..e984100b 100644 --- a/docs/configuration/options.md +++ b/docs/configuration/options.md @@ -32,7 +32,8 @@ QGIS-Plugin-CI is best served if you use these two conventions: | `plugin_path` | **yes** | The folder where the source code is located. Shouldn't have any dash character. Defaults to: `slugify(plugin_name)`. | qgis_plugin_CI_testing | | `project_slug` | no | The *project* slug on SCM host (e.g. Github) and translation platform (e.g. Transifex).
Not required when running on Travis since deduced from `$TRAVIS_REPO_SLUG`environment variable. | `qgis-plugin-ci` | | `repository_plugin_id` | no | The plugin identifier in the repository where it is published or is intended to be published. | Typically the same `plugin_id` value than on the official repository, i.e. `"3951"`. Or using a DNS prefix: `plugins.myorg.com:99999` | -| `repository_url_raw` | no | | `https://raw.githubusercontent.com/opengisch/qgis-plugin-ci` for a plugin hosted on Github; `https://gitlab.com/Oslandia/qgis/oslandia/-/raw/` for a plugin hosted on gitlab. | +| `repository_plugin_url` | no | Base URL for the custom plugins repository. Equivalent to and can be overridden by the `-u`/`--plugin-repo-url` CLI option. Typically, the GitHub/GitLab Pages base URL of your project. | `https://opengisch.github.io/qgis-plugin-ci/` for this project. `https://oslandia.gitlab.io/qgis/oslandia/` for this plugin hosted on public GitLab instance. | +| `repository_url_raw` | no | Base URL to the source code repository. | `https://raw.githubusercontent.com/opengisch/qgis-plugin-ci` for a plugin hosted on Github; `https://gitlab.com/Oslandia/qgis/oslandia/-/raw/` for a plugin hosted on gitlab. | | `timezone` | no | The timezone for the plugin creation date. Defaults to: `UTC`. | `Europe/Paris` | ---- diff --git a/qgispluginci/cli.py b/qgispluginci/cli.py index e1b9038c..48625a99 100755 --- a/qgispluginci/cli.py +++ b/qgispluginci/cli.py @@ -234,12 +234,14 @@ def cli(): # PACKAGE if args.command == "package": + # repo url from CLI option or from config file + plugin_repo_url = args.plugin_repo_url or parameters.plugin_repo_url release( parameters, release_version=args.release_version, tx_api_token=args.transifex_token, allow_uncommitted_changes=args.allow_uncommitted_changes, - plugin_repo_url=args.plugin_repo_url, + plugin_repo_url=plugin_repo_url, plugin_repo_stylesheet=not args.no_repository_stylesheet, disable_submodule_update=args.disable_submodule_update, asset_paths=args.asset_path, diff --git a/qgispluginci/parameters.py b/qgispluginci/parameters.py index 6be726cb..d0fafd4e 100755 --- a/qgispluginci/parameters.py +++ b/qgispluginci/parameters.py @@ -106,6 +106,12 @@ class Parameters: The plugin identifier in the repository where it is published or is intended to be published. Defaults to None. + repository_plugin_url: str + Base URL used to build the plugin download hyperlink in the custom plugins repository + plugins.xml. + Can be overriden with the CLI option -u / --plugin-repo-url. + Defaults to None. + lrelease_path: str The path of lrelease executable @@ -120,7 +126,7 @@ class Parameters: Defaults to False repository_url_raw: str - Raw URL to plugin repository. Used to determine absolute URL to resources like + Raw URL to source code repository. Used to determine absolute URL to resources like plugin's icon in the custom repository plugins.xml. Defaults to None. """ @@ -229,6 +235,8 @@ def __init__(self, definition: dict[str, Any]): os.environ.get("TRAVIS_REPO_SLUG", "").split("/")[0], ) self.repository_url_raw: str | None = definition.get("repository_url_raw") + self.plugin_repo_url: str | None = definition.get("repository_plugin_url") + self.transifex_organization = definition.get( "transifex_organization", self.github_organization_slug ) diff --git a/test/fixtures/.qgis-plugin-ci b/test/fixtures/.qgis-plugin-ci index 80f42631..c08812eb 100644 --- a/test/fixtures/.qgis-plugin-ci +++ b/test/fixtures/.qgis-plugin-ci @@ -12,5 +12,6 @@ timezone: Europe/Paris repository_url: https://github.com/opengisch/qgis-plugin-ci/ repository_plugin_id: plugins.qgis.org:99999 +repository_plugin_url: https://opengisch.github.io/qgis-plugin-ci/ #lrelease_path: /usr/local/opt/qt5/bin/lrelease diff --git a/test/test_parameters.py b/test/test_parameters.py index d4a7888d..a68c888e 100644 --- a/test/test_parameters.py +++ b/test/test_parameters.py @@ -36,3 +36,13 @@ def test_global_parameters(self): self.assertEqual("qgis_plugin_CI_testing", parameters.plugin_path) self.assertEqual("CHANGELOG.md", parameters.changelog_path) + self.assertIsNone(parameters.plugin_repo_url) + + def test_plugin_repo_url_from_config(self): + """plugin_repo_url doit ĂȘtre lu depuis le fichier de config.""" + parameters = Parameters.make_from( + path_to_config_file=Path("test/fixtures/.qgis-plugin-ci") + ) + self.assertEqual( + "https://opengisch.github.io/qgis-plugin-ci/", parameters.plugin_repo_url + ) diff --git a/test/test_release.py b/test/test_release.py index e4f98833..50804885 100755 --- a/test/test_release.py +++ b/test/test_release.py @@ -352,6 +352,39 @@ def test_create_plugin_repo_disable_stylesheet(self): finally: os.chdir(original_dir) + def test_package_plugin_repo_url_from_config(self): + """Test plugin_repo_url from config repository_plugin_url.""" + self.assertEqual( + "https://opengisch.github.io/qgis-plugin-ci/", + self.qgis_plugin_config_params.plugin_repo_url, + ) + + archive_name = self.qgis_plugin_config_params.archive_name( + self.qgis_plugin_config_params.plugin_path, RELEASE_VERSION_TEST + ) + original_dir = Path().cwd() + with TemporaryDirectory() as tmp_dir: + try: + os.chdir(tmp_dir) + xml_path = create_plugin_repo( + parameters=self.qgis_plugin_config_params, + release_version=RELEASE_VERSION_TEST, + release_tag=RELEASE_VERSION_TEST, + archive=archive_name, + plugin_repo_url=self.qgis_plugin_config_params.plugin_repo_url, + ) + content = Path(xml_path).read_text(encoding="utf-8") + expected_url = ( + f"https://opengisch.github.io/qgis-plugin-ci/{archive_name}" + ) + self.assertIn( + expected_url, + content, + "Download hyperlink must be the one set in config file", + ) + finally: + os.chdir(original_dir) + if __name__ == "__main__": unittest.main() From 7d90de76e4d69462345c475736dfdc003a3ac62a Mon Sep 17 00:00:00 2001 From: Julien <1596222+Guts@users.noreply.github.com> Date: Wed, 3 Jun 2026 19:43:50 +0200 Subject: [PATCH 2/2] Update test/test_parameters.py --- test/test_parameters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_parameters.py b/test/test_parameters.py index a68c888e..da40fa6a 100644 --- a/test/test_parameters.py +++ b/test/test_parameters.py @@ -39,7 +39,7 @@ def test_global_parameters(self): self.assertIsNone(parameters.plugin_repo_url) def test_plugin_repo_url_from_config(self): - """plugin_repo_url doit ĂȘtre lu depuis le fichier de config.""" + """--plugin-repo-url must be read from config file (repository_plugin_url).""" parameters = Parameters.make_from( path_to_config_file=Path("test/fixtures/.qgis-plugin-ci") )