Skip to content

Commit

Permalink
chore(ci): split tests examples and lints
Browse files Browse the repository at this point in the history
Try splitting the CI workflow to make use of services

Signed-off-by: JP-Ellis <josh@jpellis.me>
  • Loading branch information
JP-Ellis committed Sep 21, 2023
1 parent d14f8a6 commit cac28c0
Showing 1 changed file with 65 additions and 7 deletions.
72 changes: 65 additions & 7 deletions .github/workflows/test.yml
Expand Up @@ -14,9 +14,30 @@ concurrency:

env:
STABLE_PYTHON_VERSION: "3.11"
PYTEST_ADDOPTS: --color=yes

jobs:
run:
lint:
name: Lint

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3

- name: Install Hatch
run: pip install --upgrade hatch

- # TODO: Fix lints before enabling this
name: Lint
run: echo hatch run lint

test:
name: >-
Python ${{ matrix.python-version }}
on ${{ matrix.os }}
Expand Down Expand Up @@ -47,14 +68,51 @@ jobs:
- name: Install Hatch
run: pip install --upgrade hatch

- # TODO: Fix lints before enabling this
name: Lint
if: matrix.python-version == env.STABLE_PYTHON_VERSION && runner.os == 'Linux'
run: echo hatch run lint
- name: Run tests and track code coverage
run: hatch run test

example:
name: Example

runs-on: ubuntu-latest
services:
broker:
image: pactfoundation/pact-broker:latest
ports:
- "9292:9292"
env:
# Basic auth credentials for the Broker
PACT_BROKER_ALLOW_PUBLIC_READ: "true"
PACT_BROKER_BASIC_AUTH_USERNAME: pactbroker
PACT_BROKER_BASIC_AUTH_PASSWORD: pactbroker
# Database
PACT_BROKER_DATABASE_URL: sqlite:////tmp/pact_broker.sqlite
options: >-
--health-cmd "curl -sSf http://pactbroker:pactbroker@localhost:9292/diagnostic/status/heartbeat"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Check broker is live
run: |
curl -sSf http://pactbroker:pactbroker@localhost:9292/diagnostic/status/heartbeat || exit 1
- uses: actions/checkout@v4

- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: 3

- name: Install Hatch
run: pip install --upgrade hatch

- name: Examples
if: matrix.python-version == env.STABLE_PYTHON_VERSION && runner.os == 'Linux'
run: hatch run example --color=yes --capture=no
run: >
hatch run example
--capture=no
--broker-url=http://pactbroker:pactbroker@broker:9292
- name: Run tests and track code coverage
run: hatch run test

0 comments on commit cac28c0

Please sign in to comment.