chore: migrate from gitlab-ci to woodpecker
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
s3lph 2023-10-25 04:10:48 +02:00
parent 03b4beef92
commit f0b6bc7d66
Signed by: s3lph
GPG key ID: 0AA29A52FB33CFB5
4 changed files with 90 additions and 118 deletions

View file

@ -1,112 +0,0 @@
---
image: s3lph/spaceapi-server-ci:20210530-01
stages:
- test
- build
- release
before_script:
- export SPACEAPI_SERVER_VERSION=$(python -c 'import spaceapi_server; print(spaceapi_server.__version__)')
test:
stage: test
script:
- 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
codestyle:
stage: test
script:
- pip3 install -e .
- pycodestyle spaceapi_server
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
build_debian:
stage: build
script:
- find package/debian -name .gitkeep -delete
# Copy example plugin
- install -m0644 examples/plugins/filestate.py package/debian/spaceapi-server/etc/spaceapi-server/plugins/filestate.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.9), python3-yaml, 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/
- cp -r usr/lib/python3.9/site-packages/spaceapi_server* usr/lib/python3/dist-packages/
- rm -rf usr/lib/python3.9/
# 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 {} \;
# Remove spaceapi-server script
- rm usr/bin/spaceapi-server
# Fix file permissions
- find . -type f -exec chmod 0644 {} \;
- find . -type d -exec chmod 755 {} \;
- chmod 0755 DEBIAN/postinst DEBIAN/prerm DEBIAN/postrm
# 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
release:
stage: release
script:
- python3 package/release.py
only:
- tags

83
.woodpecker.yml Normal file
View file

@ -0,0 +1,83 @@
---
steps:
test:
image: python:3.11-bookworm
group: test
commands:
- pip3 install -e .[test]
- python3 -m coverage run --rcfile=setup.cfg -m unittest discover spaceapi_server
- python3 -m coverage combine
- python3 -m coverage report --rcfile=setup.cfg
codestyle:
image: python:3.11-bookworm
group: test
commands:
- pip3 install -e .[test]
- pycodestyle spaceapi_server
build_wheel:
image: python:3.11-bookworm
group: package
when:
- event: tag
secrets:
- GITEA_API_REPOSITORY_PYPI
- GITEA_API_USERNAME
- GITEA_API_PASSWORD
commands:
- pip3 install -e .[test]
- python3 setup.py egg_info bdist_wheel
- |
cat > ~/.pypirc <<EOF
[distutils]
index-servers = gitea
[gitea]
repository = $${GITEA_API_REPOSITORY_PYPI}
username = $${GITEA_API_USERNAME}
password = $${GITEA_API_PASSWORD}
EOF
- python3 -m twine upload --repository gitea dist/*.whl
build_debian:
image: python:3.11-bookworm
group: package
when:
- event: tag
secrets:
- GITEA_API_REPOSITORY_DEB
- GITEA_API_USERNAME
- GITEA_API_PASSWORD
commands:
- apt update; apt install -y lintian rsync sudo curl
- export SPACEAPI_SERVER_VERSION=$(python -c 'import spaceapi_server; print(spaceapi_server.__version__)')
- |
(for version in "$(cat CHANGELOG.md | grep '<!-- BEGIN CHANGES' | cut -d ' ' -f 4)"; do
echo "spaceapi-server ($${version}-1) stable; urgency=medium\n"
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'
echo "\n -- s3lph@kabelsalat.ch $(date -R)\n"
done) > package/debian/spaceapi-server/usr/share/doc/spaceapi-server/changelog
- gzip -9n package/debian/spaceapi-server/usr/share/doc/spaceapi-server/changelog
- python3 setup.py egg_info install --root=package/debian/spaceapi-server/ --prefix=/usr --optimize=1
- cd package/debian
- mkdir -p spaceapi-server/usr/lib/python3/dist-packages/
- rsync -a spaceapi-server/usr/lib/python3.11/site-packages/ spaceapi-server/usr/lib/python3/dist-packages/
- rm -rf spaceapi-server/usr/lib/python3.11/
- find spaceapi-server/usr/lib/python3/dist-packages -name __pycache__ -exec rm -r {} \; 2>/dev/null || true
- find spaceapi-server/usr/lib/python3/dist-packages -name '*.pyc' -exec rm {} \;
- rm spaceapi-server/usr/bin/spaceapi-server
- find spaceapi-server -type f -exec chmod 0644 {} \;
- find spaceapi-server -type d -exec chmod 755 {} \;
- chmod 0755 spaceapi-server/DEBIAN/postinst spaceapi-server/DEBIAN/prerm spaceapi-server/DEBIAN/postrm
- sed -re "s/__VERSION__/$${SPACEAPI_SERVER_VERSION}-1/g" -i spaceapi-server/DEBIAN/control
- dpkg-deb --build spaceapi-server
- mv spaceapi-server.deb "spaceapi-server_$${SPACEAPI_SERVER_VERSION}-1_all.deb"
- sudo -u nobody lintian "spaceapi-server_$${SPACEAPI_SERVER_VERSION}-1_all.deb" || true
- >-
curl
--user "$${GITEA_API_USERNAME}:$${GITEA_API_PASSWORD}"
--upload-file "spaceapi-server_$${SPACEAPI_SERVER_VERSION}-1_all.deb"
$${GITEA_API_REPOSITORY_DEB}

View file

@ -1,6 +0,0 @@
FROM python:3.9-buster as python
RUN apt update \
&& apt install -y --no-install-recommends lintian rsync sudo docker.io \
&& pip3 install pycodestyle coverage \
&& rm -rf /var/cache/apt

View file

@ -21,6 +21,13 @@ setup(
'bottle',
'PyYAML',
],
extras_require={
'test': [
'coverage',
'pycodestyle',
'twine'
]
},
entry_points={
'console_scripts': [
'spaceapi-server = spaceapi_server:start'