Skip to content

Conversation

@AlexSkrypnyk
Copy link
Member

@AlexSkrypnyk AlexSkrypnyk commented Nov 1, 2025

Closes #1560

Summary by CodeRabbit

  • Tests
    • Refactored test infrastructure to adopt fixture-based naming conventions for helper functions.
    • Removed deprecated test utilities for CircleCI integration and deployment workflow validation.
    • Streamlined test helper organization by consolidating fixture setup and teardown routines.
    • Updated test files to use new fixture-oriented utilities.

@coderabbitai
Copy link

coderabbitai bot commented Nov 1, 2025

Walkthrough

The PR refactors BATS test infrastructure by renaming helper functions to use a fixture-oriented naming convention (prepare_* → fixture_*), introduces new fixture utilities for SSH keys, Docker config, and Robo tooling, removes three complete helper files (CircleCI, deployment, workflow), and updates dependent unit test files to use the new fixture APIs.

Changes

Cohort / File(s) Summary
Main fixture framework refactoring
.vortex/tests/bats/_helper.bash
Renames helper functions to fixture pattern (prepare_local_repofixture_local_repo, prepare_global_gitconfigfixture_global_gitconfig, prepare_global_gitignorefixture_global_gitignore, restore_global_gitignorefixture_global_gitignore_restore). Introduces new fixture utilities: fixture_ssh_key_prepare, fixture_ssh_key, fixture_ssh_key_with_suffix, fixture_docker_config_file, fixture_robo. Updates setup/teardown to invoke renamed fixtures.
Deleted helper modules
.vortex/tests/bats/_helper.circleci.bash, .vortex/tests/bats/_helper.deployment.bash, .vortex/tests/bats/_helper.workflow.bash
Removes entire CircleCI API helper (4 functions), deployment fixture helper (4 functions), and workflow assertion helper (30+ functions). Consolidates functionality into main _helper.bash and new fixture utilities.
Deployment unit tests updated
unit/deploy-artifact.bats, unit/deploy-container-registry.bats, unit/deploy-lagoon.bats, unit/deploy-webhook.bats, unit/login-container-registry.bats
Removes load ../_helper.deployment.bash dependencies. Replaces fixture calls: setup_ssh_key_fixturefixture_ssh_key_prepare, setup_robo_fixturefixture_ssh_key (or inline setup), provision_default_ssh_keyfixture_ssh_key, create_docker_config_filefixture_docker_config_file. In deploy-container-registry.bats, adds inline setup_robo_fixture function to configure Composer vendor paths.
SSH/DB unit tests updated
unit/download-db-lagoon.bats, unit/setup-ssh.bats
Replaces SSH fixture calls: setup_ssh_key_fixturefixture_ssh_key_prepare, provision_default_ssh_keyfixture_ssh_key, provision_ssh_key_with_suffixfixture_ssh_key_with_suffix. Updates test step labels (e.g., "Swap to" → "Move to").

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Large file deletions: Three substantial helper files removed with combined 30+ functions; verify all functionality is either properly migrated to new fixture utilities or intentionally deprecated as part of the PHPUnit migration strategy (linked issue Convert workflow BATS tests to PHPUnit tests #1560).
  • Cross-file consistency: Multiple test files updated with fixture renames; ensure all call sites are updated uniformly and no test files inadvertently retain references to deleted helpers.
  • Fixture API migration: New fixture functions must properly replace removed helpers; verify fixture_ssh_key, fixture_docker_config_file, and fixture_robo have equivalent behavior and return values to their predecessors.
  • Inline setup duplication: deploy-container-registry.bats introduces an inline setup_robo_fixture function; confirm this approach is consistent with the refactoring intent or should be centralized.

Possibly related PRs

Poem

🐰 Hop, hop—the fixtures now align!
From prepare_* to fixture_*, we refine,
Old workflows fade, new patterns shine,
Testing grounds reorganized, test helpers realign.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "[#1560] Removed obsolete BATS test helpers." is concise, specific, and clearly summarizes the primary change in the changeset. The title accurately reflects the main objective: removal of outdated test helper files and functions. It references the related issue number and uses clear, descriptive language without vague terms or unnecessary noise. The title directly corresponds to the substantive changes made across multiple helper files and test files.
Linked Issues Check ✅ Passed The PR changes align well with the primary objective of issue #1560 to convert workflow BATS tests to PHPUnit tests. The PR removes three entire helper files (_helper.circleci.bash, _helper.deployment.bash, _helper.workflow.bash) that provided dependencies for workflow and deployment BATS tests targeted for conversion (circleci.bats, deployment1.bats, deployment0.bats). Additionally, the refactoring of _helper.bash with new fixture-oriented naming conventions and introduction of new fixture functions supports the secondary objective of continuing to use BATS for unit testing of scripts. The updates across multiple unit test files ensure they work with the refactored helpers, maintaining functionality for tests that remain in BATS.
Out of Scope Changes Check ✅ Passed All changes in this PR are directly in scope with the linked issue objective. The removal of the three helper files (_helper.circleci.bash, _helper.deployment.bash, _helper.workflow.bash) targets the specific BATS files mentioned for PHPUnit conversion. The refactoring of _helper.bash with fixture naming conventions and new fixture functions supports unit testing of remaining scripts in BATS. The corresponding updates to unit test files (deploy-artifact.bats, deploy-container-registry.bats, deploy-lagoon.bats, deploy-webhook.bats, download-db-lagoon.bats, login-container-registry.bats, setup-ssh.bats) are necessary housekeeping changes to maintain test functionality after helper reorganization. No extraneous or unrelated changes are present.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/1560-cleanup-bats

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot temporarily deployed to commit November 1, 2025 22:27 Inactive
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f93d51 and 81d28b6.

📒 Files selected for processing (11)
  • .vortex/tests/bats/_helper.bash (5 hunks)
  • .vortex/tests/bats/_helper.circleci.bash (0 hunks)
  • .vortex/tests/bats/_helper.deployment.bash (0 hunks)
  • .vortex/tests/bats/_helper.workflow.bash (0 hunks)
  • .vortex/tests/bats/unit/deploy-artifact.bats (2 hunks)
  • .vortex/tests/bats/unit/deploy-container-registry.bats (3 hunks)
  • .vortex/tests/bats/unit/deploy-lagoon.bats (10 hunks)
  • .vortex/tests/bats/unit/deploy-webhook.bats (0 hunks)
  • .vortex/tests/bats/unit/download-db-lagoon.bats (3 hunks)
  • .vortex/tests/bats/unit/login-container-registry.bats (1 hunks)
  • .vortex/tests/bats/unit/setup-ssh.bats (11 hunks)
💤 Files with no reviewable changes (4)
  • .vortex/tests/bats/unit/deploy-webhook.bats
  • .vortex/tests/bats/_helper.circleci.bash
  • .vortex/tests/bats/_helper.deployment.bash
  • .vortex/tests/bats/_helper.workflow.bash
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: AlexSkrypnyk
Repo: drevops/vortex PR: 1896
File: .vortex/tests/bats/unit/download-db-lagoon.bats:24-25
Timestamp: 2025-08-08T12:02:24.652Z
Learning: In .vortex/tests/bats/unit Bats tests using ../_helper.bash (run_steps), prefixing a STEPS entry with "- " denotes a negative assertion (the substring must NOT appear in output). Unprefixed entries are positive assertions. Example: "- Database dump refresh requested. Will create a new dump." asserts absence; "Database dump refresh requested. Will create a new dump." asserts presence.
📚 Learning: 2025-08-08T12:02:24.652Z
Learnt from: AlexSkrypnyk
Repo: drevops/vortex PR: 1896
File: .vortex/tests/bats/unit/download-db-lagoon.bats:24-25
Timestamp: 2025-08-08T12:02:24.652Z
Learning: In .vortex/tests/bats/unit Bats tests using ../_helper.bash (run_steps), prefixing a STEPS entry with "- " denotes a negative assertion (the substring must NOT appear in output). Unprefixed entries are positive assertions. Example: "- Database dump refresh requested. Will create a new dump." asserts absence; "Database dump refresh requested. Will create a new dump." asserts presence.

Applied to files:

  • .vortex/tests/bats/unit/deploy-artifact.bats
  • .vortex/tests/bats/unit/setup-ssh.bats
  • .vortex/tests/bats/unit/download-db-lagoon.bats
  • .vortex/tests/bats/unit/deploy-lagoon.bats
  • .vortex/tests/bats/_helper.bash
  • .vortex/tests/bats/unit/deploy-container-registry.bats
  • .vortex/tests/bats/unit/login-container-registry.bats
📚 Learning: 2025-05-29T12:15:32.188Z
Learnt from: AlexSkrypnyk
Repo: drevops/vortex PR: 0
File: :0-0
Timestamp: 2025-05-29T12:15:32.188Z
Learning: Do not review files in `.vortex/installer/tests/Fixtures/install` directory as they are test fixtures.

Applied to files:

  • .vortex/tests/bats/unit/setup-ssh.bats
  • .vortex/tests/bats/unit/download-db-lagoon.bats
  • .vortex/tests/bats/unit/deploy-container-registry.bats
🧬 Code graph analysis (6)
.vortex/tests/bats/unit/deploy-artifact.bats (1)
.vortex/tests/bats/_helper.bash (3)
  • fixture_ssh_key_prepare (249-253)
  • fixture_ssh_key (255-258)
  • fixture_robo (271-280)
.vortex/tests/bats/unit/setup-ssh.bats (1)
.vortex/tests/bats/_helper.bash (3)
  • fixture_ssh_key_prepare (249-253)
  • fixture_ssh_key (255-258)
  • fixture_ssh_key_with_suffix (260-263)
.vortex/tests/bats/unit/download-db-lagoon.bats (1)
.vortex/tests/bats/_helper.bash (1)
  • fixture_ssh_key_prepare (249-253)
.vortex/tests/bats/unit/deploy-lagoon.bats (1)
.vortex/tests/bats/_helper.bash (2)
  • fixture_ssh_key_prepare (249-253)
  • fixture_ssh_key (255-258)
.vortex/tests/bats/unit/deploy-container-registry.bats (1)
.vortex/tests/bats/_helper.bash (1)
  • fixture_docker_config_file (265-269)
.vortex/tests/bats/unit/login-container-registry.bats (1)
.vortex/tests/bats/_helper.bash (1)
  • fixture_docker_config_file (265-269)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: build (0)
  • GitHub Check: build (1)
  • GitHub Check: vortex-test-workflow (2)
  • GitHub Check: vortex-test-workflow (4)
  • GitHub Check: vortex-test-workflow (3)
  • GitHub Check: vortex-test-workflow (0)
  • GitHub Check: vortex-test-workflow (1)
  • GitHub Check: vortex-test-common
  • GitHub Check: vortex-test-installer (8.3)
  • GitHub Check: vortex-test-installer (8.4)
  • GitHub Check: vortex-test-docs
🔇 Additional comments (41)
.vortex/tests/bats/_helper.bash (12)

30-30: LGTM!

Minor text update for clarity.


142-146: LGTM!

Consistent fixture-based naming applied in setup phase.


166-166: LGTM!

Teardown correctly updated to use the renamed restore function.


171-171: LGTM!

Header appropriately renamed to reflect fixture-oriented organization.


175-192: LGTM!

Clean rename from prepare_local_repo to fixture_local_repo with implementation unchanged.


194-196: LGTM!

Function renamed consistently with the fixture-based convention.


198-240: LGTM!

Function renamed consistently with the fixture-based convention.


242-247: LGTM!

Function renamed consistently with the fixture-based convention.


249-263: LGTM!

Well-structured SSH key fixture utilities that provide both default and customizable key generation.


265-269: LGTM!

Docker config fixture correctly creates mock authentication configuration.


271-280: LGTM!

Robo fixture properly sets up mock binaries for both robo and git-artifact.


282-296: LGTM!

New utility function git_init provides clean git repository initialization with optional push configuration.

.vortex/tests/bats/unit/download-db-lagoon.bats (3)

41-41: LGTM!

Fixture function renamed consistently with the new fixture-based convention.


94-94: LGTM!

Fixture function renamed consistently with the new fixture-based convention.


147-147: LGTM!

Fixture function renamed consistently with the new fixture-based convention.

.vortex/tests/bats/unit/deploy-lagoon.bats (10)

46-47: LGTM!

Fixture functions renamed consistently with the new fixture-based convention.


79-80: LGTM!

Fixture functions renamed consistently with the new fixture-based convention.


115-116: LGTM!

Fixture functions renamed consistently with the new fixture-based convention.


160-161: LGTM!

Fixture functions renamed consistently with the new fixture-based convention.


195-196: LGTM!

Fixture functions renamed consistently with the new fixture-based convention.


236-237: LGTM!

Fixture functions renamed consistently with the new fixture-based convention.


283-284: LGTM!

Fixture functions renamed consistently with the new fixture-based convention.


314-315: LGTM!

Fixture functions renamed consistently with the new fixture-based convention.


349-350: LGTM!

Fixture functions renamed consistently with the new fixture-based convention.


384-385: LGTM!

Fixture functions renamed consistently with the new fixture-based convention.

.vortex/tests/bats/unit/login-container-registry.bats (1)

36-36: LGTM!

Docker config fixture function renamed consistently with the new fixture-based convention.

.vortex/tests/bats/unit/deploy-artifact.bats (2)

26-26: LGTM!

Minor text improvement for clarity.


75-77: LGTM!

Fixture functions renamed consistently with the new fixture-based convention. The new names better reflect what each function does.

.vortex/tests/bats/unit/setup-ssh.bats (11)

17-17: LGTM!

Fixture function renamed consistently with the new fixture-based convention.


31-31: LGTM!

Fixture function renamed consistently with the new fixture-based convention.


47-47: LGTM!

Fixture function renamed consistently with the new fixture-based convention.


66-67: LGTM!

Fixture functions renamed consistently with the new fixture-based convention.


97-99: LGTM!

Fixture functions renamed consistently with the new fixture-based convention.


130-130: LGTM!

Fixture function renamed consistently with the new fixture-based convention.


152-155: LGTM!

Fixture functions renamed consistently with the new fixture-based convention.


186-191: LGTM!

Fixture functions renamed consistently with the new fixture-based convention.


226-231: LGTM!

Fixture functions renamed consistently with the new fixture-based convention.


267-269: LGTM!

Fixture functions renamed consistently with the new fixture-based convention.


303-305: LGTM!

Fixture functions renamed consistently with the new fixture-based convention.

.vortex/tests/bats/unit/deploy-container-registry.bats (2)

45-45: LGTM!

Docker config fixture function renamed consistently with the new fixture-based convention.


99-99: LGTM!

Docker config fixture function renamed consistently with the new fixture-based convention.

Comment on lines +8 to +17
setup_robo_fixture() {
export HOME="${BUILD_DIR}"
fixture_prepare_dir "${HOME}/.composer/vendor/bin"
touch "${HOME}/.composer/vendor/bin/robo"
chmod +x "${HOME}/.composer/vendor/bin/robo"

# Also create a mock for git-artifact
touch "${HOME}/.composer/vendor/bin/git-artifact"
chmod +x "${HOME}/.composer/vendor/bin/git-artifact"
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Remove duplicated fixture function.

This setup_robo_fixture() function duplicates fixture_robo() already defined in .vortex/tests/bats/_helper.bash (lines 271-280). The implementation is identical. For consistency with the fixture-based refactor across the test suite, use the centralized fixture_robo() function instead.

Apply this diff to remove the duplication:

-setup_robo_fixture() {
-  export HOME="${BUILD_DIR}"
-  fixture_prepare_dir "${HOME}/.composer/vendor/bin"
-  touch "${HOME}/.composer/vendor/bin/robo"
-  chmod +x "${HOME}/.composer/vendor/bin/robo"
-
-  # Also create a mock for git-artifact
-  touch "${HOME}/.composer/vendor/bin/git-artifact"
-  chmod +x "${HOME}/.composer/vendor/bin/git-artifact"
-}

Then call fixture_robo where needed (though I don't see it being called in the provided code segments, so you may need to verify if it's used elsewhere in this file).

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
.vortex/tests/bats/unit/deploy-container-registry.bats lines 8-17: the
setup_robo_fixture() function duplicates fixture_robo() defined in
.vortex/tests/bats/_helper.bash (lines 271-280); remove the entire
setup_robo_fixture() function from this file and replace any local calls to it
with a call to fixture_robo(), and then run a quick search in this test file to
ensure no other references remain (if none, no replacement is needed) so the
shared fixture from _helper.bash is used instead.

@codecov
Copy link

codecov bot commented Nov 1, 2025

Codecov Report

❌ Patch coverage is 92.59259% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.41%. Comparing base (2f93d51) to head (81d28b6).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
.vortex/tests/bats/_helper.bash 92.59% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           develop    #2076       +/-   ##
============================================
+ Coverage    51.87%   67.41%   +15.54%     
============================================
  Files           97       94        -3     
  Lines         5993     4610     -1383     
  Branches        44       44               
============================================
- Hits          3109     3108        -1     
+ Misses        2884     1502     -1382     

☔ View full report in Codecov by Sentry.
📢 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.

@AlexSkrypnyk AlexSkrypnyk merged commit 6e9c2be into develop Nov 1, 2025
28 checks passed
@AlexSkrypnyk AlexSkrypnyk deleted the feature/1560-cleanup-bats branch November 1, 2025 22:40
@github-project-automation github-project-automation bot moved this from BACKLOG to Release queue in Vortex Nov 1, 2025
@AlexSkrypnyk AlexSkrypnyk added this to the 25.10.0 milestone Nov 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Released in 25.10.0

Development

Successfully merging this pull request may close these issues.

Convert workflow BATS tests to PHPUnit tests

2 participants