Skip to content

Commit

Permalink
Merge pull request #44 from mesozoic/pipes_deprecated
Browse files Browse the repository at this point in the history
Fix unit/integration tests
  • Loading branch information
chriskuehl authored Apr 26, 2023
2 parents e191414 + 881bf09 commit 6a6ac54
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 38 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
---
name: build
on: push
on: [push, pull_request]
jobs:
make:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
make_target:
- test
- itest_xenial
- itest_bionic
- itest_focal
- itest_jammy
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.6
python-version: 3.11
- run: pip install tox
- run: sudo apt-get install -y --no-install-recommends zsh
- run: make ${{ matrix.make_target }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/aactivator-build-deps_*
/build
/dist
/.cache
Expand All @@ -6,4 +7,5 @@
/.tox

*.deb
*.egg-info
*.py[co]
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ RUN apt-get update \
lintian \
&& apt-get clean

WORKDIR /mnt
# debuild will fail when running directly against /mnt, so we copy the files we need
RUN mkdir /build
COPY debian /build/debian
COPY Makefile aactivator.py /build/
WORKDIR /build

CMD [ \
"dumb-init", \
"sh", "-euxc", \
"mk-build-deps -ir --tool 'apt-get --no-install-recommends -y' debian/control && make builddeb" \
"mk-build-deps -ir --tool 'apt-get --no-install-recommends -y' debian/control && make builddeb && cp ./dist/* /mnt/dist" \
]
14 changes: 5 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,11 @@ builddeb-docker: docker-builder-image
mkdir -p dist
docker run -v $(PWD):/mnt $(DOCKER_BUILDER)

ITEST_TARGETS = itest_xenial itest_bionic itest_stretch itest_buster
ITEST_TARGETS = itest_focal itest_jammy

.PHONY: itest $(ITEST_TARGETS)
.PHONY: itest
itest: $(ITEST_TARGETS)

itest_xenial: _itest-ubuntu-xenial
itest_bionic: _itest-ubuntu-bionic
itest_focal: _itest-ubuntu-focal
itest_jammy: _itest-ubuntu-jammy

_itest-%: builddeb-docker
$(DOCKER_RUN_TEST) $(shell sed 's/-/:/' <<< "$*") /mnt/ci/docker
.PHONY: itest_%
itest_%: builddeb-docker
$(DOCKER_RUN_TEST) ubuntu:$* /mnt/ci/docker
19 changes: 7 additions & 12 deletions ci/docker
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,22 @@ set -o pipefail
# We need to set standard /tmp permissions since it's a Docker volume.
chmod 1777 /tmp

# The default mirrors are too flaky to run reliably in CI.
sed -E \
'/security\.debian/! s@http://[^/]+/@http://mirrors.kernel.org/@' \
-i /etc/apt/sources.list

apt-get update
apt-get install -y --no-install-recommends \
bash \
build-essential \
ca-certificates \
curl \
gdebi-core \
python3-dev \
python3 \
virtualenv \
zsh

# TODO: Remove python3.5 constraint on get-pip.py once xenial is dumped
curl https://bootstrap.pypa.io/pip/3.5/get-pip.py | python3
gdebi -n /mnt/dist/*.deb
pip install -r /mnt/requirements-dev.txt
pip install /mnt

# pytest can't deal with a read-only filesystem
# pip & pytest can't deal with a read-only filesystem
cp -r /mnt /tmp/test
pytest -vv /tmp/test
virtualenv -ppython3 /tmp/venv
/tmp/venv/bin/pip install -r /tmp/test/requirements-dev.txt
/tmp/venv/bin/pip install /tmp/test
/tmp/venv/bin/pytest -vv /tmp/test
2 changes: 1 addition & 1 deletion debian/compat
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9
11
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
classifiers=[
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'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',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
],
python_requires='>=3.3',
python_requires='>=3.7',
py_modules=['aactivator'],
entry_points={
'console_scripts': [
Expand Down
7 changes: 4 additions & 3 deletions tests/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ def get_proc(shell, homedir):
shell[0], list(shell[1:]),
timeout=5,
env={
'BASH_SILENCE_DEPRECATION_WARNING': '1', # macOS
'COVERAGE_PROCESS_START': os.environ.get(
'COVERAGE_PROCESS_START', '',
),
'PS1': PS1,
'TOP': os.environ.get('TOP', ''),
'HOME': str(homedir),
'PATH': os.path.dirname(sys.executable) + os.defpath
'PATH': os.pathsep.join([os.path.dirname(sys.executable), os.defpath]),
},
)

Expand All @@ -42,8 +43,8 @@ def expect_exact_better(proc, expected):
"""
# I'd put a $ on the end of this regex, but sometimes the buffer comes
# to us too quickly for our assertions
before = proc.before
after = proc.after
before = proc.before or b''
after = proc.after or b''
reg = '^' + re.escape(expected)
reg = reg.replace('\n', '\r*\n')
try:
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[tox]
envlist = py36
envlist = py37,py38,py39,py310,py311

[testenv]
deps = -rrequirements-dev.txt
commands =
coverage erase
coverage run -m pytest -vv tests/
coverage run -m pytest -vv {posargs:tests}
coverage combine
coverage report --show-missing
pre-commit run --all-files
Expand Down

0 comments on commit 6a6ac54

Please sign in to comment.