Skip to content

Deps/docker updates inc ref verifier #8

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 6 commits into from
Nov 13, 2024
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
15 changes: 6 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,18 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: '3.8'
architecture: 'x64'
- run: pip install -r requirements.txt
- name: Test
- uses: actions/checkout@v4
- name: Test (ruby standalone - docker)
run: GIT_BRANCH=${GITHUB_REF:11} make test
- name: Test (native standalone - docker)
run: GIT_BRANCH=${GITHUB_REF:11} make test_native

# Runs on branches as well, so we know the status of our PRs
can-i-deploy:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: docker pull pactfoundation/pact-cli:latest
- name: Can I deploy?
run: GIT_BRANCH=${GITHUB_REF:11} make can_i_deploy
Expand All @@ -41,7 +38,7 @@ jobs:
runs-on: ubuntu-latest
needs: can-i-deploy
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- run: docker pull pactfoundation/pact-cli:latest
- name: Deploy
run: GIT_BRANCH=${GITHUB_REF:11} make deploy
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/verify_changed_pact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
verify-changed-pact:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.8'
architecture: 'x64'
Expand Down
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.11

WORKDIR /code

COPY ./requirements.txt /code/requirements.txt

RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

COPY ./app /code/app

CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
34 changes: 31 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ fake_ci_webhook:
## =====================

test: .env
docker-compose up --abort-on-container-exit --exit-code-from pact_verifier
docker-compose logs pact_verifier
docker compose up pact_verifier --exit-code-from pact_verifier
docker compose logs pact_verifier
test_native: .env
docker compose up pact_verifier_native --exit-code-from pact_verifier_native
docker compose logs pact_verifier_native

## =====================
## Deploy tasks
Expand Down Expand Up @@ -108,6 +111,31 @@ test_pact_changed_webhook:
## ======================
## Misc
## ======================

PROJECT := example-provider-python
PYTHON_MAJOR_VERSION := 3.11
sgr0 := $(shell tput sgr0)
red := $(shell tput setaf 1)
green := $(shell tput setaf 2)
.env:
touch .env


venv:
@if [ -d "./.venv" ]; then echo "$(red).venv already exists, not continuing!$(sgr0)"; exit 1; fi
@type pyenv >/dev/null 2>&1 || (echo "$(red)pyenv not found$(sgr0)"; exit 1)

@echo "\n$(green)Try to find the most recent minor version of the major version specified$(sgr0)"
$(eval PYENV_VERSION=$(shell pyenv install -l | grep "\s\s$(PYTHON_MAJOR_VERSION)\.*" | tail -1 | xargs))
@echo "$(PYTHON_MAJOR_VERSION) -> $(PYENV_VERSION)"

@echo "\n$(green)Install the Python pyenv version if not already available$(sgr0)"
pyenv install $(PYENV_VERSION) -s

@echo "\n$(green)Make a .venv dir$(sgr0)"
~/.pyenv/versions/${PYENV_VERSION}/bin/python3 -m venv ${CURDIR}/.venv

@echo "\n$(green)Make it 'available' to pyenv$(sgr0)"
ln -sf ${CURDIR}/.venv ~/.pyenv/versions/${PROJECT}

@echo "\n$(green)Use it! (populate .python-version)$(sgr0)"
pyenv local ${PROJECT}
30 changes: 25 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
version: "3"

services:
api:
image: tiangolo/uvicorn-gunicorn-fastapi:python3.7
build:
context: .
volumes:
- ./app:/app
expose:
Expand All @@ -29,5 +28,26 @@ services:
--provider-base-url http://api:8000
--provider pactflow-example-provider-python
--provider-app-version ${GIT_COMMIT}
--provider-version-tag ${GIT_BRANCH}
--wait 10
--provider-version-branch ${GIT_BRANCH}
--wait 10

pact_verifier_native:
image: pactfoundation/pact-ref-verifier:latest
depends_on:
- api
environment:
- PACT_BROKER_BASE_URL
- PACT_BROKER_TOKEN
- PACT_BROKER_USERNAME
- PACT_BROKER_PASSWORD
- PACT_BROKER_PUBLISH_VERIFICATION_RESULTS
# - PACT_WEBHOOK_CALLBACK_URL=${PACT_URL}
- GIT_COMMIT
- GIT_BRANCH
command: >
--hostname api
--port 8000
--provider-name pactflow-example-provider-python
--loglevel info
--provider-version $GIT_COMMIT
--provider-branch $GIT_BRANCH
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
fastapi==0.61.1
uvicorn==0.11.8
fastapi==0.115.5
uvicorn==0.32.0