Skip to content

Commit fac0761

Browse files
authored
Migrate from Travis CI to GitHub Actions and update Django+Python versions
1 parent 777b671 commit fac0761

File tree

6 files changed

+69
-173
lines changed

6 files changed

+69
-173
lines changed

.github/workflows/tests.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: tests
2+
3+
on: [pull_request, push]
4+
5+
jobs:
6+
tests:
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
database_url:
11+
- postgres://postgres:postgres@postgres/django_relativity
12+
- sqlite://
13+
- mysql://root:mysql@mysql/django_relativity
14+
django_version: ["3.2", "4.0", "4.1", "4.2"]
15+
python_version: ["3.8", "3.9", "3.10", "3.11"]
16+
include:
17+
- {django_version: "3.2", python_version: "3.6", database_url: "postgres://postgres:postgres@postgres/django_relativity"}
18+
- {django_version: "3.2", python_version: "3.6", database_url: "sqlite://"}
19+
- {django_version: "3.2", python_version: "3.6", database_url: "mysql://root:mysql@mysql/django_relativity"}
20+
- {django_version: "3.2", python_version: "3.7", database_url: "postgres://postgres:postgres@postgres/django_relativity"}
21+
- {django_version: "3.2", python_version: "3.7", database_url: "sqlite://"}
22+
- {django_version: "3.2", python_version: "3.7", database_url: "mysql://root:mysql@mysql/django_relativity"}
23+
exclude:
24+
- {django_version: "3.2", python_version: "3.11"}
25+
- {django_version: "4.0", python_version: "3.11"}
26+
runs-on: ubuntu-latest
27+
container: python:${{ matrix.python_version }}
28+
steps:
29+
- uses: actions/checkout@v3
30+
- run: make test
31+
env:
32+
DJANGO_VERSION: ${{ matrix.django_version }}
33+
DATABASE_URL: ${{ matrix.database_url }}
34+
services:
35+
mysql:
36+
image: ${{ startsWith(matrix.database_url, 'mysql') && 'mysql' || '' }}
37+
env:
38+
MYSQL_ROOT_PASSWORD: mysql
39+
options: >-
40+
--health-cmd "mysqladmin ping"
41+
--health-interval 10s
42+
--health-timeout 5s
43+
--health-retries 3
44+
postgres:
45+
image: ${{ startsWith(matrix.database_url, 'postgres') && 'postgres' || '' }}
46+
env:
47+
POSTGRES_USER: postgres
48+
POSTGRES_PASSWORD: postgres
49+
POSTGRES_DB: postgres
50+
options: >-
51+
--health-cmd pg_isready
52+
--health-interval 10s
53+
--health-timeout 5s
54+
--health-retries 3

.travis.yml

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

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
DJANGO_VERSION ?= 4.2
2+
13
venv:
24
python3 -mvenv venv
35
venv/bin/pip install --upgrade pip setuptools wheel
4-
venv/bin/pip install twine
56

67
build: venv
8+
venv/bin/pip install twine
79
venv/bin/python setup.py sdist bdist_wheel --universal
810

911
deploy:
1012
venv/bin/twine upload dist/*
13+
14+
test: venv
15+
xargs venv/bin/pip install --upgrade "django==$(DJANGO_VERSION).*" < test-requirements.txt
16+
PYTHONPATH=. DJANGO_SETTINGS_MODULE=tests.settings venv/bin/django-admin test

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# django-relativity
22

33
[![PyPI](https://img.shields.io/pypi/v/django-relativity.svg)](https://pypi.org/project/django-relativity/)
4-
[![Build Status](https://app.travis-ci.com/AlexHill/django-relativity.svg?branch=master)](https://app.travis-ci.com/github/AlexHill/django-relativity)
4+
![build status](https://github.com/alexhill/django-relativity/actions/workflows/tests.yml/badge.svg)
55

6-
django-relativity provides a `Relationship` field that lets you declare the non-foreign-key relationships between your models and use them throughout the ORM.
6+
django-relativity provides a `Relationship` field that lets you declare non-foreign-key relationships between your models and use them throughout the ORM.
77

88
_Non-foreign-key relationships?_
99

test-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
django-environ
22
django-mptt
33
django-treebeard
4+
psycopg2-binary
5+
mysqlclient

tests/tests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,18 +153,18 @@ def test_m2m_prefetch_related_forward(self):
153153
member_qs = Categorised.objects.filter(pk__lte=4)
154154
with self.assertNumQueries(2):
155155
members = member_qs.prefetch_related("categories")
156-
member_dict = {m: list(m.categories.all()) for m in members}
156+
member_dict = {m: set(m.categories.all()) for m in members}
157157
self.assertDictEqual(
158-
member_dict, {m: list(m.categories.all()) for m in member_qs}
158+
member_dict, {m: set(m.categories.all()) for m in member_qs}
159159
)
160160

161161
def test_m2m_prefetch_related_reverse(self):
162162
category_qs = Category.objects.filter(code__in=["AAA", "BBB"])
163163
with self.assertNumQueries(2):
164164
categories = category_qs.prefetch_related("members")
165-
category_dict = {c: list(c.members.all()) for c in categories}
165+
category_dict = {c: set(c.members.all()) for c in categories}
166166
self.assertDictEqual(
167-
category_dict, {c: list(c.members.all()) for c in category_qs}
167+
category_dict, {c: set(c.members.all()) for c in category_qs}
168168
)
169169

170170
def test_m2m_recursive_accessor_forward(self):

0 commit comments

Comments
 (0)