Skip to content

Commit 24fa6da

Browse files
committed
First pass at GH workflows
1 parent 380cab2 commit 24fa6da

File tree

8 files changed

+217
-110
lines changed

8 files changed

+217
-110
lines changed

.github/workflows/check-docs.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Docs
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
pre_job:
7+
name: Path match check
8+
runs-on: ubuntu-latest
9+
# Map a step output to a job output
10+
outputs:
11+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
12+
steps:
13+
- id: skip_check
14+
uses: fkirc/skip-duplicate-actions@master
15+
with:
16+
github_token: ${{ github.token }}
17+
paths: '["docs/**", "requirements/docs.txt"]'
18+
docs:
19+
name: Checking docs build
20+
needs: pre_job
21+
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v2
25+
- uses: actions/setup-python@v2
26+
- name: pip cache
27+
uses: actions/cache@v2
28+
with:
29+
path: ~/.cache/pip
30+
key: ${{ runner.os }}-pip-docs-${{ hashFiles('requirements/docs.txt') }}
31+
restore-keys: |
32+
${{ runner.os }}-pip-docs
33+
- name: Install dependencies
34+
run: |
35+
python -m pip install --upgrade pip
36+
pip install -r requirements/docs.txt
37+
- name: Check Docs build
38+
run: make docs

.github/workflows/python2-lint.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Python 2 linting
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
pre_job:
7+
name: Path match check
8+
runs-on: ubuntu-latest
9+
# Map a step output to a job output
10+
outputs:
11+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
12+
steps:
13+
- id: skip_check
14+
uses: fkirc/skip-duplicate-actions@master
15+
with:
16+
github_token: ${{ github.token }}
17+
paths: '["morango/**.py"]'
18+
lint:
19+
name: Python 2 syntax checking
20+
needs: pre_job
21+
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v2
25+
- name: Set up Python 2.7
26+
uses: actions/setup-python@v2
27+
with:
28+
python-version: 2.7
29+
- name: Install dependencies
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install flake8
33+
- name: Lint with flake8
34+
run: |
35+
flake8 morango

.github/workflows/tox.yml

+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Python tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
pre_job:
7+
name: Path match check
8+
runs-on: ubuntu-latest
9+
# Map a step output to a job output
10+
outputs:
11+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
12+
steps:
13+
- id: skip_check
14+
uses: fkirc/skip-duplicate-actions@master
15+
with:
16+
github_token: ${{ github.token }}
17+
paths: '["**.py", ".github/workflows/tox.yml", "tox.ini", "requirements/*.txt"]'
18+
unit_test:
19+
name: Python unit tests
20+
needs: pre_job
21+
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
22+
runs-on: ubuntu-18.04
23+
strategy:
24+
max-parallel: 5
25+
matrix:
26+
python-version: [2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9]
27+
28+
steps:
29+
- uses: actions/checkout@v2
30+
- name: Set up Python ${{ matrix.python-version }}
31+
uses: actions/setup-python@v2
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
- name: Install tox
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install tox
38+
- name: tox env cache
39+
uses: actions/cache@v2
40+
with:
41+
path: ${{ github.workspace }}/.tox/py${{ matrix.python-version }}
42+
key: ${{ runner.os }}-tox-py${{ matrix.python-version }}-${{ hashFiles('setup.py', 'requirements/*.txt') }}
43+
- name: Test with tox
44+
run: tox -e py${{ matrix.python-version }}
45+
cryptography:
46+
name: Python cryptography enhanced unit tests
47+
needs: pre_job
48+
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
49+
runs-on: ubuntu-18.04
50+
strategy:
51+
max-parallel: 5
52+
matrix:
53+
python-version: [ 2.7, 3.6 ]
54+
crypto-version: [ 1.2, 1.8, 2.3 ]
55+
56+
steps:
57+
- uses: actions/checkout@v2
58+
- name: Set up Python ${{ matrix.python-version }}
59+
uses: actions/setup-python@v2
60+
with:
61+
python-version: ${{ matrix.python-version }}
62+
- name: Install system dependencies
63+
run: |
64+
sudo apt-get -y -qq update
65+
sudo apt-get install -y libssl-dev
66+
- name: Install tox
67+
run: |
68+
python -m pip install --upgrade pip
69+
pip install tox
70+
- name: tox env cache
71+
uses: actions/cache@v2
72+
with:
73+
path: ${{ github.workspace }}/.tox/py${{ matrix.python-version }}
74+
key: ${{ runner.os }}-tox-py${{ matrix.python-version }}-crypto${{ matrix.crypto-version }}-${{ hashFiles('setup.py', 'requirements/*.txt') }}
75+
- name: Test with tox
76+
run: tox -e py${{ matrix.python-version }}-cryptography{{ matrix.crypto-version }}
77+
postgres:
78+
name: Python postgres unit tests
79+
needs: pre_job
80+
if: ${{ needs.pre_job.outputs.should_skip != 'true' }}
81+
runs-on: ubuntu-18.04
82+
services:
83+
# Label used to access the service container
84+
postgres:
85+
# Docker Hub image
86+
image: postgres
87+
# Provide the password for postgres
88+
env:
89+
POSTGRES_USER: postgres
90+
POSTGRES_PASSWORD: postgres
91+
POSTGRES_DB: test
92+
# Set health checks to wait until postgres has started
93+
options: >-
94+
--health-cmd pg_isready
95+
--health-interval 10s
96+
--health-timeout 5s
97+
--health-retries 5
98+
ports:
99+
# Maps tcp port 5432 on service container to the host
100+
- 5432:5432
101+
steps:
102+
- uses: actions/checkout@v2
103+
- name: Set up Python 3.5 for Postgres
104+
uses: actions/setup-python@v2
105+
with:
106+
python-version: 3.5
107+
- name: Install tox
108+
run: |
109+
python -m pip install --upgrade pip
110+
pip install tox
111+
- name: tox env cache
112+
uses: actions/cache@v2
113+
with:
114+
path: ${{ github.workspace }}/.tox/py${{ matrix.python-version }}
115+
key: ${{ runner.os }}-tox-py${{ matrix.python-version }}-${{ hashFiles('setup.py', 'requirements/*.txt') }}
116+
- name: Test with tox
117+
run: tox -e postgres

