Lint codebase and add CI job
parent
9c9d3927bb
commit
5a4631fa22
|
@ -1,8 +1,19 @@
|
||||||
stages:
|
stages:
|
||||||
|
- lint
|
||||||
- test
|
- test
|
||||||
- build
|
- build
|
||||||
- publish
|
- publish
|
||||||
|
|
||||||
|
lint:
|
||||||
|
stage: lint
|
||||||
|
image: python:3.10
|
||||||
|
before_script:
|
||||||
|
- pip install .[lint]
|
||||||
|
script:
|
||||||
|
- black .
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
|
||||||
test:
|
test:
|
||||||
stage: test
|
stage: test
|
||||||
image: python:3
|
image: python:3
|
||||||
|
|
|
@ -78,7 +78,9 @@ class APIClient(object):
|
||||||
)
|
)
|
||||||
self.session.verify = config["funkwhale"].get("verify_cert", True)
|
self.session.verify = config["funkwhale"].get("verify_cert", True)
|
||||||
|
|
||||||
self.exclude_compilation_artists = self.config["funkwhale"].get("exclude_compilation_artists", True)
|
self.exclude_compilation_artists = self.config["funkwhale"].get(
|
||||||
|
"exclude_compilation_artists", True
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def use_oauth(self):
|
def use_oauth(self):
|
||||||
|
@ -151,7 +153,9 @@ def get_token(config):
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
token_data = json.loads(raw)
|
token_data = json.loads(raw)
|
||||||
token_data["expires_in"] = token_data["expires_at"] - datetime.timestamp(datetime.now())
|
token_data["expires_in"] = token_data["expires_at"] - datetime.timestamp(
|
||||||
|
datetime.now()
|
||||||
|
)
|
||||||
return token_data
|
return token_data
|
||||||
except (TypeError, ValueError):
|
except (TypeError, ValueError):
|
||||||
logger.error("Cannot decode token data, you may need to relogin")
|
logger.error("Cannot decode token data, you may need to relogin")
|
||||||
|
|
|
@ -378,7 +378,9 @@ class FunkwhaleLibraryProvider(backend.LibraryProvider):
|
||||||
client = self.backend.client
|
client = self.backend.client
|
||||||
config = {
|
config = {
|
||||||
"track": lambda id: [client.get_track(id)],
|
"track": lambda id: [client.get_track(id)],
|
||||||
"album": lambda id: client.list_tracks({"album": id, "ordering": "position"})["results"],
|
"album": lambda id: client.list_tracks(
|
||||||
|
{"album": id, "ordering": "position"}
|
||||||
|
)["results"],
|
||||||
"artist": lambda id: client.list_tracks({"artist": id})["results"],
|
"artist": lambda id: client.list_tracks({"artist": id})["results"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,9 @@ mopidy.ext =
|
||||||
funkwhale = mopidy_funkwhale:Extension
|
funkwhale = mopidy_funkwhale:Extension
|
||||||
|
|
||||||
[options.extras_require]
|
[options.extras_require]
|
||||||
|
lint =
|
||||||
|
black
|
||||||
|
|
||||||
test =
|
test =
|
||||||
pytest
|
pytest
|
||||||
pytest-cov
|
pytest-cov
|
||||||
|
|
11
setup.py
11
setup.py
|
@ -4,24 +4,27 @@ import codecs
|
||||||
import os
|
import os
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
|
|
||||||
def read(rel_path):
|
def read(rel_path):
|
||||||
here = os.path.abspath(os.path.dirname(__file__))
|
here = os.path.abspath(os.path.dirname(__file__))
|
||||||
with codecs.open(os.path.join(here, rel_path), 'r') as fp:
|
with codecs.open(os.path.join(here, rel_path), "r") as fp:
|
||||||
return fp.read()
|
return fp.read()
|
||||||
|
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
tag = os.getenv('CI_COMMIT_TAG', None)
|
tag = os.getenv("CI_COMMIT_TAG", None)
|
||||||
if tag:
|
if tag:
|
||||||
return tag
|
return tag
|
||||||
|
|
||||||
for line in read("mopidy_funkwhale/__init__.py").splitlines():
|
for line in read("mopidy_funkwhale/__init__.py").splitlines():
|
||||||
if line.startswith('__version__'):
|
if line.startswith("__version__"):
|
||||||
delim = '"' if '"' in line else "'"
|
delim = '"' if '"' in line else "'"
|
||||||
version = line.split(delim)[1]
|
version = line.split(delim)[1]
|
||||||
iid = os.getenv('CI_PIPELINE_IID', 0)
|
iid = os.getenv("CI_PIPELINE_IID", 0)
|
||||||
return "{}.dev{}".format(version, iid)
|
return "{}.dev{}".format(version, iid)
|
||||||
raise RuntimeError("Unable to find version string.")
|
raise RuntimeError("Unable to find version string.")
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
version=get_version(),
|
version=get_version(),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue