1
0
Fork 0
forked from s3lph/matemat
matemat/.gitlab-ci.yml

143 lines
5 KiB
YAML
Raw Normal View History

2018-05-29 21:49:40 +02:00
---
2018-11-07 15:09:45 +01:00
image: s3lph/matemat-ci:20181107-02
2018-05-29 21:49:40 +02:00
stages:
- test
2018-07-11 17:17:00 +02:00
- build
- deploy
before_script:
2018-10-19 22:15:05 +02:00
- export MATEMAT_VERSION=$(python -c 'import matemat; print(matemat.__version__)')
2018-05-29 21:49:40 +02:00
test:
stage: test
2018-05-29 21:49:40 +02:00
script:
2018-10-19 21:35:35 +02:00
- pip3 install -e .
- sudo -u matemat python3.6 -m coverage run --rcfile=setup.cfg -m unittest discover matemat
- sudo -u matemat python3.6 -m coverage combine
- sudo -u matemat python3.6 -m coverage report --rcfile=setup.cfg
codestyle:
2018-07-11 17:17:00 +02:00
stage: test
script:
2018-10-19 21:35:35 +02:00
- pip3 install -e .
2018-07-10 22:18:57 +02:00
- sudo -u matemat pycodestyle matemat
build_docker:
2018-07-11 17:17:00 +02:00
stage: build
script:
2018-11-04 02:51:57 +01:00
- docker build -t "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_SHA" -f package/docker/Dockerfile .
- docker tag "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_SHA" "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_REF_NAME"
- if [[ -n "$CI_COMMIT_TAG" ]]; then docker tag "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_SHA" "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_TAG"; fi
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_TOKEN registry.gitlab.com
- docker push "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_SHA"
- docker push "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_REF_NAME"
- if [[ -n "$CI_COMMIT_TAG" ]]; then docker push "registry.gitlab.com/s3lph/matemat:$CI_COMMIT_TAG"; fi
only:
- staging
- tags
build_wheel:
stage: build
script:
- python3.6 setup.py egg_info bdist_wheel
- cd dist
- sha256sum *.whl > SHA256SUMS
artifacts:
paths:
- "dist/*.whl"
- dist/SHA256SUMS
only:
- tags
build_debian:
stage: build
script:
2018-11-11 23:37:12 +01:00
# The Python package name provided by the python3-magic Debian package is "python-magic" rather than "file-magic".
- sed -re 's/file-magic/python-magic/' -i setup.py
- echo -n > package/debian/matemat/usr/share/doc/matemat/changelog
2018-11-04 14:58:59 +01:00
- |
for version in "$(cat CHANGELOG.md | grep '<!-- BEGIN CHANGES' | cut -d ' ' -f 4)"; do
echo "matemat (${version}-1); urgency=medium\n" >> package/debian/matemat/usr/share/doc/matemat/changelog
cat CHANGELOG.md | grep -A 1000 "<"'!'"-- BEGIN CHANGES ${version} -->" | grep -B 1000 "<"'!'"-- END CHANGES ${version} -->" | tail -n +2 | head -n -1 | sed -re 's/^-/ */g' >> package/debian/matemat/usr/share/doc/matemat/changelog
echo "\n -- ${PACKAGE_AUTHOR} $(date -R)\n" >> package/debian/matemat/usr/share/doc/matemat/changelog
2018-11-04 14:58:59 +01:00
done
- gzip -9n package/debian/matemat/usr/share/doc/matemat/changelog
- cp -r static/ package/debian/matemat/usr/lib/matemat/static/
- cp -r templates/ package/debian/matemat/usr/lib/matemat/templates/
- python3.6 setup.py egg_info install --root=package/debian/matemat/ --prefix=/usr --optimize=1
- cd package/debian
- mkdir -p matemat/usr/lib/python3/dist-packages/
- rsync -a matemat/usr/lib/python3.6/site-packages/ matemat/usr/lib/python3/dist-packages/
- rm -rf matemat/usr/lib/python3.6/
- find matemat/usr/lib/python3/dist-packages -name __pycache__ -exec rm -r {} \; 2>/dev/null || true
- find matemat/usr/lib/python3/dist-packages -name '*.pyc' -exec rm {} \;
- mv matemat/usr/bin/matemat matemat/usr/lib/matemat/matemat
- rm -rf matemat/usr/bin
2018-11-11 22:41:23 +01:00
- sed -re 's$#!/usr/local/bin/python3.6$#!/usr/bin/python3$' -i matemat/usr/lib/matemat/matemat
2018-11-11 22:35:09 +01:00
- find matemat -type f -exec chmod 0644 {} \;
- find matemat -type d -exec chmod 755 {} \;
- chmod +x matemat/usr/lib/matemat/matemat matemat/DEBIAN/postinst matemat/DEBIAN/prerm matemat/DEBIAN/postrm
- dpkg-deb --build matemat
- mv matemat.deb "matemat_${MATEMAT_VERSION}-1_all.deb"
2018-11-11 22:31:11 +01:00
- sudo -u nobody lintian "matemat_${MATEMAT_VERSION}-1_all.deb"
- sha256sum *.deb > SHA256SUMS
artifacts:
paths:
- "package/debian/*.deb"
- package/debian/SHA256SUMS
only:
- tags
build_archlinux:
stage: build
image: archlinux/base:latest # Use an archlinux image instead of the customized debian image.
script:
- pacman -Sy --noconfirm python python-setuptools python-pip python-wheel python-jinja python-pillow python-magic file
2018-10-19 22:21:44 +02:00
- export MATEMAT_VERSION=$(python -c 'import matemat; print(matemat.__version__)')
- cp -r static/ package/archlinux/matemat/usr/lib/matemat/static/
- cp -r templates/ package/archlinux/matemat/usr/lib/matemat/templates/
- python3 setup.py egg_info -d -b +master install --root=package/archlinux/matemat/ --prefix=/usr --optimize=1
- cd package/archlinux
- mv matemat/usr/bin/matemat matemat/usr/lib/matemat/matemat
- rm -rf matemat/usr/bin
2018-10-19 22:10:01 +02:00
- sed -re "s/__VERSION__/${MATEMAT_VERSION}/g" -i PKGBUILD
- sudo -u nobody makepkg -c
- sha256sum *.pkg.tar.xz > SHA256SUMS
artifacts:
paths:
- "package/archlinux/*.pkg.tar.xz"
- package/archlinux/SHA256SUMS
only:
- 27-deployment
- tags
2018-07-11 17:17:00 +02:00
staging:
stage: deploy
2018-07-11 17:17:00 +02:00
script:
- eval $(ssh-agent -s)
- ssh-add - <<<"$STAGING_SSH_PRIVATE_KEY"
- echo "$CI_COMMIT_SHA" | ssh -p 20022 -oStrictHostKeyChecking=no matemat@kernelpanic.lol
2018-07-11 17:17:00 +02:00
environment:
name: staging
url: https://matemat.kernelpanic.lol/
only:
- staging
release:
stage: deploy
script:
- python package/release.py
only:
- tags