Skip to content

Commit

Permalink
Bring the deb-package building back
Browse files Browse the repository at this point in the history
  • Loading branch information
dstaroff committed Jul 14, 2023
1 parent 0c8ff52 commit a963803
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 16 deletions.
33 changes: 29 additions & 4 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,34 +66,44 @@ jobs:
python-version: ${{ matrix.target.python }}
cache: pip

- {name: install dependencies, run: "pip install .[test]" }
- {name: build project, run: flit build --no-use-vcs }
- name: install dependencies
# language=sh
run: |
pip install '.[test]'
- name: build project
# language=sh
run: |
make prepare-version
flit build --no-use-vcs
- name: upload wheel
uses: actions/upload-artifact@v3
if: ${{ matrix.clickhouse == 'latest' }}
with:
name: chtools-py${{ matrix.target.python }}.whl
name: chtools_py${{ matrix.target.python }}.whl
path: dist/*.whl
if-no-files-found: error

- name: upload sdist
uses: actions/upload-artifact@v3
if: ${{ matrix.clickhouse == 'latest' }}
with:
name: chtools-py${{ matrix.target.python }}.tar.gz
name: chtools_py${{ matrix.target.python }}.tar.gz
path: dist/*.tar.gz
if-no-files-found: error

- {name: run unit tests, run: pytest}

- name: prepare integration tests
# language=sh
run: |
cd tests
CLICKHOUSE_VERSION=${{ matrix.clickhouse }} python3 -m env_control create
cd ..
- name: run integration tests
# language=sh
run: |
cd tests
behave --show-timings --junit -D skip_setup
Expand All @@ -104,3 +114,18 @@ jobs:
if: always()
with:
report_paths: 'tests/reports/*.xml'

- name: build debian package
# language=sh
run: |
apt-get update -q -y
apt-get install -q -y git python3 python3-venv python3-pip debhelper devscripts
mv dist/*.tar.gz chtools.tar.gz
make clean build-deb-package
- name: upload deb package artifact
uses: actions/upload-artifact@v3
with:
name: mdb-ch-tools_py${{ matrix.target.python }}.deb
path: out/mdb-ch-tools*.deb
if-no-files-found: error
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ cython_debug/
tests/staging/
tests/reports/
.session_conf.sav
version.txt
69 changes: 60 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,47 @@ PREFIX=/opt/yandex/mdb-ch-tools
INSTALL_DIR=$(DESTDIR)$(PREFIX)

.PHONY: install
install: install-symlinks install-bash-completions install-logrotate ;
install: install-python-package install-symlinks install-bash-completions configure-logs ;

.PHONY: uninstall
uninstall: uninstall-python-package uninstall-symlinks uninstall-bash-completions uninstall-logrotate ;

.PHONY: install-python-package
install-python-package: build-python-package
@echo 'Installing mdb-ch-tools'

python3 -m venv $(INSTALL_DIR)
rm -f $(INSTALL_DIR)/bin/activate*
$(INSTALL_DIR)/bin/pip install -U pip

$(INSTALL_DIR)/bin/pip install --no-compile chtools.tar.gz

find $(INSTALL_DIR) -name __pycache__ -type d -exec rm -rf {} +
test -n '$(DESTDIR)' \
&& grep -l -r -F '#!$(INSTALL_DIR)' $(INSTALL_DIR) \
| xargs sed -i -e 's|$(INSTALL_DIR)|$(PREFIX)|' \
|| true

.PHONY: build-python-package
build-python-package: chtools.tar.gz ;
@echo 'Cleaning up residuals from building of Python package'
rm -rf venv dist

chtools.tar.gz: venv-build prepare-version
@echo 'Building Python package'

venv/bin/flit build --no-use-vcs
mv dist/*.tar.gz $@

.PHONY: venv-build
venv-build: venv/bin/python3 ;

venv/bin/python3:
@echo 'Setting up build venv'

python3 -m venv venv
venv/bin/pip install -U pip flit

.PHONY: uninstall-python-package
uninstall-python-package:
@echo 'Uninstalling mdb-ch-tools'
Expand Down Expand Up @@ -48,14 +84,14 @@ uninstall-bash-completions:
rm -f $(DESTDIR)/etc/bash_completion.d/$(bin) ; \
)

.PHONY: install-logrotate
install-logrotate:
@echo 'Creating log rotation rules'
.PHONY: configure-logs
configure-logs:
@echo 'Configuring logging'

mkdir -p $(DESTDIR)/etc/logrotate.d/
$(foreach bin, chadmin clickhouse-monitoring keeper-monitoring, \
mkdir -p $(DESTDIR)/var/log/$(folder) ; \
chmod 775 $(DESTDIR)/var/log/$(folder) ; \
mkdir -p $(DESTDIR)/var/log/$(bin) ; \
chmod 775 $(DESTDIR)/var/log/$(bin) ; \
cp resources/logrotate/$(bin).logrotate $(DESTDIR)/etc/logrotate.d/$(bin) ; \
)

Expand All @@ -67,40 +103,55 @@ uninstall-logrotate:
rm -f $(DESTDIR)/etc/logrotate.d/$(bin) ; \
)


.PHONY: prepare-changelog
prepare-changelog: prepare-version
dch --force-bad-version --distribution stable -v `cat version.txt` Autobuild
@echo 'Bumping version into Debian package changelog'
DEBFULLNAME="Yandex LLC" DEBEMAIL="[email protected]" dch --force-bad-version --distribution stable -v `cat version.txt` Autobuild

.PHONY: prepare-version
prepare-version: version.txt
@echo "Version: `cat version.txt`"

version.txt:
@echo "2.$$(git rev-list HEAD --count).$$(git rev-parse --short HEAD | perl -ne 'print hex $$_')" > $@
@# Replace version in pyproject.toml
sed -ie "s/__version__ = \"[0-9\.]\+\"/__version__ = \"`cat $@`\"/" src/chtools/__init__.py

.PHONY: build-deb-package
build-deb-package: prepare-changelog
cd debian && debuild --check-dirname-level 0 --preserve-env --no-lintian --no-tgz-check -uc -us
mkdir out && mv ../mdb-ch-tools* out/

.PHONY: clean
clean:
@echo 'Cleaning up'

rm -rf build
rm -rf debian/files debian/.debhelper
rm -rf debian/mdb-ch-tools*

.PHONY: help
help:
@echo "Base targets:"
@echo " prepare-changelog Add an autobuild version entity to changelog"
@echo " prepare-version Update version based on latest commit"
@echo " build-python-package Build 'ch-tools' Python package"
@echo " build-deb-package Build 'mdb-ch-tools' debian package"
@echo " clean Clean up after building debian package"
@echo ""
@echo "--------------------------------------------------------------------------------"
@echo ""
@echo "Debian package build targets:"
@echo " install Install 'mdb-ch-tools' debian package"
@echo " uninstall Uninstall 'mdb-ch-tools' debian package"
@echo ""
@echo " install-python-package Install 'ch-tools' python package"
@echo " uninstall-python-package Uninstall 'ch-tools' python package"
@echo " install-symlinks Install symlinks to /usr/bin/"
@echo " uninstall-symlinks Uninstall symlinks from /usr/bin/"
@echo " install-bash-completions Install to /etc/bash_completion.d/"
@echo " uninstall-bash-completions Uninstall from /etc/bash_completion.d/"
@echo " install-logrotate Install log rotation rules to /etc/logrotate.d/"
@echo " configure-logs Install log rotation rules to /etc/logrotate.d/ and create log dirs"
@echo " uninstall-logrotate Uninstall log rotation rules from /etc/logrotate.d/"
@echo ""
@echo "--------------------------------------------------------------------------------"
Expand Down
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Uploaders: Alexander Burmak <[email protected]>,
Aleksei Filatov <[email protected]>,
Evgenii Kopanev <[email protected]>,
Mikhail Kot <[email protected]>
Build-Depends: debhelper (>= 8.0.0), python3, python3-venv, python3-pip, python3-setuptools
Build-Depends: debhelper (>= 9.0.0), python3, python3-venv, python3-pip, python3-setuptools
Standards-Version: 4.1.4
Homepage: https://github.com/yandex/ch-tools
Vcs-Browser: https://github.com/yandex/ch-tools.git
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ build-backend = "flit_core.buildapi"

[project]
name = "chtools"
version = "1.0.0"
description = "A set of tools for administration and diagnostics of ClickHouse DBMS."
license = { file = "LICENSE" }
dynamic = ["version", "description"]

authors = [
{name = "Alexander Burmak", email = "[email protected]"},
Expand Down
3 changes: 3 additions & 0 deletions src/chtools/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""A set of tools for administration and diagnostics of ClickHouse DBMS."""

__version__ = "1.0.0"

0 comments on commit a963803

Please sign in to comment.