Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #90 convert tests to using GitHub actions, migrating away from Travis #91

Merged
merged 20 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from 12 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
86 changes: 86 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- master
pull_request_target:
branches:
- master
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-20.04

strategy:
fail-fast: false

matrix:
python-version: [
# "3.8",
"3.9",
# "3.10",
# "3.11"
]
django-version: [
"3.2",
# "4.0",
# "4.1",
# "4.2",
]
es-dsl-version: [
"6.1",
"6.2",
# "6.4",
# "7.4"
]
es-version: [
"6.8.2"
# "7.13.4"
]


# exclude:
# - python-version: "3.9"
# django-version: "1.11"

steps:
- name: Install and Run Elasticsearch
uses: elastic/elastic-github-actions/elasticsearch@master
with:
stack-version: ${{ matrix.es-version }}

- uses: actions/checkout@v3

- name: Install Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Cache Pip Dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements/test.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install "Django==${{ matrix.django-version }}"
python -m pip install "elasticsearch-dsl==${{ matrix.es-dsl-version }}"
python -m pip install -r requirements/test.txt

- name: Run tests with Python ${{ matrix.python-version }} and Django ${{ matrix.django-version }} and elasticsearch-dsl-py ${{ matrix.es-dsl-version }}
run: |
TOX_ENV=$(echo "py${{ matrix.python-version }}-django-${{ matrix.django-version }}-es${{ matrix.es-dsl-version }}" | tr -d .)
echo -e "TOX_ENV: $TOX_ENV"
python -m tox -e $TOX_ENV
#
# - name: Publish Coverage Report
# uses: codecov/codecov-action@v1
22 changes: 11 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Config file for automatic testing at travis-ci.org

language: python
python: 3.6
python: 3.9

dist: trusty
dist: focal

branches:
only:
Expand All @@ -19,17 +19,17 @@ addons:

matrix:
include:
- env: TOX_ENV=py36-django110-es61 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
python: 3.6
- env: TOX_ENV=py36-django111-es61 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
python: 3.6
- env: TOX_ENV=py36-django20-es61 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
python: 3.6
- env: TOX_ENV=py36-django21-es61 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
python: 3.6
- env: TOX_ENV=py38-django32-es61 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
python: 3.9
# - env: TOX_ENV=py36-django111-es61 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
# python: 3.6
# - env: TOX_ENV=py36-django20-es61 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
# python: 3.6
# - env: TOX_ENV=py36-django21-es61 ES_APT_URL=https://artifacts.elastic.co/packages/6.x/apt
# python: 3.6

before_install:
- pip install pip==9.0.1
# - pip install pip==9.0.1
# work around https://github.com/travis-ci/travis-ci/issues/8363
- wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
- echo "deb $ES_APT_URL stable main" | sudo tee -a /etc/apt/sources.list.d/elk.list
Expand Down
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ to see the available ``make`` targets.

Elasticsearch Docker Compose
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This will enable you to serve elasticsearch via docker:

``docker-compose up``

Expand Down Expand Up @@ -411,6 +412,7 @@ There are already 100 films available using ``loaddata`` as follows:

Running Tests Locally
^^^^^^^^^^^^^^^^^^^^^
See `README_TESTS.md` for more information. High level summary:

Run ``make test``. To run all tests and quality checks locally,
run ``make test-all``.
Expand Down
26 changes: 26 additions & 0 deletions README_TESTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Running Tests

## Running Tests Locally with one version of python on mac

### install postgres - [deprecated / optional for now]
* _This is deprecated because for now we are using sqlite for testing_
* _In time, we may add this back_
* we need `pg_config` to be installed in order to use python locally
* `brew install postgresql`
* you may need to do `brew tap homebrew/core` first

### install version(s) of python you want to test with
* install pyenv
* use it to install python 3.9 and 3.10, or the versions you care about
* `pyenv local 3.9.17 3.10.11` or whatever versions you want

### install pip deps
* `make requirements` to install pip deps
* note that this requires `pg_config` to be on PATH

### run tests
* in another terminal, bring up dockerized postgres: `docker compose up`
* `make test` to run tests

## Running Tests Locally with multiple versions of python on mac

4 changes: 2 additions & 2 deletions django_elastic_migrations/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
URLs for django_elastic_migrations.
"""

from django.conf.urls import url
from django.urls import re_path
from django.views.generic import TemplateView

urlpatterns = [
url(r'', TemplateView.as_view(template_name="django_elastic_migrations/base.html")),
re_path(r'', TemplateView.as_view(template_name="django_elastic_migrations/base.html")),
]
4 changes: 2 additions & 2 deletions requirements/dev.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Additional requirements for development of this application

edx-lint # includes pylint, pylint-django, etc; configured use pylintrc
psycopg2 # for postgres
# psycopg2-binary # for postgres
diff-cover # Changeset diff test coverage
pip-tools # Requirements file management
tox # virtualenv management for tests
tox<4 # virtualenv management for tests
tox-battery # Makes tox aware of requirements file changes
tox-pyenv # be able to run multiple pyenv versions with tox
twine # uploading new versions to pypi
Expand Down
Loading