Skip to content

Commit 045083b

Browse files
committed
chore(ci): split tests examples and lints
Try splitting the CI workflow to make use of services Signed-off-by: JP-Ellis <josh@jpellis.me>
1 parent 3a59235 commit 045083b

File tree

1 file changed

+73
-11
lines changed

1 file changed

+73
-11
lines changed

.github/workflows/test.yml

Lines changed: 73 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ concurrency:
1414

1515
env:
1616
STABLE_PYTHON_VERSION: "3.11"
17+
PYTEST_ADDOPTS: --color=yes
1718

1819
jobs:
19-
run:
20+
test:
2021
name: >-
21-
Python ${{ matrix.python-version }}
22-
on ${{ matrix.os }}
22+
Tests py${{ matrix.python-version }} on ${{ matrix.os }}
2323
2424
runs-on: ${{ matrix.os }}
2525
continue-on-error: ${{ matrix.experimental }}
@@ -47,14 +47,76 @@ jobs:
4747
- name: Install Hatch
4848
run: pip install --upgrade hatch
4949

50-
- # TODO: Fix lints before enabling this
51-
name: Lint
52-
if: matrix.python-version == env.STABLE_PYTHON_VERSION && runner.os == 'Linux'
53-
run: echo hatch run lint
50+
- name: Run tests
51+
run: hatch run test
52+
53+
- name: Upload coverage
54+
# TODO: Configure code coverage monitoring
55+
if: false && matrix.python-version == env.STABLE_PYTHON_VERSION && matrix.os == 'ubuntu-latest'
56+
uses: codecov/codecov-action@v2
57+
with:
58+
token: ${{ secrets.CODECOV_TOKEN }}
59+
60+
example:
61+
name: Example
62+
63+
runs-on: ubuntu-latest
64+
services:
65+
broker:
66+
image: pactfoundation/pact-broker:latest
67+
ports:
68+
- "9292:9292"
69+
env:
70+
# Basic auth credentials for the Broker
71+
PACT_BROKER_ALLOW_PUBLIC_READ: "true"
72+
PACT_BROKER_BASIC_AUTH_USERNAME: pactbroker
73+
PACT_BROKER_BASIC_AUTH_PASSWORD: pactbroker
74+
# Database
75+
PACT_BROKER_DATABASE_URL: sqlite:////tmp/pact_broker.sqlite
76+
77+
steps:
78+
- uses: actions/checkout@v4
79+
80+
- name: Set up Python 3
81+
uses: actions/setup-python@v4
82+
with:
83+
python-version: ${{ env.STABLE_PYTHON_VERSION }}
84+
85+
- name: Install Hatch
86+
run: pip install --upgrade hatch
87+
88+
- name: Ensure broker is live
89+
run: |
90+
i=0
91+
until curl -sSf http://localhost:9292/diagnostic/status/heartbeat; do
92+
i=$((i+1))
93+
if [ $i -gt 120 ]; then
94+
echo "Broker failed to start"
95+
exit 1
96+
fi
97+
sleep 1
98+
done
5499
55100
- name: Examples
56-
if: matrix.python-version == env.STABLE_PYTHON_VERSION && runner.os == 'Linux'
57-
run: hatch run example --color=yes --capture=no
101+
run: >
102+
hatch run example --broker-url=http://pactbroker:pactbroker@localhost:9292
58103
59-
- name: Run tests and track code coverage
60-
run: hatch run test
104+
# TODO: Fix lints before enabling this
105+
# lint:
106+
# name: Lint
107+
108+
# runs-on: ubuntu-latest
109+
110+
# steps:
111+
# - uses: actions/checkout@v4
112+
113+
# - name: Set up Python
114+
# uses: actions/setup-python@v4
115+
# with:
116+
# python-version: ${{ env.STABLE_PYTHON_VERSION }}
117+
118+
# - name: Install Hatch
119+
# run: pip install --upgrade hatch
120+
121+
# - name: Lint
122+
# run: hatch run lint

0 commit comments

Comments
 (0)