Skip to content

chore: Tox configuration scripts #718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,36 @@ on:

jobs:
test:
name: Test / OS ${{ matrix.os }} / Python ${{ matrix.python-version }}
name: Tests
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
runs-on: ${{ matrix.os }}
steps:
- name: Clone Repository
uses: actions/checkout@v4

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

- name: Set up Poetry
uses: abatilo/actions-poetry@v3
- uses: abatilo/actions-poetry@v3
with:
poetry-version: 1.3.2
- run: |
pip install tox>=4
pip install tox-gh>=1.2
tox -re ${{ matrix.python-version }}
- uses: codecov/codecov-action@v4

- name: Run Tests
run: poetry run tests
lint:
name: Code formatting
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
pip install tox>=4
tox -re format

- name: Upload Coverage
uses: codecov/codecov-action@v4
publish:
needs: test
if: ${{ !startsWith(github.event.head_commit.message, 'bump') && !startsWith(github.event.head_commit.message, 'chore') && github.ref == 'refs/heads/main' && github.event_name == 'push' && github.repository_owner == 'supabase-community' }}
Expand Down
3,402 changes: 1,838 additions & 1,564 deletions CHANGELOG.md

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions Makefile

This file was deleted.

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ Currently the test suites are in a state of flux. We are expanding our clients t
The above test database is a blank supabase instance that has populated the `countries` table with the built in countries script that can be found in the supabase UI. You can launch the test scripts and point to the above test database by running

```bash
./test.sh
# Example: Run tests against python3.9 environment
$ tox -e py39
```

## Badges
Expand Down
1,634 changes: 861 additions & 773 deletions poetry.lock

Large diffs are not rendered by default.

16 changes: 0 additions & 16 deletions poetry_scripts.py

This file was deleted.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ python-semantic-release = "^9.3.1"
python-dotenv = "^1.0.1"

[tool.poetry.scripts]
tests = 'poetry_scripts:run_tests'
format = 'poetry_scripts:lint'
install = 'poetry_scripts:install'
coverage = 'poetry_scripts:coverage'

[tool.poetry.group.dev.dependencies]
unasync-cli = "^0.0.9"
Expand Down
19 changes: 19 additions & 0 deletions scripts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import subprocess
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (llm): It's great to see automation scripts being added to enhance the development workflow. However, it would be beneficial to include unit tests for these scripts themselves, especially for the Command.run method, to ensure its reliability and handle potential exceptions gracefully. Testing the scripts will help in maintaining the robustness of the development workflow.



class Command:
@staticmethod
def run(cmd):
return subprocess.run(cmd, shell=True, check=True)


def install():
return Command.run("poetry install --verbose")


def lint():
return Command.run("poetry run pre-commit run --all-files")


def coverage():
return Command.run("poetry run pytest --cov=./ --cov-report=html -vv")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (llm): While the coverage command is a good addition, it's crucial to ensure that the test suite includes tests that cover the new tox configuration scripts. This includes testing for different Python environments as specified in the tox.ini file. If such tests are not present, I recommend adding them to verify that the tox configurations work as expected across the specified Python versions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (llm): The addition of a coverage command is commendable as it emphasizes the importance of test coverage. However, it would be beneficial to document the expected coverage threshold within the project's contribution guidelines or as a comment within this script. This ensures that contributors are aware of the coverage expectations and maintain or improve the test coverage with their contributions.

33 changes: 33 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[tox]
isolated_build = True
envlist = py37, py38, py39, py310, py311

[gh]
python =
3.11 = py311
3.10 = py310
3.9 = py39
3.8 = py38

[testenv]
allowlist_externals = poetry
require_locked_deps = true
poetry_dep_groups =
dev
setenv =
PYTHONPATH = {toxinidir}
passenv =
SUPABASE_URL
SUPABASE_KEY
commands =
poetry install --no-root -v
poetry run pytest -s --cov=./ --cov-report=term --cov-report=html

[testenv:build]
commands =
poetry install --only dev
poetry run unasync supabase tests

[testenv:format]
deps = pre-commit
commands = pre-commit run --all-files --show-diff-on-failure