Skip to content

Commit

Permalink
global: migrate CI to gh-actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Parth Shandilya authored and lnielsen committed Dec 9, 2020
1 parent 027794e commit 4d1594f
Show file tree
Hide file tree
Showing 13 changed files with 190 additions and 119 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ indent_size = 4
[*.{css,html,js,json,yml}]
indent_size = 2

# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
# Matches the exact files either package.json or .github/workflows/*.yml
[{package.json, .github/workflows/*.yml}]
indent_size = 2

# Dockerfile
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish

on:
push:
tags:
- v*

jobs:
Publish:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
- name: Build package
# Remove `compile_catalog` if the package has no translations.
run: |
python setup.py compile_catalog sdist bdist_wheel
- name: Publish on PyPI
uses: pypa/[email protected]
with:
user: __token__
# The token is provided by the inveniosoftware organization
password: ${{ secrets.pypi_token }}
120 changes: 120 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2020 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

name: CI

on:
push:
branches: master
pull_request:
branches: master
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 3 * * 6'
workflow_dispatch:
inputs:
reason:
description: 'Reason'
required: false
default: 'Manual trigger'

jobs:
Tests:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
requirements-level: [min, pypi]
cache-service: [redis]
db-service: [postgresql9, postgresql11, mysql5, mysql8]
mq-service: [rabbitmq, redis]
search-service: [elasticsearch6, elasticsearch7]
exclude:
- python-version: 3.8
requirements-level: min

- python-version: 3.9
requirements-level: min

- db-service: postgresql11
python-version: 3.6

- db-service: mysql8
python-version: 3.6

- search-service: elasticsearch7
python-version: 3.6

- search-service: elasticsearch6
db-service: postgresql11

- search-service: elasticsearch6
db-service: mysql8

- search-service: elasticsearch7
db-service: postgresql9

- search-service: elasticsearch7
db-service: mysql5

include:
- db-service: postgresql9
DB_EXTRAS: "postgresql"

- db-service: postgresql11
DB_EXTRAS: "postgresql"

- db-service: mysql5
DB_EXTRAS: "mysql"

- db-service: mysql8
DB_EXTRAS: "mysql"

- search-service: elasticsearch6
SEARCH_EXTRAS: "elasticsearch6"

- search-service: elasticsearch7
SEARCH_EXTRAS: "elasticsearch7"

env:
CACHE: ${{ matrix.cache-service }}
DB: ${{ matrix.db-service }}
MQ: ${{ matrix.mq-service }}
SEARCH: ${{ matrix.search-service }}
EXTRAS: all,${{ matrix.DB_EXTRAS }},${{ matrix.SEARCH_EXTRAS }}
steps:
- name: Checkout
uses: actions/checkout@v2

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

- name: Generate dependencies
run: |
python -m pip install --upgrade pip setuptools py wheel requirements-builder
requirements-builder -e "$EXTRAS" --level=${{ matrix.requirements-level }} setup.py > .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('.${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt') }}

- name: Install dependencies
run: |
pip install -r .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt
pip install ".[$EXTRAS]"
pip freeze
docker --version
docker-compose --version
- name: Run tests
run: |
./run-tests.sh
95 changes: 0 additions & 95 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,6 @@ Before you submit a pull request, check that it meets these guidelines:
1. The pull request should include tests and must not decrease test coverage.
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring.
3. The pull request should work for Python 2.7, 3.3, 3.4 and 3.5. Check
https://travis-ci.org/inveniosoftware/invenio-records-rest/pull_requests
3. The pull request should work for Python 3.6, 3.7, 3.8 and 3.9. Check
https://github.com/inveniosoftware/invenio-records-rest/actions?query=event%3Apull_request
and make sure that the tests pass for all supported Python versions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ recursive-include misc *.py
recursive-include misc *.rst
recursive-include tests *.json
recursive-include tests *.py
recursive-include .github/workflows *.yml
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
.. image:: https://img.shields.io/github/license/inveniosoftware/invenio-records-rest.svg
:target: https://github.com/inveniosoftware/invenio-records-rest/blob/master/LICENSE

.. image:: https://img.shields.io/travis/inveniosoftware/invenio-records-rest.svg
:target: https://travis-ci.org/inveniosoftware/invenio-records-rest
.. image:: https://github.com/inveniosoftware/invenio-records-rest/workflows/CI/badge.svg
:target: https://github.com/inveniosoftware/invenio-records-rest/actions?query=workflow%3ACI

.. image:: https://img.shields.io/coveralls/inveniosoftware/invenio-records-rest.svg
:target: https://coveralls.io/r/inveniosoftware/invenio-records-rest
Expand Down
26 changes: 20 additions & 6 deletions run-tests.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
#!/usr/bin/env sh
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2015-2020 CERN.
# Copyright (C) 2020 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

python -m check_manifest --ignore ".travis-*" && \
python -m sphinx.cmd.build -qnNW docs docs/_build/html && \
python -m pytest && \
python -m sphinx.cmd.build -qnNW -b doctest docs docs/_build/doctest
# Quit on errors
set -o errexit

# Quit on unbound symbols
set -o nounset

# Always bring down docker services
function cleanup() {
eval "$(docker-services-cli down --env)"
}
trap cleanup EXIT


python -m check_manifest --ignore ".*-requirements.txt"
python -m sphinx.cmd.build -qnNW docs docs/_build/html
eval "$(docker-services-cli up --db ${DB:-postgresql} --search ${SEARCH:-elasticsearch} --cache ${CACHE:-redis} --mq ${MQ:-rabbitmq} --env)"
python -m pytest
tests_exit_code=$?
python -m sphinx.cmd.build -qnNW -b doctest docs docs/_build/doctest
exit "$tests_exit_code"
12 changes: 4 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,14 @@

tests_require = [
'Flask-Login>=0.3.2',
'invenio-db[all]>=1.0.2',
'invenio-indexer>=1.0.0',
'invenio-config>=1.0.2',
'invenio-db[all]>=1.0.8',
'pytest-invenio>=1.4.0',
]

invenio_search_version = '1.2.0'

extras_require = {
'elasticsearch2': [
'invenio-search[elasticsearch2]>={}'.format(invenio_search_version),
],
'elasticsearch5': [
'invenio-search[elasticsearch5]>={}'.format(invenio_search_version),
],
Expand Down Expand Up @@ -60,7 +56,7 @@

extras_require['all'] = []
for name, reqs in extras_require.items():
if name[0] == ':' or name in ('elasticsearch2', 'elasticsearch5',
if name[0] == ':' or name in ('elasticsearch5',
'elasticsearch6', 'elasticsearch7'):
continue
extras_require['all'].extend(reqs)
Expand All @@ -76,9 +72,9 @@
'ftfy>=4.4.3',
'invenio-base>=1.2.3',
'invenio-pidstore>=1.2.0',
'invenio-records>=1.0.0',
'invenio-records>=1.4.0',
'invenio-rest>=1.2.2',
'invenio-indexer>=1.1.0',
'invenio-indexer>=1.2.0',
'invenio-i18n>=1.2.0',
'python-dateutil>=2.4.2',
]
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ def record_url(pid):
return url_for('invenio_records_rest.recid_item', pid_value=val)


def _mock_validate_fail(self):
def _mock_validate_fail(self, **kwargs):
"""Simulate a validation fail."""
raise ValidationError("")
2 changes: 1 addition & 1 deletion tests/test_views_item_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def test_invalid_patch(app, es, test_records, test_patch, charset, search_url,
assert res.status_code == 412


@mock.patch('invenio_records.api.Record.validate', _mock_validate_fail)
@mock.patch('invenio_records.api.Record.commit', _mock_validate_fail)
@pytest.mark.parametrize('content_type', [
'application/json-patch+json', 'application/json-patch+json;charset=utf-8'
])
Expand Down
2 changes: 1 addition & 1 deletion tests/test_views_item_put.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def test_invalid_put(app, es, test_records, charset, search_url):
assert res.status_code == 412


@mock.patch('invenio_records.api.Record.validate', _mock_validate_fail)
@mock.patch('invenio_records.api.Record.commit', _mock_validate_fail)
@pytest.mark.parametrize('content_type', [
'application/json', 'application/json;charset=utf-8'
])
Expand Down
Loading

0 comments on commit 4d1594f

Please sign in to comment.