Skip to content

Commit

Permalink
Merge pull request #8 from Shoobx/adamg-ghaci
Browse files Browse the repository at this point in the history
moving CI to GHA
  • Loading branch information
agroszer committed Feb 22, 2023
2 parents ce31211 + a44c58a commit cf83c65
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 207 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
@@ -1,2 +1,7 @@
[run]
omit = */tests/*,*/conftest.py
relative_files = True

[report]
show_missing = true
precision = 2
1 change: 0 additions & 1 deletion .coveralls.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/test.yml
@@ -0,0 +1,32 @@
name: migrant

on:
push:
pull_request:
schedule:
- cron: '0 12 * * 0' # run once a week on Sunday
workflow_dispatch:

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Test with tox
run: tox
- name: Coveralls
uses: AndreMiras/coveralls-python-action@develop
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
14 changes: 0 additions & 14 deletions .gitlab-ci.yml

This file was deleted.

19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion CHANGES.rst
Expand Up @@ -4,7 +4,7 @@ CHANGELOG
1.5.1 (unreleased)
------------------

- Nothing changed yet.
- Moving CI to github actions


1.5.0 (2023-01-24)
Expand Down
302 changes: 145 additions & 157 deletions Pipfile.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.rst
Expand Up @@ -2,8 +2,8 @@
Migrant
=======

.. image:: https://travis-ci.org/Shoobx/migrant.png?branch=master
:target: https://travis-ci.org/Shoobx/migrant
.. image:: https://github.com/Shoobx/migrant/actions/workflows/test.yml/badge.svg
:target: https://github.com/Shoobx/migrant/actions

.. image:: https://coveralls.io/repos/github/Shoobx/migrant/badge.svg?branch=master
:target: https://coveralls.io/github/Shoobx/migrant?branch=master
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Expand Up @@ -25,8 +25,11 @@ def read_file(filename):
"Intended Audience :: Developers",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Natural Language :: English",
"Operating System :: OS Independent",
Expand All @@ -39,7 +42,6 @@ def read_file(filename):
extras_require=dict(test=["coverage", "mock"],),
package_data = {'migrant': ['py.typed']},
install_requires=[
"configparser ; python_version<'3.0'", # Py3 configparser backport.
"setuptools",
],
entry_points={
Expand Down
12 changes: 6 additions & 6 deletions src/migrant/engine.py
Expand Up @@ -3,7 +3,7 @@
# Copyright 2014 by Shoobx, Inc.
#
###############################################################################
from typing import TypeVar, Dict, List, Tuple, Generic
from typing import Optional, TypeVar, Dict, List, Tuple, Generic
import logging
import multiprocessing
import functools
Expand All @@ -28,7 +28,7 @@ def __init__(
repository: Repository,
config: Dict[str, str],
dry_run: bool = False,
processes: int = None,
processes: Optional[int] = None,
) -> None:
self.backend = backend
self.repository = repository
Expand All @@ -37,7 +37,7 @@ def __init__(
self.config = config
self.processes = processes or multiprocessing.cpu_count()

def status(self, target_id: str = None) -> int:
def status(self, target_id: Optional[str] = None) -> int:
"""Return number of migration actions to be performed to
upgrade to target_id"""
target_id = self.pick_rev_id(target_id)
Expand Down Expand Up @@ -71,7 +71,7 @@ def _update(self, db: DBN, target_id: str) -> None:
self.backend.cleanup(cdb)
log.info(f"{_pname()}: Migration completed for {cdb}")

def update(self, target_id: str = None) -> None:
def update(self, target_id: Optional[str] = None) -> None:
target_id = self.pick_rev_id(target_id)
conns = self.backend.generate_connections()

Expand All @@ -85,7 +85,7 @@ def update(self, target_id: str = None) -> None:
for _ in pool.imap_unordered(f, conns):
pass

def test(self, target_id: str = None) -> None:
def test(self, target_id: Optional[str] = None) -> None:
target_id = self.pick_rev_id(target_id)
conns = self.backend.generate_test_connections()

Expand Down Expand Up @@ -141,7 +141,7 @@ def initialize_db(self, db: DBC, initial_revid: str):
f"{_pname()}: Initialized migrations for {db}. Assuming database is at {sid}"
)

def pick_rev_id(self, rev_id: str = None) -> str:
def pick_rev_id(self, rev_id: Optional[str] = None) -> str:
if rev_id is None:
# Pick latest one
rev_id = self.script_ids[-1]
Expand Down
24 changes: 19 additions & 5 deletions tox.ini
@@ -1,13 +1,27 @@
[tox]
envlist = py36, py37, py38
envlist = py37, py38, py39, py310, py311, mypy

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310, mypy
3.11: py311

[testenv]
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
commands =
py.test \
-rw --cov=src --cov-report=term-missing --cov-report=html \
-s --tb=native
-rw --cov=src --cov-report=term-missing --cov-report=term-missing -s --tb=native
deps =
pytest
.[test]
pytest
pytest-cov

[testenv:mypy]
description = Run mypy
deps =
mypy
{[testenv]deps}
commands =
mypy --install-types --non-interactive {toxinidir}/src

0 comments on commit cf83c65

Please sign in to comment.