Skip to content

Commit e22830c

Browse files
Replace the CI workflow with the speed.python.org one
Also, fix flake8 warnings.
1 parent 1c29c58 commit e22830c

9 files changed

Lines changed: 68 additions & 46 deletions

File tree

‎.github/workflows/test.yml‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [speed.pypy.org]
6+
pull_request:
7+
branches: [speed.pypy.org]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
lint:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
17+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
18+
with:
19+
python-version: "3.13"
20+
- run: pip install -r requirements-dev.txt
21+
- run: flake8 codespeed
22+
23+
test:
24+
runs-on: ubuntu-latest
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
python-version: ["3.12", "3.13", "3.14"]
29+
django: ["5.2", "6.1"]
30+
name: Python ${{ matrix.python-version }} / Django ${{ matrix.django }}
31+
env:
32+
DJANGO_SETTINGS_MODULE: codespeed.tests.settings
33+
34+
steps:
35+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
36+
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
37+
with:
38+
python-version: ${{ matrix.python-version }}
39+
# codespeed/tests/test_commits.py drives a real Mercurial repository, and
40+
# hg is no longer preinstalled on the ubuntu-latest runner image. This
41+
# step is the only difference from the speed.python.org workflow; drop
42+
# it together with that test if the Mercurial backend stops being tested.
43+
- run: |
44+
sudo apt-get update
45+
sudo apt-get install -y --no-install-recommends mercurial
46+
hg --version
47+
- run: pip install -r requirements.txt "django==${{ matrix.django }}.*"
48+
- run: python manage.py test codespeed

‎.github/workflows/tests.yml‎

