Skip to content

Commit

Permalink
Switch from Travis to GH actions; tweak build scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
crashvb committed Apr 8, 2022
1 parent f852cc3 commit 846825a
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 28 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
name: tests
on: [push, pull_request]
jobs:
tests:
defaults:
run:
shell: 'script --command "bash {0}" --quiet --return'
if: github.repository == 'crashvb/pytest-docker-haproxy-fixtures'
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: "${{matrix.python-version}}"
- name: setup virtual enviroment
run: make venv
- name: pytest
# continue-on-error: true
run: |
source .venv/bin/activate
make test
coveralls --service=github
env:
COVERALLS_FLAG_NAME: "${{matrix.python-version}}"
COVERALLS_PARALLEL: true
DSV_GPG_LOG_ERRORS: true
GITHUB_TOKEN: "${{secrets.GITHUB_TOKEN}}"
TRAVIS: true
- name: pylint
# continue-on-error: true
run: |
source .venv/bin/activate
make test-code
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
coveralls:
defaults:
run:
shell: 'script --command "bash {0}" --quiet --return'
if: github.repository == 'crashvb/pytest-docker-haproxy-fixtures'
needs: tests
runs-on: ubuntu-20.04
steps:
- uses: actions/setup-python@v3
with:
python-version: "3.8"
- name: finalize coveralls
run: |
python -m pip install --upgrade coveralls
coveralls --finish --service=github
env:
GITHUB_TOKEN: "${{secrets.GITHUB_TOKEN}}"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.coverage
.eggs
.idea
.venv
Expand All @@ -6,5 +7,6 @@ dist
tmp

*.egg-info
*.local
*.pyc
*.swp
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# pytest-docker-haproxy-fixtures

