Skip to content

Commit 37d695f

Browse files
authored
Deps/docker updates inc ref verifier (#8)
* chore(deps): update app deps + native verifier * chore: update docker-compose to docker compose (v2 deprecation) * ci: only run one verifier at a time
1 parent cf1e78d commit 37d695f

File tree

6 files changed

+77
-21
lines changed

6 files changed

+77
-21
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,18 @@ jobs:
1717
test:
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v3
21-
- uses: actions/setup-python@v3
22-
with:
23-
python-version: '3.8'
24-
architecture: 'x64'
25-
- run: pip install -r requirements.txt
26-
- name: Test
20+
- uses: actions/checkout@v4
21+
- name: Test (ruby standalone - docker)
2722
run: GIT_BRANCH=${GITHUB_REF:11} make test
23+
- name: Test (native standalone - docker)
24+
run: GIT_BRANCH=${GITHUB_REF:11} make test_native
2825

2926
# Runs on branches as well, so we know the status of our PRs
3027
can-i-deploy:
3128
runs-on: ubuntu-latest
3229
needs: test
3330
steps:
34-
- uses: actions/checkout@v2
31+
- uses: actions/checkout@v4
3532
- run: docker pull pactfoundation/pact-cli:latest
3633
- name: Can I deploy?
3734
run: GIT_BRANCH=${GITHUB_REF:11} make can_i_deploy
@@ -41,7 +38,7 @@ jobs:
4138
runs-on: ubuntu-latest
4239
needs: can-i-deploy
4340
steps:
44-
- uses: actions/checkout@v2
41+
- uses: actions/checkout@v4
4542
- run: docker pull pactfoundation/pact-cli:latest
4643
- name: Deploy
4744
run: GIT_BRANCH=${GITHUB_REF:11} make deploy

.github/workflows/verify_changed_pact.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ jobs:
1717
verify-changed-pact:
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v3
21-
- uses: actions/setup-python@v3
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-python@v5
2222
with:
2323
python-version: '3.8'
2424
architecture: 'x64'

Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM python:3.11
2+
3+
WORKDIR /code
4+
5+
COPY ./requirements.txt /code/requirements.txt
6+
7+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8+
9+
COPY ./app /code/app
10+
11+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

Makefile

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ fake_ci_webhook:
4242
## =====================
4343

4444
test: .env
45-
docker-compose up --abort-on-container-exit --exit-code-from pact_verifier
46-
docker-compose logs pact_verifier
45+
docker compose up pact_verifier --exit-code-from pact_verifier
46+
docker compose logs pact_verifier
47+
test_native: .env
48+
docker compose up pact_verifier_native --exit-code-from pact_verifier_native
49+
docker compose logs pact_verifier_native
4750

4851
## =====================
4952
## Deploy tasks
@@ -108,6 +111,31 @@ test_pact_changed_webhook:
108111
## ======================
109112
## Misc
110113
## ======================
111-
114+
PROJECT := example-provider-python
115+
PYTHON_MAJOR_VERSION := 3.11
116+
sgr0 := $(shell tput sgr0)
117+
red := $(shell tput setaf 1)
118+
green := $(shell tput setaf 2)
112119
.env:
113120
touch .env
121+
122+
123+
venv:
124+
@if [ -d "./.venv" ]; then echo "$(red).venv already exists, not continuing!$(sgr0)"; exit 1; fi
125+
@type pyenv >/dev/null 2>&1 || (echo "$(red)pyenv not found$(sgr0)"; exit 1)
126+
127+
@echo "\n$(green)Try to find the most recent minor version of the major version specified$(sgr0)"
128+
$(eval PYENV_VERSION=$(shell pyenv install -l | grep "\s\s$(PYTHON_MAJOR_VERSION)\.*" | tail -1 | xargs))
129+
@echo "$(PYTHON_MAJOR_VERSION) -> $(PYENV_VERSION)"
130+
131+
@echo "\n$(green)Install the Python pyenv version if not already available$(sgr0)"
132+
pyenv install $(PYENV_VERSION) -s
133+
134+
@echo "\n$(green)Make a .venv dir$(sgr0)"
135+
~/.pyenv/versions/${PYENV_VERSION}/bin/python3 -m venv ${CURDIR}/.venv
136+
137+
@echo "\n$(green)Make it 'available' to pyenv$(sgr0)"
138+
ln -sf ${CURDIR}/.venv ~/.pyenv/versions/${PROJECT}
139+
140+
@echo "\n$(green)Use it! (populate .python-version)$(sgr0)"
141+
pyenv local ${PROJECT}

docker-compose.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
version: "3"
2-
31
services:
42
api:
5-
image: tiangolo/uvicorn-gunicorn-fastapi:python3.7
3+
build:
4+
context: .
65
volumes:
76
- ./app:/app
87
expose:
@@ -29,5 +28,26 @@ services:
2928
--provider-base-url http://api:8000
3029
--provider pactflow-example-provider-python
3130
--provider-app-version ${GIT_COMMIT}
32-
--provider-version-tag ${GIT_BRANCH}
33-
--wait 10
31+
--provider-version-branch ${GIT_BRANCH}
32+
--wait 10
33+
34+
pact_verifier_native:
35+
image: pactfoundation/pact-ref-verifier:latest
36+
depends_on:
37+
- api
38+
environment:
39+
- PACT_BROKER_BASE_URL
40+
- PACT_BROKER_TOKEN
41+
- PACT_BROKER_USERNAME
42+
- PACT_BROKER_PASSWORD
43+
- PACT_BROKER_PUBLISH_VERIFICATION_RESULTS
44+
# - PACT_WEBHOOK_CALLBACK_URL=${PACT_URL}
45+
- GIT_COMMIT
46+
- GIT_BRANCH
47+
command: >
48+
--hostname api
49+
--port 8000
50+
--provider-name pactflow-example-provider-python
51+
--loglevel info
52+
--provider-version $GIT_COMMIT
53+
--provider-branch $GIT_BRANCH

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
fastapi==0.61.1
2-
uvicorn==0.11.8
1+
fastapi==0.115.5
2+
uvicorn==0.32.0

0 commit comments

Comments
 (0)