diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 078aa17..f73496d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,9 +1,54 @@ +stages: + - test + - build + - deploy + - verify + variables: GIT_SUBMODULE_STRATEGY: recursive +image: ubuntu:18.10 + +lint: + stage: test + allow_failure: true + before_script: + - apt update + - apt install -y python3-pip libcairo2-dev pkg-config + - pip3 install -r dev-requirements.txt + - pip3 install -e . + script: + - python3 setup.py check -mrs + - pycodestyle + +test: + stage: test + before_script: + - apt update + - apt install -y python3-pip libcairo2-dev pkg-config libgtk-3-dev libmpv-dev libglib2.0-dev gir1.2-notify-0.7 + - pip3 install -r dev-requirements.txt + - pip3 install -e . + script: + - ./cicd/pytest.sh + artifacts: + paths: + - htmlcov + +build: + stage: build + before_script: + - apt update + - apt install -y python3-pip libcairo2-dev pkg-config + - pip3 install -r dev-requirements.txt + script: + - python3 setup.py sdist + artifacts: + paths: + - dist/* build_flatpak: image: registry.gitlab.com/robozman/libremsonic/libremsonic/build:latest + stage: build script: - cd flatpak - ./flatpak_build.sh @@ -11,3 +56,25 @@ build_flatpak: name: "libremsonic-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA" paths: - flatpak/libremsonic.flatpak + +deploy_pypi: + image: python:3.6-alpine + stage: deploy + only: + - master + before_script: + - 'pip install twine' + - './create-pypirc.sh' + script: + # Upload to the test PyPi instance, then upload to the real one. + - twine upload -r pypi_test dist/* + - twine upload dist/* + after_script: + - echo "" > ~/.pypirc && rm -f ~/.pypirc + +verify_deploy: + stage: verify + only: + - master + script: + - pip3 install libremsonic diff --git a/cicd/pytest.sh b/cicd/pytest.sh new file mode 100755 index 0000000..8ae4f5d --- /dev/null +++ b/cicd/pytest.sh @@ -0,0 +1,12 @@ +#! /bin/sh + +pytest +ec=$? + +echo "pytest exited with exit code $ec" + +case $ec in + 0) exit 0 ;; + 5) exit 0 ;; + *) exit 1 ;; +esac diff --git a/create-pypirc.sh b/create-pypirc.sh new file mode 100644 index 0000000..83463cb --- /dev/null +++ b/create-pypirc.sh @@ -0,0 +1,14 @@ +#! /bin/sh + +echo "[distutils]" >> ~/.pypirc +echo "index-servers =" >> ~/.pypirc +echo " pypi" >> ~/.pypirc +echo " pypi_test" >> ~/.pypirc +echo "[pypi]" >> ~/.pypirc +echo "username: ${PYPI_USER}" >> ~/.pypirc +echo "password: ${PYPI_PASSWORD}" >> ~/.pypirc +echo "[pypi_test]" >> ~/.pypirc +echo "repository: https://test.pypi.org/legacy/" >> ~/.pypirc +echo "username: ${PYPI_USER}" >> ~/.pypirc +echo "password: ${PYPI_TEST_PASSWORD}" >> ~/.pypirc + diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 0000000..d3c4be8 --- /dev/null +++ b/dev-requirements.txt @@ -0,0 +1,5 @@ +pytest +pytest-cov +docutils +pycodestyle +lxml diff --git a/pytest.ini b/pytest.ini index ff7f6da..0e77ad6 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,6 +2,7 @@ addopts = -vvv --doctest-modules - --cov=tracktime + --ignore-glob='api_object_generator' + --cov=libremsonic --cov-report html --cov-report term