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 aab5563 commit 4e825ea
Showing 1 changed file with 65 additions and 7 deletions.
72 changes: 65 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,27 @@ env:
STABLE_PYTHON_VERSION: "3.11"

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 +67,52 @@ 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:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
broker:
image: pactfoundation/pact-broker:latest-multi
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_ADAPTER: postgres
PACT_BROKER_DATABASE_URL: "postgres://postgres:postgres@postgres/postgres"

steps:
- name: Check broker is live
run: |
curl -sSf https://broker:9292 || 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
--color=yes
--capture=no
--broker-url=http://pactbroker:pactbroker@broker:9292
- name: Run tests and track code coverage
run: hatch run test

0 comments on commit 4e825ea

Please sign in to comment.