Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .qgis-plugin-ci
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion docs/configuration/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).<br/>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. |
Comment thread
Guts marked this conversation as resolved.
| `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. |
Comment thread
Guts marked this conversation as resolved.
| `timezone` | no | The timezone for the plugin creation date. Defaults to: `UTC`. | `Europe/Paris` |

----
Expand Down
4 changes: 3 additions & 1 deletion qgispluginci/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 9 additions & 1 deletion qgispluginci/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
"""
Expand Down Expand Up @@ -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
)
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/.qgis-plugin-ci
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions test/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 must be read from config file (repository_plugin_url)."""
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
)
33 changes: 33 additions & 0 deletions test/test_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Loading