Skip to content

chore: add tox.ini for local development#38

Merged
salman2013 merged 9 commits into
mainfrom
salman/modernize-branch
Jun 24, 2026
Merged

chore: add tox.ini for local development#38
salman2013 merged 9 commits into
mainfrom
salman/modernize-branch

Conversation

@salman2013

@salman2013 salman2013 commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Modernizes the local development and CI tooling to use tox as the single source of truth for running lint, tests, and docs — matching the approach used in the XBlock repo itself.

  • Adds tox.ini with lint, django42, django52, and docs environments using uv-venv-lock-runner
  • Replaces [project.optional-dependencies] test/docs extras with [dependency-groups] (test-base, test, django42, doc, ci) for proper Django version isolation
  • Adds a ci dependency group (tox + tox-uv) so CI installs only what it needs via uv sync --group ci
  • Simplifies CI from two separate jobs (lint + test) to a single run_tests matrix job over [lint, docs, django42, django52]
  • Tox is now the canonical way to run all checks locally (make lint, make test, make docs all delegate to tox)
  • Sets fail_ci_if_error: true on Codecov upload so coverage failures surface in CI
  • Bumps codecov/codecov-action pin from v6.0.1 → v6.0.2 (fixes GPG key verification failure)
  • Declares uv.lock conflicts between test and django42 groups (uv derives the doc conflict automatically via include-group)

Test plan

  • make lint passes (tox -e lint)
  • make test passes (tox -e django42,django52)
  • make docs passes (tox -e docs)
  • CI matrix runs all four envs: lint, docs, django42, django52

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels May 19, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @salman2013!

This repository is currently maintained by @openedx/axim-engineering.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@codecov

codecov Bot commented May 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.17%. Comparing base (6a4dea2) to head (e411010).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #38   +/-   ##
=======================================
  Coverage   82.17%   82.17%           
=======================================
  Files          48       48           
  Lines        1419     1419           
  Branches      110      110           
=======================================
  Hits         1166     1166           
  Misses        221      221           
  Partials       32       32           
Flag Coverage Δ
unittests 82.17% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a tox.ini configuration to make it easy to run the repo’s existing linting, tests (with coverage), and docs build locally via tox, using uv-native tox environments (tox-uv).

Changes:

  • Introduces lint, test, and docs tox environments.
  • Uses uv-venv-lock-runner with extras mapped to existing optional-dependency groups (dev, test, docs).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tox.ini Outdated
Comment thread tox.ini Outdated
@farhan

farhan commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

I think we can follow two approaches for command orchestration:

  1. Current: Commands defined in Makefile; both ci.yml and tox.ini (PR need updates) delegate to make targets.
    • suggested tox file changes are below
[tox]
envlist = lint, test, docs
requires =
   tox-uv>=1

[testenv:lint]
runner = uv-venv-lock-runner
extras = dev
allowlist_externals = make
commands =
   make lint

[testenv:test]
runner = uv-venv-lock-runner
extras = test
allowlist_externals = make
commands =
   make test-with-coverage

[testenv:docs]
runner = uv-venv-lock-runner
extras = docs
allowlist_externals = make
commands =
   make docs
  1. Alternative: Commands defined in tox.ini; both ci.yml and Makefile delegate to tox -e .

I think we should follow second option:

Reasons:

  • tox is the Python & Open edX community standard for this — it's what contributors expect
  • CI and local environments are guaranteed to match (tox manages the venv)
  • Makefile becomes a convenience layer, not a logic layer — make test just calls tox -e test

@feanil @kdmccormick @openedx/axim-aximprovements

@feanil

feanil commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

@farhan I agree, I think the 2nd option is the way to go. Tox for codifying the testing env and then makefile for convenience/consistency aliases for calling Tox.

@farhan

farhan commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

@salman2013 Let's go for second option then

Please study xblocks-core tox.ini to run tests for different environments; different django versions;

and keep it consistent in all the repositories.

- Makefile and CI now delegate to `tox -e <env>` instead of running commands directly
- Add `allowlist_externals = make` to [testenv:docs] for tox v4 compatibility
- Add `uv tool install tox --with tox-uv` to `make requirements`

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@farhan

farhan commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

make test or tox -e test command is not running the tests in all the environments.
We should replicated the ci test commands to tox -e test, to run the ci tests locally.

xblocks-extra
Screenshot 2026-06-23 at 2 07 12 PM

We should add all the environments in the tox supported by the repository.
Please look into xblocks-core tox.ini file

xblocks-core
Screenshot 2026-06-23 at 2 04 55 PM

@farhan farhan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

done with the pass

Comment thread .github/workflows/ci.yml
salman2013 and others added 3 commits June 23, 2026 16:13
Adds PEP 735 dependency groups to test against Django 4.2 and 5.2
(matching the CI matrix), following the same pattern as openedx/XBlock.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
- Replace separate lint/test/docs CI jobs with a single matrix job
  over [lint, docs, django42, django52] running in parallel
- Use uv sync --group ci instead of uv tool install tox
- Simplify tox envs from py312-django{42,52} to django{42,52}
  using [testenv] default with dependency group factors
- Add ci dependency group to lock tox/tox-uv versions

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@salman2013 salman2013 requested a review from farhan June 23, 2026 11:48
Matches XBlock's approach of using changedir = {toxinidir}/docs
with make html instead of make -C docs html.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

@farhan farhan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some change requests, rest seems good,
We are close to merge I believe

Comment thread tox.ini Outdated
@@ -0,0 +1,26 @@
[tox]
envlist = django{42,52}, lint, docs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should add python version explicitly
py312-django{42,52}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Its takes default python version so don't need to mention.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should make sure the default version is 3.12 otherwise we will get errors (for example on python version 3.11, 3.13); so explicitly mentioning the supported python versions is better atleast in tox.ini

reference

image

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

alright i have updated it.

Comment thread Makefile Outdated
test-with-coverage: ## Run tests with coverage reporting
uv run pytest --cov=$(SRC_DIRECTORY) --cov-report=xml
test: ## Run tests against all supported Python/Django combinations
tox -e "django{42,52}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same:
I think we should add python version explicitly
py312-django{42,52}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Its takes default python version so don't need to mention.

Comment thread .github/workflows/ci.yml Outdated
Comment thread pyproject.toml Outdated
salman2013 and others added 2 commits June 24, 2026 15:05
- Set fail_ci_if_error: true so coverage upload failures surface in CI
- Remove explicit {group = "doc"} from uv conflicts; uv derives it
  automatically since doc includes test via include-group

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
v6.0.1 had a stale GPG signing key causing CI failures.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@salman2013 salman2013 requested a review from farhan June 24, 2026 10:25
@salman2013 salman2013 merged commit 1f30ddc into main Jun 24, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from Ready for Review to Done in Contributions Jun 24, 2026
@salman2013 salman2013 deleted the salman/modernize-branch branch June 24, 2026 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants