Skip to content

Commit

Permalink
Merge pull request #789 from CenterForOpenScience/try/github-actions
Browse files Browse the repository at this point in the history
switch to github actions for running tests
  • Loading branch information
aaxelb committed Jul 12, 2021
2 parents 3804b1b + e9c32f1 commit 20b6e20
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 62 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: run_share_tests

on:
push:
pull_request:
workflow_dispatch:

permissions:
checks: write

jobs:

run_tests:
strategy:
matrix:
python-version: [3.6]
runs-on: ubuntu-latest


services:

postgres:
image: postgres:10
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

elasticsearch:
image: elasticsearch:5.4
env:
ES_JAVA_OPTS: "-Xms512m -Xmx512m"
ports:
- 9200:9200

steps:
- uses: actions/checkout@v2

- name: set up python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: install non-py dependencies
run: sudo apt-get install libxml2-dev libxslt1-dev libpq-dev

- name: cache py dependencies
id: cache-requirements
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements.txt', 'dev-requirements.txt') }}

- name: install py dependencies
if: steps.cache-requirements.outputs.cache-hit != 'true'
run: pip install -r dev-requirements.txt

- name: install share
run: python setup.py develop

- name: flake it
run: flake8 .

- name: run tests
run: |
coverage run -m pytest
coverage run --append -m behave
env:
DATABASE_PASSWORD: postgres

- name: send coverage report
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58 changes: 0 additions & 58 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ django-debug-toolbar==2.2
factory-boy==2.8.1
fake-factory==0.7.2
faker==4.0.3
flake8==3.8.4
httpretty==0.8.14
pytest-benchmark==3.0.0
pytest-cov==2.5.1
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ newrelic==2.86.3.70 # newrelic APM agent, Custom License
pendulum==1.2.5 # MIT
pillow==4.0.0 # PIL Software License:
psycogreen==1.0 # BSD
psycopg2==2.7.3 # LGPL with exceptions or ZPL
psycopg2==2.7.3.1 # LGPL with exceptions or ZPL
pycountry==1.20 # LGPL 2.1
python-dateutil==2.8.0 # Apache 2.0
PyJWE==1.0.0 # Apache 2.0
Expand Down
7 changes: 4 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,13 @@ def elastic_test_manager(settings, elastic_test_index_name):
elastic_manager.delete_index(elastic_test_index_name)
elastic_manager.create_index(elastic_test_index_name)

yield elastic_manager
try:
yield elastic_manager
finally:
elastic_manager.delete_index(elastic_test_index_name)

except (ConnectionError, ElasticConnectionError):
raise pytest.skip('Elasticsearch unavailable')
finally:
elastic_manager.delete_index(elastic_test_index_name)


@pytest.fixture
Expand Down

0 comments on commit 20b6e20

Please sign in to comment.