[![pypi version](https://img.shields.io/pypi/v/pytest-docker-haproxy-fixtures.svg)](https://pypi.org/project/pytest-docker-haproxy-fixtures)
[![build status](https://github.com/crashvb/pytest-docker-haproxy-fixtures/actions/workflows/main.yml/badge.svg)](https://github.com/crashvb/pytest-docker-haproxy-fixtures/actions)
[![coverage status](https://coveralls.io/repos/github/crashvb/pytest-docker-haproxy-fixtures/badge.svg)](https://coveralls.io/github/crashvb/pytest-docker-haproxy-fixtures)
[![python versions](https://img.shields.io/pypi/pyversions/pytest-docker-haproxy-fixtures.svg?logo=python&logoColor=FBE072)](https://pypi.org/project/pytest-docker-haproxy-fixtures)
[![linting](https://img.shields.io/badge/linting-pylint-yellowgreen)](https://github.com/PyCQA/pylint)
[![code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![license](https://img.shields.io/github/license/crashvb/pytest-docker-haproxy-fixtures.svg)](https://github.com/crashvb/pytest-docker-haproxy-fixtures/blob/master/LICENSE)

## Overview

Pytest fixtures to instantiate and utilize local haproxy docker containers, using [lovely-pytest-docker](https://pypi.org/project/lovely-pytest-docker) and [docker-py](https://pypi.org/project/docker-py), for testing.
Expand Down Expand Up @@ -35,9 +43,6 @@ def test_haproxy_insecure(haproxy_insecure: HAProxyInsecure):
```

The `push_image` mark can optionally be added to stage images in the haproxy prior to testing. See [Markers](#markers) for details.
## Compatibility

* Tested with python 3.8

## Installation
### From [pypi.org](https://pypi.org/project/pytest-docker-haproxy-fixtures/)
Expand Down
37 changes: 25 additions & 12 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#! /usr/bin/make -f
#!/usr/bin/make -f

-include makefile.config
include makefile.config
-include makefile.config.local

.PHONY: black build clean default deploy deploy-test purge release sign test test-all test-all-verbose test-code test-package test-verbose venv .venv verify
.PHONY: black build clean default deploy deploy-test purge release sign test test-all test-all-verbose test-code test-coverage test-coverage-all test-coverage-all-verbose test-coverage-verbose test-package test-verbose venv .venv verify

tmpdir:=$(shell mktemp --directory)
package_folder := $(shell sed --expression='s/^.*name="\(.*\)",/\1/p' --quiet setup.py)
package_name := $(shell sed --expression='s/_/-/g' --expression='s/^.*name="\(.*\)",/\1/p' --quiet setup.py)

default: build

Expand All @@ -24,7 +26,6 @@ deploy-test: clean build sign

release:
@[ "X$(shell git status --porcelain 2>&1)" = "X" ] || (echo "GIT work tree is dirty!" && /bin/false)
$(eval package_name := $(shell sed --expression='s/_/-/g' --expression='s/^.*name="\(.*\)",/\1/p' --quiet setup.py))
@echo "Detected package: $(package_name)"
$(eval version_current := $(shell sed --expression='s/^__version__ = "\(.*\)"/\1/p' --quiet */__init__.py))
@echo "Detected current version as: $(version_current)"
Expand All @@ -46,19 +47,31 @@ sign:
find dist -type f \( -iname "*.tar.gz" -o -iname "*.whl" \) -exec gpg --armor --detach-sig --local-user=$(keyid) --sign {} \;

test:
python -m pytest --log-cli-level info $(args)
python -m pytest --cov=$(package_folder) --cov-report= --log-cli-level info $(args)

test-all:
python -m pytest --log-cli-level info --allow-online $(args)
python -m pytest --cov=$(package_folder) --cov-report= --log-cli-level info $(test_all_args) $(args)

test-all-verbose:
python -m pytest --log-cli-level debug --allow-online $(args)
python -m pytest --cov=$(package_folder) --cov-report= --log-cli-level debug $(test_all_args) $(args)

test-code:
# Note: https://github.com/PyCQA/pylint/issues/289
python -m pylint --disable C0330,R0801 --max-line-length=120 pytest_docker_haproxy_fixtures tests
python -m pylint --disable=$(pylint_disable) --max-line-length=120 $(package_folder) tests

test-coverage: test
coverage report --fail-under=80

test-coverage-all: test-all
coverage report --fail-under=80

test-coverage-all-verbose: test-all-verbose
coverage report --fail-under=80

test-coverage-verbose: test-verbose
coverage report --fail-under=80

test-package: build
$(eval tmpdir := $(shell mktemp --directory))
python -m venv $(tmpdir)

cd /tmp
Expand All @@ -67,7 +80,7 @@ test-package: build
rm --force --recursive $(tmpdir)

test-verbose:
python -m pytest -r sx --log-cli-level debug $(args)
python -m pytest -r sx --cov=$(package_folder) --cov-report= --log-cli-level debug $(args)

.venv:
python -m venv .venv
Expand All @@ -80,7 +93,7 @@ verify:
find dist -type f -iname "*.asc" -exec gpg --verify {} \;

clean:
rm --force --recursive .eggs build dist *.egg-info
rm --force --recursive .coverage .eggs build dist *.egg-info
find . -type f -name "*.pyc" -delete
find . -type d -name __pycache__ -delete

Expand Down
4 changes: 4 additions & 0 deletions makefile.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/make -f

pylint_disable=R0401,R0801,W0511
test_all_args=--allow-online
19 changes: 16 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,26 @@ def find_version(*segments):
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Operating System :: OS Independent",
],
description="Pytest fixtures for testing with haproxy.",
entry_points={
"pytest11": ["docker_haproxy_fixtures = pytest_docker_haproxy_fixtures"]
},
extras_require={"dev": ["black", "pylint", "twine", "wheel"]},
extras_require={
"dev": [
"black",
"coveralls",
"pylint",
"pytest",
"pytest-cov",
"twine",
"wheel",
]
},
include_package_data=True,
install_requires=[
"bcrypt",
Expand All @@ -42,7 +55,7 @@ def find_version(*segments):
"pytest",
],
keywords="docker fixtures haproxy pytest",
license="GNU General Public License v3.0",
license="Apache License 2.0",
long_description=open("README.md", encoding="utf-8").read(),
long_description_content_type="text/markdown",
name="pytest_docker_haproxy_fixtures",
Expand All @@ -54,8 +67,8 @@ def find_version(*segments):
"Bug Reports": "https://github.com/crashvb/pytest-docker-haproxy-fixtures/issues",
"Source": "https://github.com/crashvb/pytest-docker-haproxy-fixtures",
},
tests_require=["pytest", "urllib3"],
test_suite="tests",
tests_require=["urllib3"],
url="https://github.com/crashvb/pytest-docker-haproxy-fixtures",
version=find_version("pytest_docker_haproxy_fixtures", "__init__.py"),
)

0 comments on commit 846825a

Please sign in to comment.