Skip to content

Test/todo binary #1

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

Merged
merged 11 commits into from
Aug 7, 2023
Merged
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
31 changes: 14 additions & 17 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,37 @@ BUILD_TEST_TASK_TEMPLATE: &BUILD_TEST_TASK_TEMPLATE
- python --version
- python -m pip install --upgrade pip
- python -m pip install -r requirements_dev.txt
- python -m flake8 --show-source --exclude examples/grpc/area_calculator_pb2.py,examples/grpc/area_calculator_pb2_grpc.py,.git,__pycache__,build,dist,.tox
- python -m flake8 --exclude '*pb2*',.git,__pycache__,build,dist,.tox --show-source
- python -m pydocstyle pact
- python -m tox -e test
- make examples
- make todo

env:
RUN_BROKER: 0
USE_HOSTED_PACT_BROKER: 1
USE_STANDALONE: 1

PYTHON_VERSION_MATRIX: &PYTHON_VERSION_MATRIX
- VERSION: 3.11
# - VERSION: 3.6
# - VERSION: 3.7
# - VERSION: 3.8
# - VERSION: 3.9
# - VERSION: 3.10

linux_arm64_task:
only_if: $CIRRUS_CHANGE_TITLE !=~ 'ci\(gha\).*'
env:
# PACT_FFI_PATH: .tox/test/lib/python$VERSION/site-packages/pact/bin
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: python
LANG: C.UTF-8 # required for python 3.6 docker image
matrix:
- VERSION: 3.6
- VERSION: 3.7
- VERSION: 3.8
- VERSION: 3.9
- VERSION: 3.10
- VERSION: 3.11
<<: *PYTHON_VERSION_MATRIX
arm_container:
image: python:$VERSION-slim
install_script:
- apt update --yes && apt install --yes gcc make curl
<< : *BUILD_TEST_TASK_TEMPLATE


macos_arm64_task:
only_if: $CIRRUS_CHANGE_TITLE !=~ 'ci\(gha\).*'
macos_instance:
Expand All @@ -43,15 +45,10 @@ macos_arm64_task:
PATH: ${HOME}/.pyenv/shims:${PATH}
# PACT_FFI_PATH: .tox/test/lib/python$VERSION/site-packages/pact/bin
matrix:
- VERSION: 3.6
- VERSION: 3.7
- VERSION: 3.8
- VERSION: 3.9
- VERSION: 3.10
- VERSION: 3.11
<<: *PYTHON_VERSION_MATRIX
install_script:
- brew update
- brew install pyenv protobuf # protobuf only needed if using grpc plugins
- brew install pyenv protobuf shared-mime-info # protobuf only needed if using grpc plugins
- pyenv install ${VERSION}
- pyenv global ${VERSION}
- pyenv rehash
Expand Down
24 changes: 14 additions & 10 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:

matrix:
python-version:
- '3.7'
- '3.8'
- '3.9'
- '3.10'
# - '3.7'
# - '3.8'
# - '3.9'
# - '3.10'
- '3.11'
os: [
ubuntu-latest,
Expand All @@ -27,9 +27,13 @@ jobs:

# These versions are no longer supported by Python team, and may
# eventually be dropped from GitHub Actions.
include:
- python-version: '3.6'
os: ubuntu-20.04
# include:
# - python-version: '3.6'
# os: ubuntu-20.04
# - python-version: '3.6'
# os: windows-latest
# - python-version: '3.6'
# os: macos-latest

steps:
- name: Check out code
Expand All @@ -47,7 +51,7 @@ jobs:

- name: Lint with flake8, pydocstyle
run: |
flake8 --show-source --exclude examples/grpc/area_calculator_pb2.py,examples/grpc/area_calculator_pb2_grpc.py,.git,__pycache__,build,dist,.tox
flake8 --show-source --exclude '*pb2*',.git,__pycache__,build,dist,.tox
pydocstyle pact

- name: Install Pact plugins for tests
Expand All @@ -61,12 +65,12 @@ jobs:

- name: Test examples
if: runner.os == 'Linux'
run: make examples
run: make todo

- name: Test examples
# no docker so we use a hosted pact broker and pact-ruby-standalone for publishing
if: runner.os != 'Linux'
run: make examples
run: make todo
env:
RUN_BROKER: 0
USE_HOSTED_PACT_BROKER: 1
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export GRPC
define TODO
echo "todo make"
cd examples/todo
pip install -q -r requirements.txt
pip install -r requirements.txt
pip install -e ../../
./run_pytest.sh
endef
Expand Down Expand Up @@ -128,7 +128,7 @@ todo:


.PHONY: examples
examples: consumer flask fastapi messaging grpc
examples: consumer flask fastapi messaging grpc todo
# examples: consumer flask fastapi messaging todo


Expand Down
193 changes: 0 additions & 193 deletions examples/todo/pacts/TodoApp-TodoServiceV3.json

This file was deleted.

7 changes: 4 additions & 3 deletions examples/todo/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
json2xml==3.21.0
pytest-flask==1.1.0
json2xml==3.8.0; python_version < '3.7'
json2xml==3.21.0; python_version >= '3.7'
Flask==2.0.3; python_version < '3.7'
Flask==2.2.5; python_version >= '3.7'
pytest==7.0.1; python_version < '3.7'
pytest==6.2.5; python_version < '3.7'
pytest==7.1.3; python_version >= '3.7'
requests==2.27.1; python_version < '3.7'
requests==2.26.0; python_version < '3.7'
requests>=2.28.0; python_version >= '3.7'
13 changes: 11 additions & 2 deletions examples/todo/src/todo_consumer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import os
import requests
import xml.etree.ElementTree as ET

import platform
target_platform = platform.platform().lower()
is_not_win = any(substring in target_platform for substring in ['linux', 'macos'])
is_gha = os.getenv("ACT") == "true" or os.getenv("GITHUB_ACTIONS") == "true"
mime_type = 'image/jpeg' if is_not_win and is_gha else 'application/octet-stream'

class TodoConsumer(object):
def __init__(self, base_uri):
Expand All @@ -25,6 +30,10 @@ def get_projects(self, format='json'):

def post_image(self, id, file_path):
"""Store an image against a project"""
print(id)
print(file_path)
print(mime_type)
print(target_platform)
uri = self.base_uri + '/projects/' + str(id) + '/images'
response = requests.post(uri, data=open(file_path, 'rb'), headers={'Content-Type': 'application/octet-stream'})
response = requests.post(uri, data=open(file_path, 'rb'), headers={'Content-Type': mime_type})
response.raise_for_status()
Loading