Skip to content

Commit d58f124

Browse files
committed
Fix testContainer setup on CI
1 parent 0a1460d commit d58f124

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ jobs:
3131

3232
- name: Run pip install
3333
run: pip install -r requirements.txt
34-
3534
- name: Run contract as tests with Specmatic Python Extensions
36-
# run: coverage run --branch -m pytest test -v -s --junitxml contract-test-reports/TEST-junit-jupiter.xml
37-
run: coverage run --branch -m pytest test/test_contract_with_coverage.py -v -s --junitxml contract-test-reports/TEST-junit-jupiter.xml
35+
run: coverage run --branch -m pytest test -v -s --junitxml contract-test-reports/TEST-junit-jupiter.xml
36+
env:
37+
TESTCONTAINERS_RYUK_DISABLED: ${{ runner.os == 'Windows' && 'true' || 'false' }}
3838

3939
- name: Save Specmatic license
4040
if: false

test/test_contract_using_test_container.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from api import app, database
1010

11-
APPLICATION_HOST = "host.docker.internal"
11+
APPLICATION_HOST = "0.0.0.0"
1212
APPLICATION_PORT = 5001
1313
HTTP_STUB_PORT = 8080
1414

@@ -28,7 +28,7 @@ def _stream():
2828
@pytest.fixture(scope="module")
2929
def api_service():
3030
database.reset()
31-
server = make_server("0.0.0.0", APPLICATION_PORT, app)
31+
server = make_server(APPLICATION_HOST, APPLICATION_PORT, app)
3232
thread = threading.Thread(target=server.serve_forever)
3333
thread.start()
3434
yield
@@ -42,10 +42,11 @@ def test_container():
4242
build_reports_path = Path("build/reports/specmatic").resolve()
4343
container = (
4444
DockerContainer("specmatic/specmatic")
45-
.with_command(["test", f"--host={APPLICATION_HOST}", f"--port={APPLICATION_PORT}"])
45+
.with_command(["test", "--host=host.docker.internal", f"--port={APPLICATION_PORT}"])
4646
.with_env("SPECMATIC_GENERATIVE_TESTS", "true")
4747
.with_volume_mapping(specmatic_yaml_path, "/usr/src/app/specmatic.yaml", mode="ro")
4848
.with_volume_mapping(build_reports_path, "/usr/src/app/build/reports/specmatic", mode="rw")
49+
.with_kwargs(extra_hosts={"host.docker.internal": "host-gateway"})
4950
.waiting_for(LogMessageWaitStrategy("Tests run:"))
5051
)
5152
container.start()

0 commit comments

Comments
 (0)