Skip to content

Bump factory-boy from 3.3.0 to 3.3.1 #647

Bump factory-boy from 3.3.0 to 3.3.1

Bump factory-boy from 3.3.0 to 3.3.1 #647

# This file is part of the Provider API Example.
#
# Copyright (C) 2023 Serghei Iakovlev <[email protected]>
#
# For the full copyright and license information, please view
# the LICENSE file that was distributed with this source code.
name: Contract Tests
on:
# Run this workflow only on PR to main branch
pull_request:
paths-ignore: [ '**.rst' ]
branches: [ main ]
# This will make it possible to make an API call from the consumer's workflow
repository_dispatch:
types: [ pacts_changed ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
explicit_branch:
description: Branch in consumer repository
required: true
type: string
default: main
jobs:
contract-tests:
name: Contract Tests
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Detect current Git branch
id: current-branch
run: |
# This condition allows to use the branch the user has explicitly
# chosen using 'workflow_dispatch'
if [ "${{ github.event.inputs.explicit_branch }}" != "" ]; then
ref="${{ github.event.inputs.explicit_branch }}"
else
# Otherwise, define the necessary branch taking into
# account 'repository_dispatch'
if [ "${{ github.head_ref }}" != "" ]; then
ref="${{ github.head_ref }}"
else
ref="${{ github.ref }}"
fi
fi
# Cleanup branch name from 'refs/heads/' prefix
prefix="refs/heads/"
branch=${ref#"$prefix"}
# Store in the output for future use
echo "ref=$branch" >> $GITHUB_OUTPUT
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Setup Python cache
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Set up virtualenv
run: |
make init
source .venv/bin/activate
echo "$(pwd)/.venv/bin" >> $GITHUB_PATH
- name: Install dependencies
run: make install
# In real life, next steps (all with `id: consumer-*`) are not necessary,
# at least at the stage of testing the provider. Usually, when you test a
# provider, you get contracts (pacts) from a broker that would be
# self-hosted or using PactFlow. However, in this, a simplified example,
# we do not have a deployed broker, so we deploy it ourselves, right now.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BROKER START ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
- name: 'Checkout ${{ steps.current-branch.outputs.ref }} consumer brach'
id: consumer-checkout
uses: actions/checkout@v4
continue-on-error: true
with:
repository: sergeyklay/consumer-pact-example
path: consumer-pact-example
ref: ${{ steps.current-branch.outputs.ref }}
# Clone default branch, if the previous step failed.
- name: Checkout default consumer brach
id: consumer-checkout-default
uses: actions/checkout@v4
if: ${{ steps.consumer-checkout.outcome == 'failure' }}
with:
repository: sergeyklay/consumer-pact-example
path: consumer-pact-example
- name: Start broker
id: consumer-broker
run: docker compose up -d --quiet-pull --no-color
working-directory: consumer-pact-example
- name: Print docker logs
id: consumer-broker-logs
if: failure()
run: docker compose logs
working-directory: consumer-pact-example
- name: Publish consumer's pacts to broker
id: consumer-publish-pacts
run: ./publish-contracts.sh
working-directory: consumer-pact-example
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BROKER END ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
- name: Download pact_verifier_cli
run: |
repo=https://github.com/pact-foundation/pact-reference
release=pact_verifier_cli-v0.10.4
file=pact_verifier_cli-linux-x86_64
archive="${file}.gz"
curl -o "${archive}" -sSL "${repo}/releases/download/${release}/${archive}"
gzip -dv "${archive}"
mkdir -p "${HOME}/.local/bin"
mv "${file}" "${HOME}/.local/bin/pact_verifier_cli"
chmod +x "${HOME}/.local/bin/pact_verifier_cli"
echo "${HOME}/.local/bin" >> $GITHUB_PATH
- name: Verify contracts
run: ./verify-contracts.sh