.travis.yml

-54
This file was deleted.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Morango
22

3-
[![image](https://img.shields.io/travis/learningequality/morango.svg)](https://travis-ci.org/learningequality/morango)
3+
[![build](https://github.com/learningequality/morango/actions/workflows/tox.yml/badge.svg?branch=master)](https://github.com/learningequality/morango/actions)
44
[![image](http://codecov.io/github/learningequality/morango/coverage.svg?branch=master)](http://codecov.io/github/learningequality/morango?branch=master)
55
[![image](https://readthedocs.org/projects/morango/badge/?version=latest)](http://morango.readthedocs.org/en/latest/)
66

requirements/postgres.txt

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
psycopg2
1+
psycopg2==2.7.4
2+
cryptography==2.3

tests/testapp/testapp/postgres_test.py renamed to tests/testapp/testapp/postgres_settings.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@
1818
'default': {
1919
'ENGINE': 'django.db.backends.postgresql',
2020
'USER': 'postgres',
21-
'PASSWORD': '',
21+
'PASSWORD': 'postgres',
2222
'NAME': 'default', # This module should never be used outside of tests -- so this name is irrelevant
2323
'TEST': {
24-
'NAME': 'travis_ci_default'
24+
'NAME': 'test'
2525
}
2626
},
2727
'default-serializable': {
2828
'ENGINE': 'django.db.backends.postgresql',
2929
'USER': 'postgres',
30-
'PASSWORD': '',
30+
'PASSWORD': 'postgres',
3131
'NAME': 'default', # This module should never be used outside of tests -- so this name is irrelevant
3232
'TEST': {
33-
'NAME': 'travis_ci_default'
33+
'NAME': 'test'
3434
},
3535
'OPTIONS': {
3636
'isolation_level': isolation_level,

tox.ini

+20-50
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,43 @@
11
[tox]
2-
envlist = {py27,py34,py35,py36}-django{111}-cryptography{12,18,23},lint,docs
3-
4-
[testenv:lint]
5-
deps =
6-
flake8
7-
commands =
8-
flake8 morango
9-
10-
[testenv:docs]
11-
changedir = docs
12-
deps =
13-
-r{toxinidir}/requirements/docs.txt
14-
commands =
15-
make docs
16-
17-
[travis]
18-
python =
19-
2.7: py27,lint, postgres
20-
3.4: py34
21-
3.5: py35
22-
3.6: py36
23-
24-
[travis:env]
25-
DJANGO =
26-
1.11: django111
27-
CRYPTOGRAPHY =
28-
1.2: cryptography12
29-
1.8: cryptography18
30-
2.3: cryptography23
31-
LINT =
32-
yes: lint
33-
POSTGRES =
34-
yes: postgres
2+
envlist =
3+
py{2.7,3.4,3.5,3.6,3.7,3.8,3.9}
4+
py{2.7,3.6}-cryptography{1.2,1.8,2.3}
5+
postgres
356

367
[testenv]
378

389
whitelist_externals=
39-
sh
10+
sh
4011

4112
setenv =
4213
PYTHONPATH = {toxinidir}:{toxinidir}/tests/testapp
4314

4415
basepython =
45-
py27: python2.7
46-
py34: python3.4
47-
py35: python3.5
48-
py36: python3.6
49-
docs: python2.7
50-
lint: python2.7
51-
postgres: python2.7
16+
py2.7: python2.7
17+
py3.4: python3.4
18+
py3.5: python3.5
19+
py3.6: python3.6
20+
py3.7: python3.7
21+
py3.8: python3.8
22+
py3.9: python3.9
23+
postgres: python3.5
5224

5325
deps =
5426
-r{toxinidir}/requirements/test.txt
55-
django111: Django>=1.11,<1.12
56-
cryptography12: cryptography==1.2.3
57-
cryptography18: cryptography==1.8.1
58-
cryptography23: cryptography==2.3
27+
cryptography1.2: cryptography==1.2.3
28+
cryptography1.8: cryptography==1.8.1
29+
cryptography2.3: cryptography==2.3
5930

6031
commands =
6132
sh -c '! tests/testapp/manage.py makemigrations --dry-run --exit --noinput'
62-
py.test --cov=morango {posargs}
33+
py.test {posargs:--cov=morango --color=no}
6334

6435
[testenv:postgres]
6536
deps =
6637
-r{toxinidir}/requirements/test.txt
67-
psycopg2==2.7.4
68-
cryptography==2.3
38+
-r{toxinidir}/requirements/postgres.txt
6939
setenv =
7040
PYTHONPATH = {toxinidir}:{toxinidir}/tests/testapp
71-
DJANGO_SETTINGS_MODULE = testapp.postgres_test
41+
DJANGO_SETTINGS_MODULE = testapp.postgres_settings
7242
commands =
73-
py.test --cov=morango {posargs}
43+
py.test {posargs:--cov=morango --color=no}

0 commit comments

Comments
 (0)