Skip to content

Commit

Permalink
Automatically test new python versions (#379)
Browse files Browse the repository at this point in the history
Every night this will check all the supported versions of python on github actions, and file
a PR to expand our test coverage if new versions of python are released.

(Note that this PR purposefully removes an old version of python for testing, this should get
automatically re-added when this first runs).
  • Loading branch information
benfred authored Apr 26, 2021
1 parent a1b1121 commit fd629e9
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [2.7.17, 2.7.18, 3.5.4, 3.5.9, 3.5.10, 3.6.7, 3.6.8, 3.6.9, 3.6.10, 3.6.11, 3.6.12, 3.6.13, 3.7.1, 3.7.5, 3.7.6, 3.7.7, 3.7.8, 3.7.9, 3.7.10, 3.8.0, 3.8.1, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.9.0, 3.9.1, 3.9.2, 3.9.3, 3.9.4]
python-version: [2.7.18, 3.5.4, 3.5.9, 3.5.10, 3.6.7, 3.6.8, 3.6.9, 3.6.10, 3.6.11, 3.6.12, 3.6.13, 3.7.1, 3.7.5, 3.7.6, 3.7.7, 3.7.8, 3.7.9, 3.7.10, 3.8.0, 3.8.1, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.9.0, 3.9.1, 3.9.2, 3.9.3, 3.9.4]
# TODO: also test windows
os: [ubuntu-latest, macos-latest]
steps:
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/update_python_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Update Dependencies
on:
schedule:
- cron: '0 1 * * 1'
jobs:
update-dep:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install
run: pip install --upgrade requests
- name: Scan for new python versions
run: python ci/update_python_test_versions.py
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
commit-message: Update tested python versions
title: Update tested python versions
branch: update-python-versons
10 changes: 7 additions & 3 deletions ci/update_python_test_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def get_github_python_versions():
raw_versions = [v["version"] for v in versions_json]
versions = []
for version_str in raw_versions:
if '-' in version_str:
if "-" in version_str:
continue

v = pkg_resources.parse_version(version_str)
Expand All @@ -28,8 +28,12 @@ def get_github_python_versions():


if __name__ == "__main__":
versions = sorted(get_github_python_versions(), key = lambda x: pkg_resources.parse_version(x))
build_yml = pathlib.Path(__file__).parent.parent / ".github" / "workflows" / "build.yml"
versions = sorted(
get_github_python_versions(), key=lambda x: pkg_resources.parse_version(x)
)
build_yml = (
pathlib.Path(__file__).parent.parent / ".github" / "workflows" / "build.yml"
)

transformed = []
for line in open(build_yml):
Expand Down
7 changes: 4 additions & 3 deletions tests/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@

class TestPyspy(unittest.TestCase):
""" Basic tests of using py-spy as a commandline application """

def _sample_process(self, script_name, options=None):
pyspy = find_executable("py-spy")
print("Testing py-spy @", pyspy)

# for permissions reasons, we really want to run the sampled python process as a
# subprocess of the py-spy (works best on linux etc). So we're running the
# subprocess of the py-spy (works best on linux etc). So we're running the
# record option, and setting different flags. To get the profile output
# we're using the speedscope format (since we can read that in as json)
with tempfile.NamedTemporaryFile() as profile_file:
Expand All @@ -42,7 +43,7 @@ def _sample_process(self, script_name, options=None):
subprocess.check_call(cmdline)
with open(profile_file.name) as f:
profiles = json.load(f)

frames = profiles["shared"]["frames"]
samples = defaultdict(int)
for p in profiles["profiles"]:
Expand Down Expand Up @@ -72,7 +73,6 @@ def test_busyloop(self):
assert sum(profile.values()) >= 95



def _get_script(name):
base_dir = os.path.dirname(__file__)
return os.path.join(base_dir, "scripts", name)
Expand All @@ -81,5 +81,6 @@ def _get_script(name):
def _most_frequent_sample(samples):
return max(samples.items(), key=lambda x: x[1])


if __name__ == "__main__":
unittest.main()

0 comments on commit fd629e9

Please sign in to comment.