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

Update python, added linting, cleaned up the package and add recent debian and ubuntu support #10

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d008b8b
Fix test output with newer version of click
maerteijn Dec 15, 2020
a89eb77
Updated python version (3.6 / 3.7 / 3.8)
maerteijn Dec 15, 2020
8c31913
Use debian 9 for the test image, use python3-pip
maerteijn Dec 15, 2020
2097533
Use new GPG key, use python3 here
maerteijn Dec 15, 2020
745760a
Remove unneeded TODO
maerteijn Dec 15, 2020
b09da63
Updated setup.py with new info
maerteijn Dec 15, 2020
dec47e1
Drop python 2 support
maerteijn Dec 15, 2020
09014ed
Use SHA256 as key (required in debian 9)
maerteijn Dec 15, 2020
c1a4389
Make this python3 compatible
maerteijn Dec 15, 2020
3fc995a
Update build.sh to use --digest-algo SHA256
maerteijn Dec 15, 2020
c64eb0c
Restructure and cleanup the invokation of the docker image and tests
maerteijn Dec 16, 2020
80d6c88
Changed license to MIT and added a license file
maerteijn Dec 16, 2020
1c761d3
Added a simpler testpackage
maerteijn Dec 16, 2020
65983dd
Added pylint and black to the project
maerteijn Dec 16, 2020
f3d5390
Applied black
maerteijn Dec 16, 2020
61f67b2
Applied pylint and added a make lint command
maerteijn Dec 16, 2020
a955cf8
Readded python3.5, still the default python on many debian bases distros
maerteijn Dec 20, 2020
1657236
First attempt to use github actions for this
maerteijn Jan 12, 2021
4c71a9f
Added the tests
maerteijn Jan 12, 2021
30ca457
Setup the repository first
maerteijn Jan 12, 2021
0aba8ef
Split make install with make install-dev and make install-lint
maerteijn Jan 13, 2021
14743da
Run a separate test script to create a repo with a signed package
maerteijn Jan 19, 2021
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
68 changes: 68 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: vdt.simpleaptrepo ci
on: [push]

defaults:
run:
working-directory: ./src

jobs:
run-linting:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v2
with:
path: ./src
- name: Setup Python 3.6
uses: actions/setup-python@v2
with:
python-version: '3.6'
- name: Install all dependencies
run: make install
- name: Run all linting
run: make lint
- name: Upload src dir as artefact
uses: actions/upload-artifact@v2
with:
name: src
path: ./src

run-tests:
needs: run-linting
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
steps:
- name: Download src dir
uses: actions/download-artifact@v2
with:
name: src
path: ./src
- name: Setup Python 3.x
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install all dependencies
run: make install-dev
- name: Run the unittests
run: make test

run-docker:
needs: run-tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: /usr/local/src
container:
image: maerteijn/simpeapt-test-image:latest
steps:
- name: Download src dir
uses: actions/download-artifact@v2
with:
name: src
path: /usr/local/src
- name: Copy GPG keys to github home directory
run: cp -R /root/.gnupg ~
- name: Create a test repo and install a signed package
run: bash ./docker/create-test-repo.sh
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016-2021 Martijn Jacobs (maerteijn)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
19 changes: 16 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
.PHONY: clean nosetest install lint black test docker_test clean_release release_testpypi release
clean:
find . -name '*.pyc' -delete
find . -name '__pycache__' -delete
find . -name '*.egg-info' -delete

nosetest:
nosetests -s --with-coverage --cover-erase --cover-package=vdt.simpleaptrepo --cover-xml --logging-level=INFO --with-doctest --verbosity=2

install:
pip install -e .[dev,lint]

install-dev:
pip install -e .[dev]

test: install nosetest
lint:
black --check vdt/
pylint setup.py vdt/

black:
black --exclude "migrations/*" vdt/

test: nosetest

docker_test:
docker run --rm -v $(PWD):/usr/local/src maerteijn/simpeapt-test-image ./docker/run-tests.sh