Lines changed: 0 additions & 30 deletions
This file was deleted.

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Codespeed
2-
[![Build Status](https://travis-ci.org/tobami/codespeed.png?branch=master)](https://travis-ci.org/tobami/codespeed)
2+
[![Tests](https://github.com/python/codespeed/actions/workflows/test.yml/badge.svg?branch=speed.pypy.org)](https://github.com/python/codespeed/actions/workflows/test.yml)
33
[![PyPI version](https://img.shields.io/pypi/v/codespeed.svg)](https://pypi.python.org/pypi/codespeed)
44

55
Codespeed is a web application to monitor and analyze the performance of your code.

‎codespeed/commits/git.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def getlogs(endrev, startrev):
6767
p, stdout, stderr = execute_command(cmd, working_copy)
6868

6969
if p.returncode != 0:
70-
raise CommitLogError(f"'%s' in '%s' returned %s: %s" % (
70+
raise CommitLogError("'%s' in '%s' returned %s: %s" % (
7171
" ".join(cmd), working_copy, p.returncode, stderr))
7272
logs = []
7373
for log in filter(None, stdout.split('\x1e')):

‎codespeed/results.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def save_result(data, update_repo=True):
6868
if error:
6969
return res, True
7070
else:
71-
assert(isinstance(res, Environment))
71+
assert isinstance(res, Environment)
7272
env = res
7373

7474
p, created = Project.objects.get_or_create(name=data["project"])

‎codespeed/tests/test_commits.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
import tempfile
55
import os
66

7-
from django.test import TestCase, override_settings
7+
from django.test import TestCase
88
from django.urls import reverse
99

1010
from codespeed.models import (Project, Benchmark, Revision, Branch, Executable,
11-
Environment, Result, Report)
11+
Environment)
1212

1313
hgdir = ''
1414

1515
# hg aborts on commit when ui.username is unset, which is the case on a CI
1616
# runner with no ~/.hgrc, so supply one explicitly.
1717
HG_USER = ['-u', 'Codespeed Tests <tests@example.com>']
1818

19+
1920
def setUpModule():
2021
global hgdir
2122
hgdir = tempfile.TemporaryDirectory()
@@ -34,9 +35,11 @@ def setUpModule():
3435
subprocess.check_call(['hg', 'commit', '-m', "second commit"] + HG_USER,
3536
cwd=hgdir.name)
3637

38+
3739
def tearDownModule():
3840
hgdir.cleanup()
3941

42+
4043
class TestMercurial(TestCase):
4144

4245
def setUp(self):
@@ -65,5 +68,5 @@ def setUp(self):
6568

6669
def test_hg(self):
6770
with self.settings(REPOSITORY_BASE_PATH=os.path.dirname(self.hgdir)):
68-
response = self.client.get(reverse('displaylogs'), {'revisionid':1})
71+
response = self.client.get(reverse('displaylogs'), {'revisionid': 1})
6972
assert response.status_code == 200, 'expected 200 got %d' % response.status_code

‎codespeed/tests/test_models.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,17 @@ def test_github_browsing_url(self):
287287
# It should work with https:// as well as git:// urls
288288
self.github_project.save()
289289
self.assertEqual(self.github_project.commit_browsing_url,
290-
'https://github.com/tobami/codespeed.git/'
291-
'commit/{commitid}')
290+
'https://github.com/tobami/codespeed.git/'
291+
'commit/{commitid}')
292292

293293
self.github_project.repo_path = 'git://github.com/tobami/codespeed.git'
294294
self.github_project.save()
295295
self.assertEqual(self.github_project.commit_browsing_url,
296-
'https://github.com/tobami/codespeed.git/'
297-
'commit/{commitid}')
296+
'https://github.com/tobami/codespeed.git/'
297+
'commit/{commitid}')
298298

299299
# If filled in, commit browsing url should not change
300300
self.github_project.commit_browsing_url = 'https://example.com/{commitid}'
301301
self.github_project.save()
302302
self.assertEqual(self.github_project.commit_browsing_url,
303-
'https://example.com/{commitid}')
303+
'https://example.com/{commitid}')

‎codespeed/tests/test_views.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def test_bad_environment(self):
9999
response = self.client.post(self.path, self.data)
100100
self.assertEqual(response.status_code, 400)
101101
self.assertEqual(response.content.decode(),
102-
"Environment " + bad_name + " not found")
102+
"Environment " + bad_name + " not found")
103103
self.data['environment'] = 'Dual Core'
104104

105105
def test_empty_argument(self):
@@ -118,7 +118,7 @@ def test_missing_argument(self):
118118
"""Should respond 400 when a POST request is missing an argument"""
119119
for key in list(self.data):
120120
backup = self.data[key]
121-
del(self.data[key])
121+
del self.data[key]
122122
response = self.client.post(self.path, self.data)
123123
self.assertEqual(response.status_code, 400)
124124
self.assertEqual(
@@ -290,7 +290,7 @@ def test_add_correct_results(self):
290290
# Check that we get a success response
291291
self.assertEqual(response.status_code, 202)
292292
self.assertEqual(response.content.decode(),
293-
"All result data saved successfully")
293+
"All result data saved successfully")
294294

295295
# Check that the data was correctly saved
296296
e = Environment.objects.get(name='bigdog')
@@ -365,7 +365,7 @@ def test_missing_argument(self):
365365
data = self.data[2]
366366
for key in list(data):
367367
backup = data[key]
368-
del(data[key])
368+
del data[key]
369369
response = self.client.post(self.path,
370370
{'json': json.dumps(self.data)})
371371
self.assertEqual(response.status_code, 400)

‎codespeed/views_data.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ def getdefaultexecutable():
126126
settings.DEF_EXECUTABLES is not None):
127127
try:
128128
def_name = settings.DEF_EXECUTABLES[0]['name']
129-
def_project = Project.objects.get(name=settings.DEF_EXECUTABLES[0]['project'])
129+
def_project = Project.objects.get(
130+
name=settings.DEF_EXECUTABLES[0]['project'])
130131
default = Executable.objects.get(name=def_name, project=def_project)
131132
except Executable.DoesNotExist:
132133
pass

0 commit comments

Comments
 (0)