Skip to content

Commit b7cf768

Browse files
authored
Merge pull request #7 from pactflow/deps/pact_v2_python_3_11
Deps/pact v2 python 3 11
2 parents cb43883 + 0577116 commit b7cf768

File tree

7 files changed

+866
-389
lines changed

7 files changed

+866
-389
lines changed

.env

Whitespace-only changes.

.github/workflows/build.yml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,10 @@ jobs:
1414
test:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v4
1818
- uses: actions/setup-python@v4
1919
with:
20-
python-version: "3.8"
21-
# - name: Install python version
22-
# uses: gabrielfalcao/pyenv-action@v10
23-
# with:
24-
# default: 3.8.13
25-
# command: pip install -U pip # upgrade pip after installing python
26-
# - name: Create virtualenv for python 3.5.7
27-
# run: pyenv local 3.8.13 && python3 -mvenv .venv
28-
# - name: venv
29-
# run: pyenv local 3.8.13 && python3 -mvenv .venv3813
20+
python-version: "3.11"
3021
- name: install pyenv
3122
run: curl https://pyenv.run | bash
3223
- name: set pyenv on path
@@ -43,12 +34,10 @@ jobs:
4334
run: make venv
4435
- name: Install
4536
run: make deps
46-
- name: Activate virtual env
37+
- name: Activate virtual env & test
4738
run: |
4839
source .venv/bin/activate
4940
make test
50-
# - name: Test
51-
# run: make test
5241
- name: Publish pacts
5342
run: GIT_BRANCH=${GIT_REF:11} make publish_pacts
5443

Makefile

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,21 @@ ci: test publish_pacts can_i_deploy $(DEPLOY_TARGET)
2222
# Run the ci target from a developer machine with the environment variables
2323
# set as if it was on Travis CI.
2424
# Use this for quick feedback when playing around with your workflows.
25-
fake_ci: .env
25+
fake_ci:
2626
CI=true \
2727
GIT_COMMIT=`git rev-parse --short HEAD`+`date +%s` \
2828
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` \
2929
make ci
3030

3131

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

3535
## =====================
3636
## Build/test tasks
3737
## =====================
3838

39-
test: .env
39+
test:
4040
python3 -m pytest
4141

4242
## =====================
@@ -51,18 +51,18 @@ deploy: deploy_app record_deployment
5151
no_deploy:
5252
@echo "Not deploying as not on main branch"
5353

54-
can_i_deploy: .env
54+
can_i_deploy:
5555
@"${PACT_CLI}" broker can-i-deploy \
5656
--pacticipant ${PACTICIPANT} \
5757
--version ${GIT_COMMIT} \
5858
--to-environment production \
59-
--retry-while-unknown 0 \
59+
--retry-while-unknown 5 \
6060
--retry-interval 10
6161

6262
deploy_app:
6363
@echo "Deploying to production"
6464

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

6868
## =====================
@@ -101,16 +101,13 @@ test_github_webhook:
101101
## Misc
102102
## ======================
103103

104-
.env:
105-
touch .env
106-
107104
.PHONY: test
108105

109106
## ======================
110107
## Python additions
111108
## ======================
112109
PROJECT := example-consumer-python-sns
113-
PYTHON_MAJOR_VERSION := 3.8
110+
PYTHON_MAJOR_VERSION := 3.11
114111

115112
sgr0 := $(shell tput sgr0)
116113
red := $(shell tput setaf 1)

poetry.lock

Lines changed: 849 additions & 358 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ requires = ["poetry-core>=1.0.0"]
1313
build-backend = "poetry.core.masonry.api"
1414

1515
[tool.poetry.dependencies]
16-
python = "^3.8"
16+
python = "^3.11"
1717

1818
[tool.poetry.dev-dependencies]
19-
pytest = "7.1.2"
20-
pytest-asyncio = "^0.18.3"
21-
pytest-mock = "^3.7.0"
22-
pact-python = "^1.5.2"
19+
pytest = "8.3.3"
20+
pytest-asyncio = "^0.24.0"
21+
pytest-mock = "^3.14.0"
22+
pact-python = "^2.2.2"

template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Resources:
2626
Type: AWS::Serverless::Function
2727
Properties:
2828
Description: A Lambda function that receives a Product update event from the ProductEvent topic
29-
Runtime: python3.8
29+
Runtime: python3.11
3030
Handler: src.lambda.product.handler
3131
# This property associates this Lambda function with the SNS topic defined above, so that whenever the topic
3232
# receives a message, the Lambda function is invoked

tests/unit/product_service_pact_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async def test_receive_a_product_update(pact, consumer):
3737
pact
3838
.expects_to_receive("a product event update")
3939
.with_content(event)
40-
.with_metadata({"Content-Type": "application/json", 'topic': 'products'})
40+
.with_metadata({"contentType": "application/json", 'topic': 'products'})
4141
)
4242

4343
with pact:

0 commit comments

Comments
 (0)