Skip to content

Closes #583: Add branching CI matrix job and test_branching.py#591

Open
bctiemann wants to merge 8 commits into
mainfrom
583-branching-ci
Open

Closes #583: Add branching CI matrix job and test_branching.py#591
bctiemann wants to merge 8 commits into
mainfrom
583-branching-ci

Conversation

@bctiemann

Copy link
Copy Markdown
Contributor

Summary

  • Adds testing/configuration_branching.py: wraps DATABASES in DynamicSchemaDict and registers BranchAwareRouter, satisfying netbox-branching's startup requirements for the test environment.
  • Adds netbox_custom_objects/tests/test_branching.py (carried over from the branching-check branch): 2793-line TransactionTestCase-based suite covering branch sync, merge, revert, and cross-COT lifecycle scenarios. All tests gate on HAS_BRANCHING so the standard main/feature CI jobs are unaffected.
  • Extends .github/workflows/lint-tests.yaml with a third matrix entry (netbox-ref: main, with-branching: true) that installs netboxlabs-netbox-branching>=1.0.0 and runs the full suite against configuration_branching.py. The job is continue-on-error: true while the pipeline stabilises.

Test plan

  • Confirm the new tests (main, true) CI job runs and branching tests are no longer skipped
  • Confirm the existing tests (main) and tests (feature) jobs are unaffected

Closes: #583

🤖 Generated with Claude Code

@bctiemann

Copy link
Copy Markdown
Contributor Author

Blocked by #574

bctiemann and others added 8 commits June 23, 2026 14:46
- Add testing/configuration_branching.py: wraps DATABASES in
  DynamicSchemaDict and adds BranchAwareRouter, enabling netbox-branching
  to initialise correctly in the test environment
- Add netbox_custom_objects/tests/test_branching.py (from branching-check
  branch): TransactionTestCase-based suite covering branch sync, merge,
  revert, and cross-COT lifecycle; all tests are skipped when
  netbox-branching is absent so the standard CI jobs are unaffected
- Extend .github/workflows/lint-tests.yaml with a third matrix entry
  (netbox-ref: main, with-branching: true) that installs
  netboxlabs-netbox-branching>=1.0.0 and runs the full test suite
  against configuration_branching.py; marked continue-on-error: true
  while the pipeline stabilises

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…full TransactionCleanupMixin

test_branching.py imports _recreate_contenttypes and relies on the full
setUp/tearDown logic in TransactionCleanupMixin for test isolation. These
were stripped from main but are required for the branching CI job.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The symbol only exists on 268-display-expression. Guard the import with
try/except so CI runs against main and feature branches can still load
base.py, and skip the reset call when the context var is absent.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The feature branch is a pre-release moving target; failures there are
expected when upcoming NetBox API changes haven't been adopted yet.
Non-blocking so they show up as warnings without breaking CI on main.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When HAS_BRANCHING is False, concrete test classes now inherit from
``object`` instead of ``TransactionTestCase`` via the ``_TestBase``
conditional. Django's test runner only discovers subclasses of
``unittest.TestCase`` (and its Django subclasses), so these classes are
invisible to the runner when netbox-branching is not installed.

Previously the classes were decorated with ``@skipUnless(HAS_BRANCHING)``
but still inherited from ``TransactionTestCase``, which was enough for the
test runner to discover and process them as skipped tests. The presence of
discovered-but-skipped TransactionTestCase classes was found to cause four
TestCase-based API tests to fail on the feature NetBox branch, likely due
to interaction with Django's test ordering or class-level machinery.

The ``@skipUnless`` decorators are kept as documentation and for the case
where a resolver re-enables discovery of the base class.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…okups

NetBox's feature branch enforces permission-filtered resolution for related
objects referenced in API write payloads. Grant the test user view permission
on Device, Tag, and cross-COT target models in the four tests that need it.

Also restore tests (feature) as a blocking CI job now that the failures are
fixed (only the branching job remains continue-on-error).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Branching adds per-request queries (branch lookup, schema check) that
are absent from the baselines recorded without branching.  The counts
are adequately tested by the non-branching matrix jobs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add CI matrix job with netbox-branching enabled so branching tests are not permanently skipped

1 participant