Skip to content

Commit 294e0f9

Browse files
authored
Feature/GitHub action (#80)
Create Github action for CI
1 parent f628a49 commit 294e0f9

File tree

3 files changed

+54
-36
lines changed

3 files changed

+54
-36
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python CI
5+
6+
on: [push, pull_request]
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
max-parallel: 4
13+
matrix:
14+
django-version: [2.2.27, 3.2.12]
15+
16+
steps:
17+
- uses: actions/checkout@v2
18+
- name: Set up Python 3.7
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: "3.7"
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install -q Django==${{ matrix.django-version }} flake8 coverage djangorestframework
26+
- name: Lint with flake8
27+
run: |
28+
flake8 --exclude vote/migrations/* vote
29+
- name: Test with coverage
30+
run: |
31+
coverage run runtests.py
32+
- name: Upload coverage to Codecov
33+
uses: codecov/codecov-action@v2

.travis.yml

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

runtests.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,47 @@
66

77
if not settings.configured:
88
settings.configure(
9+
SECRET_KEY="secret key",
910
DATABASES={
10-
'default': {
11-
'ENGINE': 'django.db.backends.sqlite3',
11+
"default": {
12+
"ENGINE": "django.db.backends.sqlite3",
1213
}
1314
},
1415
INSTALLED_APPS=[
15-
'django.contrib.auth',
16-
'django.contrib.sessions',
17-
'django.contrib.contenttypes',
18-
'vote',
19-
'test',
16+
"django.contrib.auth",
17+
"django.contrib.sessions",
18+
"django.contrib.contenttypes",
19+
"vote",
20+
"test",
2021
],
2122
ROOT_URLCONF="test.urls",
2223
MIDDLEWARE_CLASSES=[ # Deprecated in Django 1.10 https://docs.djangoproject.com/en/1.11/ref/settings/#middleware-classes
23-
'django.contrib.sessions.middleware.SessionMiddleware',
24-
'django.contrib.auth.middleware.AuthenticationMiddleware',
24+
"django.contrib.sessions.middleware.SessionMiddleware",
25+
"django.contrib.auth.middleware.AuthenticationMiddleware",
2526
],
2627
MIDDLEWARE=[
27-
'django.contrib.sessions.middleware.SessionMiddleware',
28-
'django.contrib.auth.middleware.AuthenticationMiddleware',
28+
"django.contrib.sessions.middleware.SessionMiddleware",
29+
"django.contrib.auth.middleware.AuthenticationMiddleware",
2930
],
3031
TEMPLATES=[
3132
{
32-
'BACKEND': 'django.template.backends.django.DjangoTemplates',
33-
'APP_DIRS': True,
34-
'OPTIONS': {
35-
'context_processors': [
36-
'django.template.context_processors.request',
37-
'django.contrib.auth.context_processors.auth',
33+
"BACKEND": "django.template.backends.django.DjangoTemplates",
34+
"APP_DIRS": True,
35+
"OPTIONS": {
36+
"context_processors": [
37+
"django.template.context_processors.request",
38+
"django.contrib.auth.context_processors.auth",
3839
],
39-
4040
},
4141
},
42-
43-
]
42+
],
4443
)
4544

4645

4746
def runtests():
48-
argv = sys.argv[:1] + ['test'] + sys.argv[1:]
47+
argv = sys.argv[:1] + ["test"] + sys.argv[1:]
4948
execute_from_command_line(argv)
5049

5150

52-
if __name__ == '__main__':
51+
if __name__ == "__main__":
5352
runtests()

0 commit comments

Comments
 (0)