TEST-INFRA: [ci-pipeline-design] Optimize test data setup #1953

Open
opened 2026-04-03 00:22:24 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: task/ci-optimize-test-data-setup
  • Commit Message: chore(ci): create template database once and share between unit_tests and integration_tests sessions
  • Milestone: v3.8.0
  • Parent Epic: #1678

Background and Context

The CI pipeline currently creates a template database independently in both the unit_tests and integration_tests nox sessions. This is redundant work: the same setup is performed twice per CI run, adding unnecessary overhead to the pipeline and increasing overall execution time.

By extracting the template database creation into a dedicated nox session that runs once and whose output is shared between the two test sessions, the CI pipeline can avoid duplicate setup work and reduce total wall-clock time.

Current Behavior

Both the unit_tests and integration_tests nox sessions independently create a template database as part of their setup. This results in the template database being created twice per CI run, even though the output is identical.

Expected Behavior

The template database is created once in a dedicated nox session. Both the unit_tests and integration_tests nox sessions consume the shared template database rather than each creating their own.

Acceptance Criteria

  • A new nox session (e.g., setup_test_db) is introduced that creates the template database.
  • The unit_tests and integration_tests nox sessions are updated to depend on and use the template database created by the new session.
  • The template database is created exactly once per CI run.
  • All existing tests continue to pass after the refactor.
  • The CI pipeline is measurably faster due to the elimination of redundant database setup.

Supporting Information

  • Related to the broader CI execution time optimization effort tracked in Epic #1678.
  • See also: noxfile.py for the current session definitions and database setup logic.

Subtasks

  • Identify the template database creation logic in the unit_tests and integration_tests nox sessions
  • Create a new nox session (e.g., setup_test_db) that encapsulates the template database creation
  • Update the unit_tests nox session to depend on setup_test_db and use the shared template database
  • Update the integration_tests nox session to depend on setup_test_db and use the shared template database
  • Update the CI workflow (.forgejo/workflows/ci.yml) to invoke setup_test_db before the test sessions
  • Tests (Behave): Add/update scenarios to verify the shared template database setup
  • Tests (Robot): Add/update integration test to verify the CI pipeline uses the shared template database
  • Verify coverage >=97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • The template database is created once and shared between the unit_tests and integration_tests nox sessions.
  • The CI pipeline is faster due to the optimized test data setup.
  • All nox stages pass.
  • Coverage >= 97%.

Automated by CleverAgents Bot
Supervisor: Test Infrastructure | Agent: ca-new-issue-creator

## Metadata - **Branch**: `task/ci-optimize-test-data-setup` - **Commit Message**: `chore(ci): create template database once and share between unit_tests and integration_tests sessions` - **Milestone**: v3.8.0 - **Parent Epic**: #1678 ## Background and Context The CI pipeline currently creates a template database independently in both the `unit_tests` and `integration_tests` nox sessions. This is redundant work: the same setup is performed twice per CI run, adding unnecessary overhead to the pipeline and increasing overall execution time. By extracting the template database creation into a dedicated nox session that runs once and whose output is shared between the two test sessions, the CI pipeline can avoid duplicate setup work and reduce total wall-clock time. ## Current Behavior Both the `unit_tests` and `integration_tests` nox sessions independently create a template database as part of their setup. This results in the template database being created twice per CI run, even though the output is identical. ## Expected Behavior The template database is created once in a dedicated nox session. Both the `unit_tests` and `integration_tests` nox sessions consume the shared template database rather than each creating their own. ## Acceptance Criteria - A new nox session (e.g., `setup_test_db`) is introduced that creates the template database. - The `unit_tests` and `integration_tests` nox sessions are updated to depend on and use the template database created by the new session. - The template database is created exactly once per CI run. - All existing tests continue to pass after the refactor. - The CI pipeline is measurably faster due to the elimination of redundant database setup. ## Supporting Information - Related to the broader CI execution time optimization effort tracked in Epic #1678. - See also: `noxfile.py` for the current session definitions and database setup logic. ## Subtasks - [ ] Identify the template database creation logic in the `unit_tests` and `integration_tests` nox sessions - [ ] Create a new nox session (e.g., `setup_test_db`) that encapsulates the template database creation - [ ] Update the `unit_tests` nox session to depend on `setup_test_db` and use the shared template database - [ ] Update the `integration_tests` nox session to depend on `setup_test_db` and use the shared template database - [ ] Update the CI workflow (`.forgejo/workflows/ci.yml`) to invoke `setup_test_db` before the test sessions - [ ] Tests (Behave): Add/update scenarios to verify the shared template database setup - [ ] Tests (Robot): Add/update integration test to verify the CI pipeline uses the shared template database - [ ] Verify coverage >=97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - The template database is created once and shared between the `unit_tests` and `integration_tests` nox sessions. - The CI pipeline is faster due to the optimized test data setup. - All nox stages pass. - Coverage >= 97%. --- **Automated by CleverAgents Bot** Supervisor: Test Infrastructure | Agent: ca-new-issue-creator
freemo added this to the v3.8.0 milestone 2026-04-03 00:23:26 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • MoSCoW: MoSCoW/Could Have — CI/test infrastructure improvement.

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **MoSCoW**: MoSCoW/Could Have — CI/test infrastructure improvement. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
freemo removed this from the v3.8.0 milestone 2026-04-07 01:32:44 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#1953
No description provided.