diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..5fed540 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,92 @@ +name: Test and Publish +on: + release: + types: [published] + push: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.x" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install pytest pytest-cov + + - name: Run tests + run: pytest --cov=src/ttt_game --cov-report=xml tests + + - name: Upload Coverage Report to Codecov.io + uses: codecov/codecov-action@v1 + with: + file: ./coverage.xml + flags: unittests + + build: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.x" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install build + + - name: Build package + run: python -m build + + - name: Archive production artifacts + uses: actions/upload-artifact@v2 + with: + name: built-files + path: dist + + publish-pypi: + needs: [test, build] + runs-on: ubuntu-latest + if: github.event_name == 'release' + steps: + - uses: actions/checkout@v2 + - name: Download a single artifact + uses: actions/download-artifact@v2 + with: + name: built-files + path: dist + + - name: Publish package + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} + + publish-testing: + needs: [test, build] + runs-on: ubuntu-latest + if: github.event_name == 'push' + steps: + - uses: actions/checkout@v2 + - name: Download a single artifact + uses: actions/download-artifact@v2 + with: + name: built-files + path: dist + + - name: Publish package + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ diff --git a/README.md b/README.md index 5e4a0a5..9d372a2 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,13 @@ -# Tic Tac Toe +# TTT-game + +[![codecov](https://codecov.io/gh/dm1sh/tic-tac-toe/branch/main/graph/badge.svg)](https://codecov.io/gh/dm1sh/tic-tac-toe) +![CI](https://github.com/dm1sh/tic-tac-toe/actions/workflows/ci.yaml/badge.svg) A simple tic tac toe game implementation ## Usage -tic-tac-toe module exports main game class `Game` and `Pl` and `Tr` enums to simplify typing. +tic_tac_toe module exports main game class `Game` and `Pl` and `Tr` enums to simplify typing. ### `Game` class diff --git a/setup.py b/setup.py index d142369..6da9c91 100644 --- a/setup.py +++ b/setup.py @@ -4,16 +4,16 @@ with open("README.md", "r", encoding="utf-8") as fh: long_description = fh.read() setuptools.setup( - name="tic-tac-toe-dm1sh", + name="ttt_game", version="0.0.1", author="dm1sh", author_email="me@dmitriy.icu", description="A simple tic tac toe game implementation", long_description=long_description, long_description_content_type="text/markdown", - url="https://github.com/dm1sh/tic-tac-toe", + url="https://github.com/dm1sh/ttt-game", project_urls={ - "Bug Tracker": "https://github.com/dm1sh/tic-tac-toe/issues", + "Bug Tracker": "https://github.com/dm1sh/ttt-game/issues", }, classifiers=[ "Programming Language :: Python :: 3", diff --git a/src/tic_tac_toe/__init__.py b/src/ttt_game/__init__.py similarity index 100% rename from src/tic_tac_toe/__init__.py rename to src/ttt_game/__init__.py diff --git a/src/tic_tac_toe/game.py b/src/ttt_game/game.py similarity index 100% rename from src/tic_tac_toe/game.py rename to src/ttt_game/game.py diff --git a/tests/test_game.py b/tests/test_game.py index 35fbde5..57eee61 100644 --- a/tests/test_game.py +++ b/tests/test_game.py @@ -1,4 +1,4 @@ -from src.tic_tac_toe import Game, Tr +from src.ttt_game import Game, Tr def test_init():