Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Tests

on:
push:
branches: [speed.python.org]
pull_request:
branches: [speed.python.org]

permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.13"
- run: pip install -r requirements-dev.txt
- run: flake8 codespeed

test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.13", "3.14"]
django: ["5.2", "6.1"]
name: Python ${{ matrix.python-version }} / Django ${{ matrix.django }}
env:
DJANGO_SETTINGS_MODULE: sample_project.settings

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: ${{ matrix.python-version }}
- run: pip install -r requirements.txt "django==${{ matrix.django }}.*"
- run: python manage.py test codespeed
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ override
build
dist
*.egg-info
.venv*/
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

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

Codespeed is a web application to monitor and analyze the performance of your code.
Expand Down
1 change: 0 additions & 1 deletion codespeed/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
default_app_config = 'codespeed.apps.CodespeedConfig'
2 changes: 2 additions & 0 deletions codespeed/commits/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .logs import get_logs, get_commit_date

__all__ = ["get_logs", "get_commit_date"]
3 changes: 2 additions & 1 deletion codespeed/commits/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get_scm(project):
elif project.repo_type == project.GIT:
from .git import getlogs, updaterepo
elif project.repo_type == project.GITHUB:
from .github import getlogs, updaterepo
from .github import getlogs, updaterepo # noqa: F401
else:
return None

Expand Down Expand Up @@ -51,6 +51,7 @@ def _get_commit_date(project, commit_id):

return scm.get_commit_date(commit_id)


def get_commit_date(project, commit_id):
date = _get_commit_date(project, commit_id)
if date is not None:
Expand Down
13 changes: 8 additions & 5 deletions codespeed/commits/mercurial.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def update_repo(self, update=True):
return

p = Popen(['hg', 'pull', '-u'], stdout=PIPE, stderr=PIPE,
cwd=project.working_copy)
cwd=project.working_copy)
stdout, stderr = p.communicate()

if p.returncode != 0 or stderr:
Expand All @@ -37,7 +37,7 @@ def update_repo(self, update=True):
cmd = ['hg', 'clone', project.repo_path, project.repo_name]

p = Popen(cmd, stdout=PIPE, stderr=PIPE,
cwd=settings.REPOSITORY_BASE_PATH)
cwd=settings.REPOSITORY_BASE_PATH)
logger.debug('Cloning Mercurial repo {0} for project {1}'.format(
project.repo_path, project))
stdout, stderr = p.communicate()
Expand All @@ -52,9 +52,11 @@ def update_repo(self, update=True):
def get_logs(self, endrev, startrev):
self.update_repo(update=False)

template = ("{rev}:{node|short}\n{node}\n{author|user}\n"
"{author|email}\n{date}\n{desc}\n=newlog=\n")
cmd = ["hg", "log",
"-r", "%s::%s" % (startrev.commitid, endrev.commitid),
"--template", "{rev}:{node|short}\n{node}\n{author|user}\n{author|email}\n{date}\n{desc}\n=newlog=\n"]
"-r", "%s::%s" % (startrev.commitid, endrev.commitid),
"--template", template]

