Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add debianize build pipeline #176

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,11 @@ jobs:
context: .
push: true
tags: backblaze/b2:${{ steps.build.outputs.version }}

debian-release:
if: ${{ vars.B2_DEBIAN_BUCKET_UPLOAD }}
name: Build Debian Package

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's skip this step if vars are missing

uses: ./.github/workflows/cd_debian.yml
secrets: inherit
with:
b2-upload-bucket: ${{ vars.B2_DEBIAN_BUCKET_UPLOAD }}
41 changes: 41 additions & 0 deletions .github/workflows/cd_debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Debian Continuous Delivery

on:
workflow_call:
inputs:
b2-upload-bucket:
required: true
type: string

env:
PYTHON_DEFAULT_VERSION: "3.11"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debian is probably decades away from supporting this python, I assume that's not a problem? like maybe some things here pass even though they are syntax errors in the version that debian is gonna use?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.11 is actually the default version in the latest Debian.

But we run testsuite for all the supported Python versions (3.7+), so if anything would be misbehaving we'd find out there, no?


jobs:
build-deb:
env:
# dont run tests in Debian build, we ran them already
DEB_BUILD_OPTIONS: nocheck
B2_APPLICATION_KEY_ID: '${{ secrets.B2_DEBIAN_APPLICATION_KEY_ID }}'
B2_APPLICATION_KEY: '${{ secrets.B2_DEBIAN_APPLICATION_KEY }}'

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_DEFAULT_VERSION }}

- name: Install dependencies
run: python -m pip install -U wheel b2

- uses: jtdor/build-deb-action@v1
with:
buildpackage-opts: --build=binary

- name: Upload to B2
working-directory: debian/artifacts
run: |
ls -1 *.deb | xargs -I {} b2 upload_file ${{ inputs.b2-upload-bucket }} {} {}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ venv
doc/source/main_help.rst
Dockerfile
b2/licenses_output.txt
.pc
.pybuild
debian/backblaze-b2*
debian/.debhelper
debian/debhelper-build-stamp
debian/files
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed
* Unpin `setuptools-scm<6.0` as we don't support Python 3.5 (reason for pinning) anymore
* use `rst2ansi` conditionally as it's not available in Debian packaging

### Infrastructure
* Autocomplete integration tests will now work properly even if tested package has not been installed
* Automatically set copyright date when generating the docs
* Increase timeout time in autocomplete tests to accommodate slower CI environments
* Update pyinstaller to fix Linux Bundle build
* Replace `pyflakes` with `ruff` for linting
* Add Debian package build to CD

## [3.9.0] - 2023-04-28

Expand Down
21 changes: 20 additions & 1 deletion b2/arg_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,29 @@
import re
import sys
import textwrap
from contextlib import suppress

import arrow
from b2sdk.v2 import RetentionPeriod
from rst2ansi import rst2ansi

rst2ansi = None
with suppress(ImportError):
from rst2ansi import rst2ansi

if not rst2ansi:

def rst2ansi(input_string, output_encoding='utf-8'):
yedpodtrzitko marked this conversation as resolved.
Show resolved Hide resolved
"""Dummy replacement of rst2ansi which is not available in Debian."""
if isinstance(input_string, bytes):
input_string = input_string.decode(output_encoding)

# remove double backticks
stripped = input_string.replace('``', '')
# remove code-block directive
stripped = stripped.replace('.. code-block::', '')

return stripped


_arrow_version = tuple(int(p) for p in arrow.__version__.split("."))

Expand Down
5 changes: 3 additions & 2 deletions b2/console_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import argcomplete
import b2sdk
import requests
import rst2ansi
from b2sdk.v2 import (
ALL_CAPABILITIES,
B2_ACCOUNT_INFO_DEFAULT_FILE,
Expand Down Expand Up @@ -126,11 +125,13 @@
from b2.json_encoder import B2CliJsonEncoder
from b2.version import VERSION

rst2ansi = None
piplicenses = None
prettytable = None
with suppress(ImportError):
import piplicenses
import prettytable
import rst2ansi

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -3290,7 +3291,7 @@ def _fetch_license_from_url(self, url: str) -> str:
def _get_single_license(self, module_dict: dict):
license_ = module_dict['LicenseText']
module_name = module_dict['Name']
if module_name == 'rst2ansi':
if module_name == 'rst2ansi' and rst2ansi:
# this one module is problematic, we need to extract the license text from its docstring
assert license_ == piplicenses.LICENSE_UNKNOWN # let's make sure they didn't fix it
license_ = rst2ansi.__doc__
Expand Down
Loading