Skip to content

Commit

Permalink
Update the pipeline to cover more supported code. (#82)
Browse files Browse the repository at this point in the history
This updates the pipeline to use new versions of pre-commit repos.
This also covers more of the post deployment testing code for
implementers to debug installations.

Signed-off-by: David Brown <dmlb2000@gmail.com>
  • Loading branch information
dmlb2000 committed May 16, 2019
1 parent a473b1a commit 17acf23
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 55 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
repos:
- repo: https://github.com/pre-commit/mirrors-autopep8
rev: v1.4.3
rev: v1.4.4
hooks:
- id: autopep8
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0
rev: v2.2.2
hooks:
- id: fix-encoding-pragma
- id: trailing-whitespace
Expand Down
99 changes: 52 additions & 47 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,62 +1,67 @@
language: python
dist: xenial
stages:
- lint
- test
- test-docker
- deploy
".script": &1
- pip install .
- export ARCHIVEINTERFACE_CPCONFIG=$PWD/server.conf
- cd tests
- coverage run --include '*/site-packages/pacifica/archiveinterface/*' --omit '*/site-packages/pacifica/archiveinterface/backends/abstract/*' -m pacifica.archiveinterface --stop-after-a-moment
- coverage run -a --include '*/site-packages/pacifica/archiveinterface/*' --omit '*/site-packages/pacifica/archiveinterface/backends/abstract/*' -m pytest -xv
- coverage report -m --fail-under 100
".lint_block": &3
stage: lint
script: pre-commit run -a
".docker_block": &2
stage: test-docker
sudo: required
services:
- docker
script:
- docker-compose build --pull
- docker-compose up -d
- cd post_deployment_tests
- python -m unittest deployment_test
".test_block": &1
stage: test
script:
- pip install .
- export ARCHIVEINTERFACE_CPCONFIG=$PWD/server.conf
- cd tests
- coverage run --include '*/site-packages/pacifica/archiveinterface/*' --omit '*/site-packages/pacifica/archiveinterface/backends/abstract/*' -m pacifica.archiveinterface --stop-after-a-moment
- coverage run -a --include '*/site-packages/pacifica/archiveinterface/*' --omit '*/site-packages/pacifica/archiveinterface/backends/abstract/*' -m pytest -xv
- coverage report -m --fail-under 100
".deploy_block": &4
stage: deploy
language: python
script: skip
".deploy_attrs": &5
skip_cleanup: true
provider: pypi
user: dmlb2000
password:
secure: S/O36Q5SiMtYF8Gtovo0hO7tczJc+YB79RGyBylmGjhmXlMfYv0bHAtYTEwGbqSrB1gGZgV0JMTvOKFmfHPIOm0mYxobPBgzNqAK0uqI+zueVf2+KmxwzC45uXRAzsRjcjMr66bPf04WRYP1vT7Lhp/JJ5nwfAT81TGERo1rP2w4gs/8fvZWJPmexFOocyNRYpf8yg+bQrIQzco/neNgjvPtYd7P1tBhJcxngkMRAd0HXc6ehegUbqHVotvTXH8BG+h9ZRZd5szrRlyfl5+u8YcBKx4cm4i2ayJ43/vurIJIs6CULsvFTClHol/4mFW2uyg3mqw1E37fd0HoHsY7FPR81cdPnpgA5ljieJIh6XCVF8rE7rYoPuedAcFlqTHSkqZoCNK/uodY91SQFyyYW2msWWYAGMDrJ4bHQEWYIkkNf+wCFHG6wAIVIhlJiOZa0Y5aopVtlrpRVgKPw5U0XfqNjI82yXU+W8H3WC0bXK3ggrHE+JPFNqEd2bAS4a3NOFNxeVRtql/qYw7QN4EUa6XHTl6IRbeSVSJX43BeREktDdIFKnZ/i3jUutbSX4jwsDUsstobQjmdksi97QkAsNIBTiG67QqJJloSf6Kv4gbpYfDZ3zaPkzVgrjJnViqyLUU/JS2iTimsB/gq3EMUNgPSQWCLtOlOeo4sDNG5Pbg=
on:
tags: true
jobs:
include:
- stage: lint
python: 3.6
script: pre-commit run -a
- python: 3.6
<<: *3
- python: 2.7
script: pre-commit run -a
- stage: test
script: *1
python: 3.6
- script: *1
python: 2.7
- stage: test-docker
sudo: required
python: 2.7
services:
- docker
script: >
docker-compose build --pull;
docker-compose up -d;
cd post_deployment_tests;
python -m unittest deployment_test.BasicArchiveTests
- stage: deploy
language: python
script: skip
python: 3.6
<<: *3
- python: 3.6
<<: *1
- python: 2.7
<<: *1
- python: 3.6
<<: *2
- python: 2.7
<<: *2
- python: 3.6
deploy:
skip_cleanup: true
provider: pypi
user: dmlb2000
distributions: sdist bdist_wheel
password:
secure: S/O36Q5SiMtYF8Gtovo0hO7tczJc+YB79RGyBylmGjhmXlMfYv0bHAtYTEwGbqSrB1gGZgV0JMTvOKFmfHPIOm0mYxobPBgzNqAK0uqI+zueVf2+KmxwzC45uXRAzsRjcjMr66bPf04WRYP1vT7Lhp/JJ5nwfAT81TGERo1rP2w4gs/8fvZWJPmexFOocyNRYpf8yg+bQrIQzco/neNgjvPtYd7P1tBhJcxngkMRAd0HXc6ehegUbqHVotvTXH8BG+h9ZRZd5szrRlyfl5+u8YcBKx4cm4i2ayJ43/vurIJIs6CULsvFTClHol/4mFW2uyg3mqw1E37fd0HoHsY7FPR81cdPnpgA5ljieJIh6XCVF8rE7rYoPuedAcFlqTHSkqZoCNK/uodY91SQFyyYW2msWWYAGMDrJ4bHQEWYIkkNf+wCFHG6wAIVIhlJiOZa0Y5aopVtlrpRVgKPw5U0XfqNjI82yXU+W8H3WC0bXK3ggrHE+JPFNqEd2bAS4a3NOFNxeVRtql/qYw7QN4EUa6XHTl6IRbeSVSJX43BeREktDdIFKnZ/i3jUutbSX4jwsDUsstobQjmdksi97QkAsNIBTiG67QqJJloSf6Kv4gbpYfDZ3zaPkzVgrjJnViqyLUU/JS2iTimsB/gq3EMUNgPSQWCLtOlOeo4sDNG5Pbg=
on:
tags: true
- language: python
python: 2.7
script: skip
<<: *5
<<: *4
- python: 2.7
deploy:
skip_cleanup: true
provider: pypi
user: dmlb2000
distributions: bdist_wheel
password:
secure: S/O36Q5SiMtYF8Gtovo0hO7tczJc+YB79RGyBylmGjhmXlMfYv0bHAtYTEwGbqSrB1gGZgV0JMTvOKFmfHPIOm0mYxobPBgzNqAK0uqI+zueVf2+KmxwzC45uXRAzsRjcjMr66bPf04WRYP1vT7Lhp/JJ5nwfAT81TGERo1rP2w4gs/8fvZWJPmexFOocyNRYpf8yg+bQrIQzco/neNgjvPtYd7P1tBhJcxngkMRAd0HXc6ehegUbqHVotvTXH8BG+h9ZRZd5szrRlyfl5+u8YcBKx4cm4i2ayJ43/vurIJIs6CULsvFTClHol/4mFW2uyg3mqw1E37fd0HoHsY7FPR81cdPnpgA5ljieJIh6XCVF8rE7rYoPuedAcFlqTHSkqZoCNK/uodY91SQFyyYW2msWWYAGMDrJ4bHQEWYIkkNf+wCFHG6wAIVIhlJiOZa0Y5aopVtlrpRVgKPw5U0XfqNjI82yXU+W8H3WC0bXK3ggrHE+JPFNqEd2bAS4a3NOFNxeVRtql/qYw7QN4EUa6XHTl6IRbeSVSJX43BeREktDdIFKnZ/i3jUutbSX4jwsDUsstobQjmdksi97QkAsNIBTiG67QqJJloSf6Kv4gbpYfDZ3zaPkzVgrjJnViqyLUU/JS2iTimsB/gq3EMUNgPSQWCLtOlOeo4sDNG5Pbg=
on:
tags: true
<<: *5
<<: *4
install:
- pip install -r requirements-dev.txt
12 changes: 6 additions & 6 deletions post_deployment_tests/deployment_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def unistr2binary(data_str):
"""Convert a string to binary in 2/3."""
if PY2: # pragma: no cover python 2 only
return bytearray(data_str)
return bytes(data_str, 'utf8') # pragma: no cover python 3 only
return bytearray(data_str, 'utf8') # pragma: no cover python 3 only


class BasicArchiveTests(unittest.TestCase):
Expand Down Expand Up @@ -104,7 +104,7 @@ class BinaryFileArchiveTests(unittest.TestCase):
def test_binary_file_write(self):
"""Write a binary file to the archive."""
fileid = '4321'
data = unistr2binary([123, 3, 255, 0, 100])
data = bytearray([123, 3, 255, 0, 100])
resp = requests.put('{}/{}'.format(ARCHIVEURL, fileid), data=data)
self.assertEqual(resp.status_code, 201)
respdata = resp.json()
Expand All @@ -114,7 +114,7 @@ def test_binary_file_write(self):
def test_binary_file_status(self):
"""Get a status for a binary file in the archive."""
fileid = '4322'
data = unistr2binary([123, 3, 255, 0, 100])
data = bytearray([123, 3, 255, 0, 100])
resp = requests.put('{}/{}'.format(ARCHIVEURL, fileid), data=data)
self.assertEqual(resp.status_code, 201)
resp = requests.head('{}/{}'.format(ARCHIVEURL, fileid))
Expand All @@ -126,7 +126,7 @@ def test_binary_file_status(self):
def test_binary_file_stage(self):
"""test staging a binary file."""
fileid = '4323'
data = unistr2binary([123, 3, 255, 0, 100])
data = bytearray([123, 3, 255, 0, 100])
resp = requests.put('{}/{}'.format(ARCHIVEURL, fileid), data=data)
self.assertEqual(resp.status_code, 201)
resp = requests.post('{}/{}'.format(ARCHIVEURL, fileid))
Expand All @@ -137,7 +137,7 @@ def test_binary_file_stage(self):
def test_binary_file_read(self):
"""test reading a binary file back form the archive."""
fileid = '4324'
data = unistr2binary([123, 3, 255, 0, 100])
data = bytearray([123, 3, 255, 0, 100])
resp = requests.put('{}/{}'.format(ARCHIVEURL, fileid), data=data)
self.assertEqual(resp.status_code, 201)
resp = requests.get('{}/{}'.format(ARCHIVEURL, fileid), stream=True)
Expand All @@ -147,7 +147,7 @@ def test_binary_file_read(self):
def test_binary_file_rewrite(self):
"""Test trying to rewrite a file, rewrite should fail."""
fileid = '4325'
data = unistr2binary([123, 3, 255, 0, 100])
data = bytearray([123, 3, 255, 0, 100])
resp = requests.put('{}/{}'.format(ARCHIVEURL, fileid), data=data)
self.assertEqual(resp.status_code, 201)
resp = requests.put('{}/{}'.format(ARCHIVEURL, fileid), data=data)
Expand Down

0 comments on commit 17acf23

Please sign in to comment.