Skip to content

Commit

Permalink
Using GitHub actions for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
clintonb committed Jan 25, 2021
1 parent 895364e commit 96e8e9d
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 103 deletions.
117 changes: 117 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.5, 3.6, 3.7, 3.8, 3.9 ]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ matrix.python-version }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox-gh-actions
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test
run: |
tox
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ matrix.python-version }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox-gh-actions
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
i18n:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ matrix.python-version }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ matrix.python-version }}-pip-
- name: Install gettext
run: |
sudo apt-get install -y gettext-base gettext
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install django
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: i18n validation
run: |
tox -e i18n
release-test:
runs-on: ubuntu-latest

needs: [test, lint, i18n]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: casperdcl/deploy-pypi@v2
with:
url: https://test.pypi.org/legacy/
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
build: true
skip_existing: true

release-production:
# Only upload if a tag is pushed (otherwise just build & check)
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')

runs-on: ubuntu-latest

needs: [test, lint, i18n, release-test]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: casperdcl/deploy-pypi@v2
with:
password: ${{ secrets.PYPI_API_TOKEN }}
build: true
73 changes: 0 additions & 73 deletions .travis.yml

This file was deleted.

11 changes: 6 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# These are required to run the tests.
Django
flake8
django-jinja>=2.4.1,<3
Jinja2>=2.7.1
transifex-client

# Everything else is in a Django-version-free version
# for TravisCI.
-r travis.txt
flake8
mock==1.3.0
tox
3 changes: 3 additions & 0 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
flake8
mock==4.0.3
tox
10 changes: 0 additions & 10 deletions test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,6 @@
}
}

if 'DATABASE_URL' in os.environ:
try:
import dj_database_url
import psycopg2
DATABASES['default'] = dj_database_url.config()
except ImportError:
raise ImportError('Using the DATABASE_URL variable requires '
'dj-database-url and psycopg2. Try:\n\npip install '
'-r travis.txt')

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
Expand Down
25 changes: 16 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
[tox]
envlist =
py{35,36,37,38}-django22
py{36,37,38}-django{30,31,master}
py35-django22
py{36,37,38,39}-django{22,30,31,master}

[gh-actions]
python =
3.5: py35
3.6: py36
3.7: py37
3.8: py38
3.9: py39

[testenv]
deps =
django22: Django>=2.2,<2.3
django30: Django>=3.0,<3.1
django31: Django>=3.1,<3.2
djangomaster: https://github.com/django/django/archive/master.tar.gz
-rtravis.txt
passenv = DATABASE_URL
django30: Django>=3.0,<3.1
django31: Django>=3.1,<3.2
djangomaster: https://github.com/django/django/archive/master.tar.gz
-r{toxinidir}/requirements.txt
commands =
./run.sh test

[testenv:i18n]
deps =
Django>=3.1,<3.2
-rtravis.txt
Django>=3.1,<3.2
-r{toxinidir}/requirements.txt
commands =
./run.sh makemessages
./run.sh compilemessages
Expand Down
6 changes: 0 additions & 6 deletions travis.txt

This file was deleted.

0 comments on commit 96e8e9d

Please sign in to comment.