Skip to content

Commit

Permalink
Use the plugin folder to create the zip (#27)
Browse files Browse the repository at this point in the history
* Keep the plugin path when creating the ZIP

* Rename qgis_plugin_ci_testing to qgis_plugin_CI_testing to have a capital letter

* Update readme about plugin_path
  • Loading branch information
Gustry committed Aug 25, 2020
1 parent 6d8e9ec commit 53af5d3
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ __pycache__/
*.tar
*.zip

qgis_plugin_ci_testing/i18n
qgis_plugin_ci_testing/resources_rc.py
qgis_plugin_CI_testing/i18n
qgis_plugin_CI_testing/resources_rc.py

setup.py

Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "qgis_plugin_ci_testing/qgissettingmanager"]
path = qgis_plugin_ci_testing/qgissettingmanager
path = qgis_plugin_CI_testing/qgissettingmanager
url = https://github.com/opengisch/qgissettingmanager.git
2 changes: 1 addition & 1 deletion .qgis-plugin-ci
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


plugin_path: qgis_plugin_ci_testing
plugin_path: qgis_plugin_CI_testing
github_organization_slug: opengisch
project_slug: qgis-plugin-ci
transifex_coordinator: geoninja
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ The plugin must have a configuration, located at the top directory:

In the configuration, you should at least provide the following configuration:

* `plugin_path`
* `plugin_path`, the folder where the source code is located

Side note, the plugin path shouldn't have any dash character.

You can find a template `.qgis-plugin-ci` in this repository.
You can read the docstring of the file `qgispluginci/parameters.py`
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 7 additions & 2 deletions qgispluginci/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import warnings

CHANGELOG_REGEXP = r"(?<=##)\s*\[*(v?\d*\d\.\d*\d\.\d*\d)\]*\s-\s([\d\-/]{10})(.*?)(?=##)"
DASH_WARNING = 'Dash in the plugin name is causing issues with QGIS plugin manager'


class Parameters:
Expand Down Expand Up @@ -114,14 +115,18 @@ def __init__(self, definition: dict):
'It is a requirement to publish the plugin on the repository')
self.repository_url = self.__get_from_metadata('repository')

def archive_name(self, release_version: str, experimental: bool = False) -> str:
@staticmethod
def archive_name(plugin_name, release_version: str, experimental: bool = False) -> str:
"""
Returns the archive file name
"""
# zipname: use dot before version number
# and not dash since it's causing issues #22
if '-' in plugin_name:
warnings.warn(DASH_WARNING)

return '{zipname}{experimental}.{release_version}.zip'.format(
zipname=self.plugin_slug.replace('-', '_'),
zipname=plugin_name,
experimental='-experimental' if experimental else '',
release_version=release_version
)
Expand Down
4 changes: 2 additions & 2 deletions qgispluginci/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def release(parameters: Parameters,
tr.pull()
tr.compile_strings()

archive_name = parameters.archive_name(release_version)
archive_name = parameters.archive_name(parameters.plugin_path, release_version)

is_prerelease = False
if github_token is not None:
Expand All @@ -389,7 +389,7 @@ def release(parameters: Parameters,
# since only QGIS 3.14+ supports the beta/experimental plugins trial
experimental_archive_name = None
if osgeo_username is not None and is_prerelease:
experimental_archive_name = parameters.archive_name(release_version, True)
experimental_archive_name = parameters.archive_name(parameters.plugin_path, release_version, True)
create_archive(
parameters, release_version, experimental_archive_name,
add_translations=transifex_token is not None,
Expand Down
4 changes: 2 additions & 2 deletions test/plugins.xml.expected
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<version>0.1.2</version>
<qgis_minimum_version>3.2</qgis_minimum_version>
<homepage>https://github.com/opengisch/qgis-plugin-ci</homepage>
<file_name>qgis_plugin_ci_testing.0.1.2.zip</file_name>
<file_name>qgis_plugin_CI_testing.0.1.2.zip</file_name>
<icon>icons/opengisch.png</icon>
<author_name>Denis Rouzaud</author_name>
<download_url>https://github.com/opengisch/qgis-plugin-ci/releases/download/0.1.2/qgis_plugin_ci_testing.0.1.2.zip</download_url>
<download_url>https://github.com/opengisch/qgis-plugin-ci/releases/download/0.1.2/qgis_plugin_CI_testing.0.1.2.zip</download_url>
<uploaded_by>Denis Rouzaud</uploaded_by>
<create_date>1985-07-21</create_date>
<update_date>__TODAY__</update_date>
Expand Down
25 changes: 21 additions & 4 deletions test/test_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from pytransifex.exceptions import PyTransifexException

from qgispluginci.parameters import Parameters
from qgispluginci.parameters import Parameters, DASH_WARNING
from qgispluginci.release import release
from qgispluginci.translation import Translation
from qgispluginci.exceptions import GithubReleaseNotFound
Expand Down Expand Up @@ -68,6 +68,23 @@ def test_release_with_transifex(self):
t = Translation(self.parameters, transifex_token=self.transifex_token)
release(self.parameters, RELEASE_VERSION_TEST, transifex_token=self.transifex_token)

def test_zipname(self):
""" Tests about the zipname for the QGIS plugin manager.
See #22 about dash
and also capital letters
"""
self.assertEqual(
'my_plugin-experimental.0.0.0.zip',
Parameters.archive_name('my_plugin', '0.0.0', True))

self.assertEqual(
'My_Plugin.0.0.0.zip',
Parameters.archive_name('My_Plugin', '0.0.0', False))

with self.assertWarnsRegex(Warning, DASH_WARNING):
Parameters.archive_name('my-plugin', '0.0.0')

def test_release_upload_github(self):
release(self.parameters, RELEASE_VERSION_TEST, github_token=self.github_token, upload_plugin_repo_github=True)

Expand All @@ -85,7 +102,7 @@ def test_release_upload_github(self):

# compare archive file size
gh_release = self.repo.get_release(id=RELEASE_VERSION_TEST)
archive_name = self.parameters.archive_name(RELEASE_VERSION_TEST)
archive_name = self.parameters.archive_name(self.parameters.plugin_path, RELEASE_VERSION_TEST)
fs = os.path.getsize(archive_name)
print('size: ', fs)
self.assertGreater(fs, 0, 'archive file size must be > 0')
Expand All @@ -103,9 +120,9 @@ def test_release_changelog(self):

# Include a changelog
release(self.parameters, RELEASE_VERSION_TEST)
archive_name = self.parameters.archive_name(RELEASE_VERSION_TEST)
archive_name = self.parameters.archive_name(self.parameters.plugin_path, RELEASE_VERSION_TEST)
with ZipFile(archive_name, 'r') as zip_file:
data = zip_file.read('qgis_plugin_ci_testing/metadata.txt')
data = zip_file.read('qgis_plugin_CI_testing/metadata.txt')
self.assertGreater(data.find(expected), 0)


Expand Down

0 comments on commit 53af5d3

Please sign in to comment.