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 <[email protected]>
  • Loading branch information
JP-Ellis committed Sep 21, 2023
1 parent aab5563 commit fddd4a0
Showing 1 changed file with 77 additions and 7 deletions.
84 changes: 77 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,64 @@ 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
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
broker:
image: pactfoundation/pact-broker:latest-multi
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_ADAPTER: postgres
PACT_BROKER_DATABASE_URL: "postgres://postgres:postgres@postgres/postgres"
options: >-
--health-cmd curl -sSf http://pactbroker:pactbroker@localhost:9292/diagnostic/status/heartbeat || exit 1
--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
--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 fddd4a0

Please sign in to comment.