cclauss / GitHub-Action-for-pytest

A GitHub Action to run a pytest command when new code is pushed into your repo
Apache License 2.0
55 stars 24 forks source link

Requests to API endpoint fail only inside github action #2

Open meetbryce opened 4 years ago

meetbryce commented 4 years ago

Have a very simple test that fails in github actions with a connection timeout.

Can't find anything about how to debug the issue, so resorting to posting an issue here.

def test_pulse_returns_200():
    r = requests.get("http://localhost:5000/pulse")
    assert r.status_code == 200

Error logs attached. 6_Test with pytest.txt

cclauss commented 4 years ago

Run https://github.com/cclauss/Ten-lines-or-less/blob/master/platform_info.py on you own computer and again inside a GitHub Action. Comparing the output, you will see that the GitHub action is not running on your local machine. So unless you have turned on a server process within that GitHub Action, there will be nothing listening on http://localhost:5000. If your GitHub Action has set up such a server process, be aware the GitHub may limit that container’s ability to receive or send external traffic.

Your code can detect if it is running inside a GitHub Action by looking for any of https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables