diff --git a/.github/workflows/hatch_test.yml b/.github/workflows/hatch_test.yml new file mode 100644 index 0000000..631a6f4 --- /dev/null +++ b/.github/workflows/hatch_test.yml @@ -0,0 +1,30 @@ +name: "Unit Tests" + +on: + push: + branches: + - master + pull_request: + workflow_dispatch: + +jobs: + run: + name: "tests & coverage" + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.7", "3.10"] + + steps: + - uses: actions/checkout@v4 + + - name: Install Hatch + uses: pypa/hatch@install + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Run tests + run: hatch test --python ${{ matrix.python-version }} --cover-quiet --randomize --parallel --retries 5 --retry-delay 3 diff --git a/pyproject.toml b/pyproject.toml index fea4f09..99e0bb5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,9 @@ [project] name = "minject" description = "A small dependency injection library for Python." -classifiers=['Development Status :: 4 - Beta'] +classifiers = ['Development Status :: 4 - Beta'] dynamic = ["version"] -authors = [{name = "Matt McHenry", email = "mmchenry@duolingo.com"}, {name = "Alek Binion", email = "alek@duolingo.com"}, {name = "Service Framework Team", email = "service-framework-team@duolingo.com"}] +authors = [{ name = "Matt McHenry", email = "mmchenry@duolingo.com" }, { name = "Alek Binion", email = "alek@duolingo.com" }, { name = "Xiyan Shao", email = "xiyan@duolingo.com"}, { name = "Service Framework Team", email = "service-framework-team@duolingo.com" }] requires-python = ">=3.7" dependencies = [ @@ -32,5 +32,19 @@ dependencies = [ "typing", ] +[tool.hatch.envs.hatch-test] +dependencies = [ + # The default hatch-test dependencies are not compatible with Python 3.7, a version we want to test against. Hence + # we need to specify our own dependencies here. + # https://github.com/pypa/hatch/blob/3adae6c0dfd5c20dfe9bf6bae19b44a696c22a43/src/hatch/env/internal/test.py + "coverage[toml]", + 'coverage-enable-subprocess', + 'pytest', + 'pytest-mock', + 'pytest-randomly', + 'pytest-rerunfailures', + 'pytest-xdist[psutil]', +] + [[tool.hatch.envs.hatch-test.matrix]] python = ["3.7", "3.10"]