diff --git a/.woodpecker.yml b/.woodpecker.yml index fc3b6b2..f201c99 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -2,21 +2,21 @@ pipeline: test: image: debian commands: - - apt-get -qq update - - apt-get -y -qq upgrade - - apt-get -qq -o=Dpkg::Use-Pty=0 -y install --no-install-recommends python3-all python3-dev python3-pip python3-venv build-essential pkg-config libsystemd-dev libldap2-dev libsasl2-dev libpq-dev libmariadb-dev wget unzip + - DEBIAN_FRONTEND=noninteractive apt-get -qq update < /dev/null > /dev/null + - DEBIAN_FRONTEND=noninteractive apt-get -y -qq upgrade < /dev/null > /dev/null + - DEBIAN_FRONTEND=noninteractive apt-get -qq -y install --no-install-recommends python3-all python3-dev python3-pip python3-venv build-essential pkg-config libsystemd-dev libldap2-dev libsasl2-dev libpq-dev libmariadb-dev wget unzip < /dev/null > /dev/null - wget --no-verbose -O /opt/instantclient-basic-linux.x64-21.4.0.0.0dbru.zip https://download.oracle.com/otn_software/linux/instantclient/214000/instantclient-basic-linux.x64-21.4.0.0.0dbru.zip - - unzip -d /opt /opt/instantclient-basic-linux.x64-21.4.0.0.0dbru.zip + - unzip -qq -d /opt /opt/instantclient-basic-linux.x64-21.4.0.0.0dbru.zip - echo /opt/instantclient_* > /etc/ld.so.conf.d/oracle-instantclient.conf - ldconfig - - ./tests.sh + - ./tests.sh --quiet build: image: debian commands: - - apt-get -qq update - - apt-get -y -qq upgrade - - apt-get -qq -o=Dpkg::Use-Pty=0 -y install --no-install-recommends git sed python3-all python3-dev python3-pip python3-venv dpkg-dev build-essential debhelper dh-python bash-completion lsb-release - - ./build.sh + - DEBIAN_FRONTEND=noninteractive apt-get -qq update < /dev/null > /dev/null + - DEBIAN_FRONTEND=noninteractive apt-get -y -qq upgrade < /dev/null > /dev/null + - DEBIAN_FRONTEND=noninteractive apt-get -qq -y install --no-install-recommends git sed python3-all python3-dev python3-pip python3-venv dpkg-dev build-essential debhelper dh-python bash-completion lsb-release < /dev/null > /dev/null + - ./build.sh --quiet - rm -fr deb_dist/python3-mylib-* publish: image: plugins/gitea-release diff --git a/build.sh b/build.sh index b6feaae..5928984 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,8 @@ #!/bin/bash +QUIET_ARG="" +[ "$1" == "--quiet" ] && QUIET_ARG="--quiet" + # Enter source directory cd $( dirname $0 ) @@ -15,15 +18,16 @@ then VENV=$( realpath venv ) TEMP_VENV=0 else - # Install stdeb in temporary venv VENV=$(mktemp -d) echo "Create a temporary virtualenv in $VENV to install build dependencies..." TEMP_VENV=1 python3 -m venv $VENV - $VENV/bin/python3 -m pip install stdeb GitPython wheel fi -# Build wheel package +echo "Install dependencies in virtualenv using pip..." +$VENV/bin/python3 -m pip install stdeb GitPython wheel $QUIET_ARG + +echo "Build wheel package..." $VENV/bin/python3 setup.py bdist_wheel # Check gitdch is installed @@ -32,14 +36,14 @@ set -e if [ -z "$GITDCH" ] then TMP_GITDCH=$(mktemp -d) - echo "Temporary install gitdch in $TMP_GITDCH" - git clone https://gitea.zionetrix.net/bn8/gitdch.git $TMP_GITDCH/gitdch + echo "Temporary install gitdch in $TMP_GITDCH..." + git clone $QUIET_ARG https://gitea.zionetrix.net/bn8/gitdch.git $TMP_GITDCH/gitdch GITDCH=$TMP_GITDCH/gitdch/gitdch else TMP_GITDCH="" fi -# Build debian source package +echo "Build debian source package using stdeb sdist_dsc command..." $VENV/bin/python3 setup.py --command-packages=stdeb.command sdist_dsc \ --package3 "python3-mylib" \ --maintainer "Benjamin Renard " \ @@ -47,34 +51,35 @@ $VENV/bin/python3 setup.py --command-packages=stdeb.command sdist_dsc \ --section net \ --forced-upstream-version "$VERSION" -# Keep only debian package directory and orig.tar.gz archive +echo "Keep only debian package directory and orig.tar.gz archive..." find deb_dist/ -maxdepth 1 -type f ! -name '*.orig.tar.gz' -delete -# Enter in debian package directory +echo "Enter in debian package directory..." cd deb_dist/mylib-$VERSION -# Generate EE debian codename +echo "Generate EE debian codename..." DEBIAN_CODENAME=$( lsb_release -c -s ) [ $( lsb_release -r -s ) -ge 9 ] && DEBIAN_CODENAME="${DEBIAN_CODENAME}-ee" -# Generate debian changelog using generate_debian_changelog.py +echo "Generate debian changelog using gitdch..." +GITDCH_LOG_ARG='--verbose' +[ -n "$QUIET_ARG" ] && GITDCH_LOG_ARG='--warning' $VENV/bin/python3 $GITDCH \ --package-name mylib \ --version "${VERSION}" \ --code-name $DEBIAN_CODENAME \ --output debian/changelog \ --path ../../ \ - --verbose + $GITDCH_LOG_ARG -# Add custom package name for dependencies +echo "Add custom package name for dependencies..." cat << EOF > debian/py3dist-overrides cx_oracle python3-cx-oracle EOF -[ $TEMP_VENV -eq 1 ] && rm -fr $VENV +[ $TEMP_VENV -eq 1 ] && echo "Clean temporary virtualenv..." && rm -fr $VENV -# Clean temporary gitdch installation -[ -n "$TMP_GITDCH" ] && rm -fr $TMP_GITDCH +[ -n "$TMP_GITDCH" ] && echo "Clean temporary gitdch installation..." && rm -fr $TMP_GITDCH -# Build debian package +echo "Build debian package..." dpkg-buildpackage --no-sign diff --git a/tests.sh b/tests.sh index d50833d..8b0a121 100755 --- a/tests.sh +++ b/tests.sh @@ -1,5 +1,8 @@ #!/bin/bash +QUIET_ARG="" +[ "$1" == "--quiet" ] && QUIET_ARG="--quiet" + # Enter source directory cd $( dirname $0 ) @@ -8,15 +11,15 @@ then VENV=$( realpath venv ) TEMP_VENV=0 else - # Install stdeb in temporary venv + # Create a temporary venv VENV=$(mktemp -d) - echo "Create a temporary virtualenv in $VENV to install build dependencies..." + echo "Create a temporary virtualenv in $VENV to install dependencies..." TEMP_VENV=1 python3 -m venv $VENV fi -# Install package with dev dependencies -$VENV/bin/python3 -m pip install -e ".[dev]" +echo "Install package with dev dependencies using pip..." +$VENV/bin/python3 -m pip install -e ".[dev]" $QUIET_ARG # Run tests $VENV/bin/python3 -m pytest tests