working_copy = self.project.working_copy
p = Popen(cmd,
Expand Down Expand Up @@ -86,7 +88,8 @@ def get_logs(self, endrev, startrev):

# Parse date
date = date.split('-')[0]
date = datetime.datetime.fromtimestamp(float(date)).strftime("%Y-%m-%d %H:%M:%S")
date = datetime.datetime.fromtimestamp(
float(date)).strftime("%Y-%m-%d %H:%M:%S")

# Add changeset info
logs.append({
Expand Down
4 changes: 2 additions & 2 deletions codespeed/commits/tests/test_git.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from datetime import datetime
from django.test import TestCase, override_settings
from mock import Mock, patch
from unittest.mock import Mock, patch

from codespeed.commits.git import getlogs
from codespeed.models import Project, Revision, Branch, Environment
Expand Down Expand Up @@ -57,4 +57,4 @@ def side_effect(cmd, *args, **kwargs):
'short_commit_id': 'id',
'tag': 'tag',
}
self.assertEquals([expected], logs)
self.assertEqual([expected], logs)
32 changes: 16 additions & 16 deletions codespeed/fixtures/timeline_tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"commitid": "1",
"tag": "",
"branch": 1,
"date": "2011-04-12T16:43:20",
"date": "2011-04-12T16:43:20Z",
"message": ""
}
},
Expand All @@ -95,7 +95,7 @@
"commitid": "2",
"tag": "",
"branch": 1,
"date": "2011-04-13T17:04:22",
"date": "2011-04-13T17:04:22Z",
"message": ""
}
},
Expand All @@ -108,7 +108,7 @@
"commitid": "3",
"tag": "",
"branch": 2,
"date": "2011-04-13T12:03:38",
"date": "2011-04-13T12:03:38Z",
"message": ""
}
},
Expand All @@ -121,7 +121,7 @@
"commitid": "4",
"tag": "",
"branch": 2,
"date": "2011-04-14T18:04:51",
"date": "2011-04-14T18:04:51Z",
"message": ""
}
},
Expand All @@ -134,7 +134,7 @@
"commitid": "5",
"tag": "",
"branch": 1,
"date": "2011-04-14T19:13:05",
"date": "2011-04-14T19:13:05Z",
"message": ""
}
},
Expand All @@ -147,7 +147,7 @@
"commitid": "1",
"tag": "",
"branch": 3,
"date": "2011-04-13T12:05:11",
"date": "2011-04-13T12:05:11Z",
"message": ""
}
},
Expand All @@ -160,7 +160,7 @@
"commitid": "2",
"tag": "",
"branch": 3,
"date": "2011-04-14T12:05:22",
"date": "2011-04-14T12:05:22Z",
"message": ""
}
},
Expand All @@ -173,7 +173,7 @@
"commitid": "444",
"tag": "1.0",
"branch": 4,
"date": "2011-05-24T09:37:32",
"date": "2011-05-24T09:37:32Z",
"message": ""
}
},
Expand Down Expand Up @@ -253,7 +253,7 @@
"environment": 1,
"val_min": 3995.1,
"std_dev": 1.11111,
"date": "2011-04-13T19:04:00",
"date": "2011-04-13T19:04:00Z",
"val_max": 4001.6,
"revision": 1
}
Expand All @@ -268,7 +268,7 @@
"environment": 1,
"val_min": 1995.1,
"std_dev": 1.11111,
"date": "2011-04-13T17:06:19",
"date": "2011-04-13T17:06:19Z",
"val_max": 2001.6,
"revision": 2
}
Expand All @@ -283,7 +283,7 @@
"environment": 1,
"val_min": 995.1,
"std_dev": 1.11111,
"date": "2011-04-13T17:06:47",
"date": "2011-04-13T17:06:47Z",
"val_max": 1001.6,
"revision": 5
}
Expand All @@ -298,7 +298,7 @@
"environment": 1,
"val_min": 3995.1,
"std_dev": 1.11111,
"date": "2011-04-13T19:06:11",
"date": "2011-04-13T19:06:11Z",
"val_max": 4001.6,
"revision": 3
}
Expand All @@ -313,7 +313,7 @@
"environment": 1,
"val_min": 995.1,
"std_dev": 1.11111,
"date": "2011-04-13T19:11:50",
"date": "2011-04-13T19:11:50Z",
"val_max": 1001.6,
"revision": 6
}
Expand All @@ -328,7 +328,7 @@
"environment": 1,
"val_min": 2995.1,
"std_dev": 1.11111,
"date": "2011-04-13T19:06:58",
"date": "2011-04-13T19:06:58Z",
"val_max": 3001.6,
"revision": 4
}
Expand All @@ -343,7 +343,7 @@
"environment": 1,
"val_min": 495.1,
"std_dev": 1.11111,
"date": "2011-04-13T19:12:23",
"date": "2011-04-13T19:12:23Z",
"val_max": 501.6,
"revision": 7
}
Expand All @@ -358,7 +358,7 @@
"environment": 1,
"val_min": null,
"std_dev": null,
"date": "2011-05-24T09:38:18",
"date": "2011-05-24T09:38:18Z",
"val_max": null,
"revision": 8
}
Expand Down
3 changes: 2 additions & 1 deletion codespeed/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ def __str__(self):
date = None
else:
date = self.date.isoformat(sep=" ")
string = " - ".join(filter(None, (date, self.commitid, self.tag, self.branch.name)))
string = " - ".join(
filter(None, (date, self.commitid, self.tag, self.branch.name)))
return string

class Meta:
Expand Down
6 changes: 3 additions & 3 deletions codespeed/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from __future__ import absolute_import

import logging
from datetime import datetime

from django.core.exceptions import ValidationError
from django.utils import timezone

from .models import (Environment, Project, Branch, Benchmark, Executable,
Revision, Result, Report)
Expand Down Expand Up @@ -52,7 +52,7 @@ def save_result(data, update_repo=True):
if error:
return res, True
else:
assert(isinstance(res, Environment))
assert isinstance(res, Environment)
env = res

p, created = Project.objects.get_or_create(name=data["project"])
Expand Down Expand Up @@ -119,7 +119,7 @@ def save_result(data, update_repo=True):
elif rev.date:
r.date = rev.date
else:
r.date = datetime.now()
r.date = timezone.now()

r.std_dev = data.get('std_dev')
r.val_min = data.get('min')
Expand Down
2 changes: 1 addition & 1 deletion codespeed/tests/test_auth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

import mock
from unittest import mock

from django.test import TestCase, override_settings
from django.http import HttpResponse
Expand Down
Loading
Loading