2019-11-25 02:48:12 +01:00
|
|
|
---
|
2019-11-26 15:14:15 +01:00
|
|
|
image: s3lph/spaceapi-server-ci:20191126-02
|
2019-11-25 02:48:12 +01:00
|
|
|
|
|
|
|
stages:
|
2019-11-26 14:24:53 +01:00
|
|
|
- test
|
|
|
|
- build
|
2019-11-26 16:07:17 +01:00
|
|
|
- release
|
2019-11-25 02:48:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
before_script:
|
2019-11-26 14:24:53 +01:00
|
|
|
- export SPACEAPI_SERVER_VERSION=$(python -c 'import spaceapi_server; print(spaceapi_server.__version__)')
|
2019-11-25 02:48:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test:
|
|
|
|
stage: test
|
|
|
|
script:
|
2019-11-26 14:24:53 +01:00
|
|
|
- pip3 install -e .
|
|
|
|
- python3 -m coverage run --rcfile=setup.cfg -m unittest discover spaceapi_server
|
|
|
|
- python3 -m coverage combine
|
|
|
|
- python3 -m coverage report --rcfile=setup.cfg
|
2019-11-25 02:48:12 +01:00
|
|
|
|
|
|
|
codestyle:
|
|
|
|
stage: test
|
|
|
|
script:
|
2019-11-26 14:24:53 +01:00
|
|
|
- pip3 install -e .
|
|
|
|
- pycodestyle spaceapi_server
|
2019-11-25 02:48:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
build_wheel:
|
|
|
|
stage: build
|
|
|
|
script:
|
|
|
|
- python3 setup.py egg_info bdist_wheel
|
|
|
|
- cd dist
|
|
|
|
- sha256sum *.whl > SHA256SUMS
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- "dist/*.whl"
|
|
|
|
- dist/SHA256SUMS
|
|
|
|
only:
|
|
|
|
- tags
|
2019-11-26 14:24:53 +01:00
|
|
|
|
|
|
|
build_debian:
|
|
|
|
stage: build
|
|
|
|
script:
|
|
|
|
- find package/debian -name .gitkeep -delete
|
|
|
|
# Copy example plugin
|
|
|
|
- install -m0644 examples/plugins/example.py package/debian/spaceapi-server/etc/spaceapi-server/plugins/example.py
|
|
|
|
# Create control
|
|
|
|
- |
|
|
|
|
cat > package/debian/spaceapi-server/DEBIAN/control <<EOF
|
|
|
|
Package: spaceapi-server
|
|
|
|
Version: ${SPACEAPI_SERVER_VERSION}
|
|
|
|
Maintainer: s3lph <account-gitlab-ideynizv@kernelpanic.lol>
|
|
|
|
Section: web
|
|
|
|
Priority: optional
|
|
|
|
Architecture: all
|
|
|
|
Depends: python3 (>= 3.6), python3-jinja2, python3-bottle
|
|
|
|
Description: Lightweight SpaceAPI endpoint server
|
|
|
|
Lightweight server for SpaceAPI endpoints. Includes support for pluggable
|
|
|
|
templating, so dynamic content, like sensor values, can be added.
|
|
|
|
EOF
|
|
|
|
- chmod 0644 package/debian/spaceapi-server/DEBIAN/control
|
|
|
|
# Create changelog
|
|
|
|
- |
|
|
|
|
for version in "$(cat CHANGELOG.md | grep '<!-- BEGIN CHANGES' | cut -d ' ' -f 4)"; do
|
|
|
|
echo "spaceapi-server (${version}-1); urgency=medium\n" >> package/debian/spaceapi-server/usr/share/doc/spaceapi-server/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/spaceapi-server/usr/share/doc/spaceapi-server/changelog
|
|
|
|
echo "\n -- s3lph <account-gitlab-ideynizv@kernelpanic.lol> $(date -R)\n" >> package/debian/spaceapi-server/usr/share/doc/spaceapi-server/changelog
|
|
|
|
done
|
|
|
|
- gzip -9n package/debian/spaceapi-server/usr/share/doc/spaceapi-server/changelog
|
|
|
|
# Copy license
|
|
|
|
- install -m0644 LICENSE package/debian/spaceapi-server/usr/share/doc/spaceapi-server/copyright
|
|
|
|
# Install spaceapi-server into package root
|
|
|
|
- python3 setup.py egg_info install --root=package/debian/spaceapi-server/ --prefix=/usr --optimize=1
|
|
|
|
- cd package/debian/spaceapi-server
|
|
|
|
- mkdir -p usr/lib/python3/dist-packages/
|
2019-11-26 15:27:53 +01:00
|
|
|
- cp -r usr/lib/python3.8/site-packages/spaceapi_server* usr/lib/python3/dist-packages/
|
2019-11-26 14:24:53 +01:00
|
|
|
- rm -rf usr/lib/python3.8/
|
|
|
|
# Remove compiled Python files
|
|
|
|
- find usr/lib/python3/dist-packages -name __pycache__ -exec rm -r {} \; 2>/dev/null || true
|
|
|
|
- find usr/lib/python3/dist-packages -name '*.pyc' -exec rm {} \;
|
2019-11-26 16:07:17 +01:00
|
|
|
# Remove spaceapi-server script
|
|
|
|
- rm usr/bin/spaceapi-server
|
2019-11-26 14:24:53 +01:00
|
|
|
# Fix file permissions
|
|
|
|
- find . -type f -exec chmod 0644 {} \;
|
|
|
|
- find . -type d -exec chmod 755 {} \;
|
2019-11-26 16:48:34 +01:00
|
|
|
- chmod 0755 DEBIAN/postinst DEBIAN/prerm DEBIAN/postrm
|
2019-11-26 14:24:53 +01:00
|
|
|
# Build the package
|
|
|
|
- cd ..
|
|
|
|
- dpkg-deb --build spaceapi-server
|
|
|
|
- mv spaceapi-server.deb "spaceapi-server_${SPACEAPI_SERVER_VERSION}-1_all.deb"
|
|
|
|
# Run lintian
|
|
|
|
- sudo -u nobody lintian --fail-on-warnings "spaceapi-server_${SPACEAPI_SERVER_VERSION}-1_all.deb"
|
|
|
|
# Generate checksum
|
|
|
|
- sha256sum *.deb > SHA256SUMS
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- "package/debian/*.deb"
|
|
|
|
- package/debian/SHA256SUMS
|
|
|
|
only:
|
|
|
|
- tags
|
2019-11-26 16:07:17 +01:00
|
|
|
|
|
|
|
build_archlinux:
|
|
|
|
stage: build
|
|
|
|
image: archlinux/base:latest # Use an archlinux image instead of the customized debian image.
|
|
|
|
script:
|
|
|
|
- find package/archlinux -name .gitkeep -delete
|
|
|
|
# Install dependencies
|
|
|
|
- pacman -Sy --noconfirm namcap python python-setuptools python-pip python-wheel python-jinja python-bottle base-devel
|
|
|
|
- export SPACEAPI_SERVER_VERSION=$(python -c 'import spaceapi_server; print(spaceapi_server.__version__)')
|
|
|
|
# Copy example plugin
|
|
|
|
- install -m0644 examples/plugins/example.py package/archlinux/spaceapi-server/etc/spaceapi-server/plugins/example.py
|
|
|
|
# Create changelog
|
|
|
|
- |
|
|
|
|
for version in "$(cat CHANGELOG.md | grep '<!-- BEGIN CHANGES' | cut -d ' ' -f 4)"; do
|
|
|
|
echo "$(date +%Y-%m-%d) s3lph <account-gitlab-ideynizv@kernelpanic.lol>" >> package/archlinux/spaceapi-server.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/^-/\t*/g' >> package/archlinux/spaceapi-server.changelog
|
|
|
|
echo >> package/archlinux/spaceapi-server.changelog
|
|
|
|
done
|
|
|
|
# Copy license
|
|
|
|
- install -m0644 LICENSE package/archlinux/spaceapi-server/usr/share/licenses/spaceapi-server/LICENSE
|
|
|
|
# Install spaceapi-server into pkgdir
|
|
|
|
- python setup.py egg_info -d -b +master install --root=package/archlinux/spaceapi-server/ --prefix=/usr --optimize=1
|
|
|
|
- cd package/archlinux
|
|
|
|
# Remove spaceapi-server script
|
|
|
|
- rm -rf spaceapi-server/usr/bin
|
|
|
|
# Build the package
|
|
|
|
- sed -re "s/__VERSION__/${SPACEAPI_SERVER_VERSION}/g" -i PKGBUILD
|
|
|
|
- sudo -u nobody makepkg -c
|
|
|
|
# Run namcap
|
|
|
|
- sudo -u nobody namcap *.pkg.tar.xz
|
|
|
|
# Generate checksum
|
|
|
|
- sha256sum *.pkg.tar.xz > SHA256SUMS
|
|
|
|
artifacts:
|
|
|
|
paths:
|
|
|
|
- "package/archlinux/*.pkg.tar.xz"
|
|
|
|
- package/archlinux/SHA256SUMS
|
|
|
|
only:
|
|
|
|
- tags
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
release:
|
|
|
|
stage: release
|
|
|
|
script:
|
|
|
|
- python3 package/release.py
|
|
|
|
only:
|
|
|
|
- tags
|