From cac28c0de4a33f017e76901e26ce2b7835c3776e Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Thu, 21 Sep 2023 12:46:44 +1000 Subject: [PATCH] chore(ci): split tests examples and lints Try splitting the CI workflow to make use of services Signed-off-by: JP-Ellis --- .github/workflows/test.yml | 72 ++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ea1ae8d5c..01a467fef 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 }} @@ -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