clean_release: clean
if [ -d "dist" ]; then rm dist/*; fi
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
vdt.simpleaptrepo
=================

Simple command line tool to create apt repositories. This will work on debian and ubuntu.
Simple command line tool to create apt repositories. This will work on debian and ubuntu. Requires `python>=3.5`

.. image:: https://api.travis-ci.org/devopsconsulting/vdt.simpleaptrepo.svg?branch=master
:target: https://travis-ci.org/devopsconsulting/vdt.simpleaptrepo
Expand Down Expand Up @@ -58,7 +58,7 @@ You will see what you need to do now::

Configure your webservice to set the www-root to /www/
Add http://<hostname>/myrepo/test / to your sources.list

Add the key on the host where you want to install the packages.
(This is only needed once per repository)
wget -qO - http://<hostname>/myrepo/test/keyfile | sudo apt-key add -
Expand All @@ -71,7 +71,7 @@ Add some more if you like::
See that our repo is there::

simpleapt list-repos

myrepo (gpgkey: 10FB8BDC)
test
staging
Expand Down
4 changes: 0 additions & 4 deletions TODO.txt

This file was deleted.

10 changes: 4 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
FROM ubuntu
MAINTAINER Martijn Jacobs <[email protected]>
FROM debian:10
MAINTAINER Martijn Jacobs <[email protected]>

ENV DEBIAN_FRONTEND noninteractive

# install the debian related packages for this tool + python pip
RUN apt-get update && apt-get install python-pip gnupg dpkg-sig apt-utils --yes
RUN apt-get update && apt-get install python3-pip gnupg dpkg-sig apt-utils --yes

# Make sure you mounted the source coude in /usr/local/src
WORKDIR /usr/local/src/

ENTRYPOINT ["make", "test"]
WORKDIR /usr/local/src/
4 changes: 2 additions & 2 deletions docker/build.sh → docker/build-test-image.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
docker build -t maerteijn/simpeapt-test-image .

# run a interactive shell and you should generate a gpg key
echo "Please run /usr/bin/gpg --gen-key, then exit the container with ctrl+D"
echo "Please run /usr/bin/gpg --digest-algo SHA256 --gen-key, then exit the container with ctrl+D"
docker run -it --name=simpleapt-test-image-generate-key maerteijn/simpeapt-test-image /bin/bash

echo "Please remember the generated GPG key hash"
Expand All @@ -13,4 +13,4 @@ docker commit simpleapt-test-image-generate-key maerteijn/simpeapt-test-image

echo "Done!"
echo "Now push the image with 'docker push maerteijn/simpeapt-test-image'"
echo "and delete the container afterwards: 'docker rm simpleapt-test-image-generate-key'"
echo "and delete the container afterwards: 'docker rm simpleapt-test-image-generate-key'"
33 changes: 33 additions & 0 deletions docker/create-test-repo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
export LC_ALL=C.UTF-8
export LANG=C.UTF-8

# install simpleaptrepo
pip3 install -e .

# do some cleanup
if [ -d "/repos/" ]; then
rm -Rf /repos/
fi

# create a repo directory
mkdir /repos

# now we really create a repo here and add a package
# the gpg key is build into the docker image for testing purposes
simpleapt create-repo myrepo /repos --gpgkey B7C72A100F81017B
simpleapt add-component myrepo test
simpleapt list-repos
cp /usr/local/src/vdt/simpleaptrepo/tests/testdata/*.deb /repos/myrepo/test
simpleapt update-repo myrepo test
simpleapt update-repo myrepo test --skip-signed

# add the created repo as a local source
echo "deb file:/repos/myrepo/test /" > /etc/apt/sources.list.d/local.list

# add the GPG key as a valid key:
cat /repos/myrepo/test/keyfile | apt-key add -

# update the apt repository and install the signed package
apt-get update
apt-get install --yes testpackage
7 changes: 0 additions & 7 deletions docker/docker-compose.yml

This file was deleted.

18 changes: 0 additions & 18 deletions docker/entrypoint.sh

This file was deleted.

8 changes: 8 additions & 0 deletions docker/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
export LC_ALL=C.UTF-8
export LANG=C.UTF-8

# runs the unittests
python3 -m pip install pip --upgrade
pip3 install -e .[dev]
make nosetest
5 changes: 5 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[pylint.MASTER]
jobs=4

[pylint.'MESSAGES CONTROL']
disable = R,C,W5103
13 changes: 7 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

__version__ = "0.0.5"
__version__ = "1.0.0"


setup(
Expand All @@ -14,19 +14,18 @@
'License :: OSI Approved :: BSD License',
'Operating System :: Unix',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',

'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
],
keywords='',
author='Martijn Jacobs',
author_email='[email protected]',
author_email='[email protected]',
url='https://github.com/devopsconsulting/vdt.simpleaptrepo',
license='BSD',
license='MIT',
# include all packages in the egg, except the test package.
packages=find_packages(
exclude=['ez_setup', 'examples', '*tests']),
Expand All @@ -48,5 +47,7 @@
# mark test target to require extras.
extras_require={
'dev': ['nose', 'coverage', 'mock', 'twine'],
'lint': ['black', 'pylint'],
},
python_requires='>=3.5',
)
2 changes: 1 addition & 1 deletion vdt/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__import__('pkg_resources').declare_namespace(__name__)
__import__("pkg_resources").declare_namespace(__name__)
Loading