Skip to content

Commit

Permalink
Merge pull request #7 from pactflow/deps/pact_v2_python_3_11
Browse files Browse the repository at this point in the history
Deps/pact v2 python 3 11
  • Loading branch information
YOU54F authored Oct 17, 2024
2 parents cb43883 + 0577116 commit b7cf768
Show file tree
Hide file tree
Showing 7 changed files with 866 additions and 389 deletions.
Empty file removed .env
Empty file.
17 changes: 3 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,10 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.8"
# - name: Install python version
# uses: gabrielfalcao/pyenv-action@v10
# with:
# default: 3.8.13
# command: pip install -U pip # upgrade pip after installing python
# - name: Create virtualenv for python 3.5.7
# run: pyenv local 3.8.13 && python3 -mvenv .venv
# - name: venv
# run: pyenv local 3.8.13 && python3 -mvenv .venv3813
python-version: "3.11"
- name: install pyenv
run: curl https://pyenv.run | bash
- name: set pyenv on path
Expand All @@ -43,12 +34,10 @@ jobs:
run: make venv
- name: Install
run: make deps
- name: Activate virtual env
- name: Activate virtual env & test
run: |
source .venv/bin/activate
make test
# - name: Test
# run: make test
- name: Publish pacts
run: GIT_BRANCH=${GIT_REF:11} make publish_pacts

Expand Down
17 changes: 7 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ ci: test publish_pacts can_i_deploy $(DEPLOY_TARGET)
# Run the ci target from a developer machine with the environment variables
# set as if it was on Travis CI.
# Use this for quick feedback when playing around with your workflows.
fake_ci: .env
fake_ci:
CI=true \
GIT_COMMIT=`git rev-parse --short HEAD`+`date +%s` \
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` \
make ci


publish_pacts: .env
publish_pacts:
@"${PACT_CLI}" publish ${PWD}/pacts --consumer-app-version ${GIT_COMMIT} --tag ${GIT_BRANCH} --branch ${GIT_BRANCH}

## =====================
## Build/test tasks
## =====================

test: .env
test:
python3 -m pytest

## =====================
Expand All @@ -51,18 +51,18 @@ deploy: deploy_app record_deployment
no_deploy:
@echo "Not deploying as not on main branch"

can_i_deploy: .env
can_i_deploy:
@"${PACT_CLI}" broker can-i-deploy \
--pacticipant ${PACTICIPANT} \
--version ${GIT_COMMIT} \
--to-environment production \
--retry-while-unknown 0 \
--retry-while-unknown 5 \
--retry-interval 10

deploy_app:
@echo "Deploying to production"

record_deployment: .env
record_deployment:
@"${PACT_CLI}" broker record-deployment --pacticipant ${PACTICIPANT} --version ${GIT_COMMIT} --environment production

## =====================
Expand Down Expand Up @@ -101,16 +101,13 @@ test_github_webhook:
## Misc
## ======================

.env:
touch .env

.PHONY: test

## ======================
## Python additions
## ======================
PROJECT := example-consumer-python-sns
PYTHON_MAJOR_VERSION := 3.8
PYTHON_MAJOR_VERSION := 3.11

sgr0 := $(shell tput sgr0)
red := $(shell tput setaf 1)
Expand Down
1,207 changes: 849 additions & 358 deletions poetry.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry.dependencies]
python = "^3.8"
python = "^3.11"

[tool.poetry.dev-dependencies]
pytest = "7.1.2"
pytest-asyncio = "^0.18.3"
pytest-mock = "^3.7.0"
pact-python = "^1.5.2"
pytest = "8.3.3"
pytest-asyncio = "^0.24.0"
pytest-mock = "^3.14.0"
pact-python = "^2.2.2"
2 changes: 1 addition & 1 deletion template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Resources:
Type: AWS::Serverless::Function
Properties:
Description: A Lambda function that receives a Product update event from the ProductEvent topic
Runtime: python3.8
Runtime: python3.11
Handler: src.lambda.product.handler
# This property associates this Lambda function with the SNS topic defined above, so that whenever the topic
# receives a message, the Lambda function is invoked
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/product_service_pact_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def test_receive_a_product_update(pact, consumer):
pact
.expects_to_receive("a product event update")
.with_content(event)
.with_metadata({"Content-Type": "application/json", 'topic': 'products'})
.with_metadata({"contentType": "application/json", 'topic': 'products'})
)

with pact:
Expand Down

0 comments on commit b7cf768

Please sign in to comment.