Skip to content

Fixed coding standards in workflow and installer tests.#2139

Merged
AlexSkrypnyk merged 2 commits into
developfrom
feature/workflow-tests-udpate-cs
Dec 1, 2025
Merged

Fixed coding standards in workflow and installer tests.#2139
AlexSkrypnyk merged 2 commits into
developfrom
feature/workflow-tests-udpate-cs

Conversation

@AlexSkrypnyk

@AlexSkrypnyk AlexSkrypnyk commented Dec 1, 2025

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Tests
    • Improved CI test reliability with stronger input validation, defensive error handling, and stricter validation of API responses, test metadata, and artifact data.
  • Style
    • Standardized parameter and variable naming across tests and helpers (camelCase → snake_case).
  • Refactor
    • Increased robustness via stricter type safety and validation in test helper logic.
  • Chores
    • CI workflow: added a pre-test lint step and adjusted tooling configuration to suppress a specific formatting rule; minor formatting cleanup.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 1, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

Refactors Rector configs to skip NewlineBetweenClassLikeStmtsRector; renames many test variables and CircleCiTrait parameters to snake_case; hardens CircleCI API methods with environment checks, JSON/structure validation, and explicit errors; adds a CI "Lint code" step running phpcs/phpstan/rector in the tests directory.

Changes

Cohort / File(s) Summary
Rector configuration
\.vortex/installer/rector.php, \.vortex/tests/rector.php
Added use Rector\CodingStyle\Rector\ClassLike\NewlineBetweenClassLikeStmtsRector; and added NewlineBetweenClassLikeStmtsRector::class to the Rector skip lists; minor formatting tweak.
Post-build tests (variable renames)
\.vortex/tests/phpunit/Functional/PostBuildTest.php
Renamed many local/test variables from camelCase to snake_case (e.g., previousJobNumbersprevious_job_numbers, artifactsDataartifacts_data, artifactPathsRunner0artifact_paths_runner0) and updated corresponding references; behavior unchanged.
CircleCI trait (API validation & renames)
\.vortex/tests/phpunit/Traits/CircleCiTrait.php
Renamed method parameters and helper args to snake_case; added env-var presence checks, JSON decode and shape validation, stricter type guards, explicit RuntimeExceptions for malformed/empty responses, and defensive per-item validation in artifact/test extraction helpers.
CI workflow
.github/workflows/vortex-test-common.yml
Inserted a "Lint code" step after dependencies install that runs phpcs, phpstan, and rector --dry-run in .vortex/tests with MEMORY_LIMIT=-1.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Test as PostBuildTest
  participant Trait as CircleCiTrait
  participant API as CircleCI API

  Test->>Trait: circleCiGetWorkflowIdFromJobNumber(job_number)
  Trait->>Trait: validate env (token, project info)
  Trait->>API: GET /project/.../job/{job_number} (Authorization)
  API-->>Trait: 200 + JSON
  Trait->>Trait: decode JSON, validate shape, extract workflow_id
  Trait-->>Test: return workflow_id

  alt fetch previous jobs
    Test->>Trait: circleCiGetPreviousJobNumbers(current_job_number)
    Trait->>API: GET /workflow/{workflow_id}/job
    API-->>Trait: 200 + JSON (jobs, dependencies)
    Trait->>Trait: validate, map dependency ids -> job_numbers
    Trait-->>Test: return previous_job_numbers
  end

  alt fetch artifacts & tests
    Test->>Trait: circleCiGetJobArtifacts(job_number)
    Trait->>API: GET /job/{job_number}/artifacts
    API-->>Trait: 200 + JSON (artifacts list)
    Trait->>Trait: validate artifacts_data, extract artifact_paths
    Trait-->>Test: return artifact_paths

    Test->>Trait: circleCiGetJobTestMetadata(job_number)
    Trait->>API: GET /job/{job_number}/tests
    API-->>Trait: 200 + JSON (tests list)
    Trait->>Trait: validate tests_data, extract test_paths
    Trait-->>Test: return test_paths
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

  • Pay extra attention to: \.vortex/tests/phpunit/Traits/CircleCiTrait.php (validation branches, thrown RuntimeExceptions, and new parameter names).
  • Verify all call sites and tests use the updated snake_case parameter/variable names (PostBuildTest.php and any other test helpers).
  • Confirm Rector skip changes are applied consistently in both rector config files and do not conflict with other rules.

Possibly related PRs

Suggested labels

AUTOMERGE

Poem

🐇 I nibbled code with careful hops,

snake_case footprints on tiny ops.
Tokens checked, JSON peeled with care,
artifacts found and tests laid bare.
A happy hop — the CI breathes air.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the main changes: enforcing coding standards through Rector configuration updates, variable renaming to snake_case, and adding a new linting workflow step.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8e2c6ee and f2a4975.

📒 Files selected for processing (2)
  • .github/workflows/vortex-test-common.yml (1 hunks)
  • .vortex/tests/phpunit/Functional/PostBuildTest.php (2 hunks)

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

@github-actions github-actions Bot temporarily deployed to commit December 1, 2025 04:20 Inactive

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 87ad5aa and 342bdce.

⛔ Files ignored due to path filters (2)
  • .vortex/installer/composer.lock is excluded by !**/*.lock
  • .vortex/tests/composer.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • .vortex/installer/rector.php (2 hunks)
  • .vortex/tests/phpunit/Functional/PostBuildTest.php (2 hunks)
  • .vortex/tests/phpunit/Traits/CircleCiTrait.php (4 hunks)
  • .vortex/tests/rector.php (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-01T08:10:15.903Z
Learnt from: AlexSkrypnyk
Repo: drevops/vortex PR: 1693
File: .vortex/installer/src/Prompts/Handlers/Internal.php:52-52
Timestamp: 2025-06-01T08:10:15.903Z
Learning: The File utility class in .vortex/installer/src/Utils/File.php extends AlexSkrypnyk\File\File, and methods like collapseRepeatedEmptyLines() are available from this external parent class dependency.

Applied to files:

  • .vortex/tests/rector.php
🧬 Code graph analysis (1)
.vortex/tests/phpunit/Functional/PostBuildTest.php (1)
.vortex/tests/phpunit/Traits/CircleCiTrait.php (5)
  • circleCiGetPreviousJobNumbers (60-114)
  • circleCiGetJobArtifacts (125-150)
  • circleCiExtractArtifactPaths (237-255)
  • circleCiGetJobTestMetadata (161-186)
  • circleCiExtractTestPaths (266-286)
⏰ 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 (1)
  • GitHub Check: build (0)
  • GitHub Check: vortex-test-installer (8.3)
  • GitHub Check: vortex-test-installer (8.4)
  • GitHub Check: vortex-test-workflow (3)
  • GitHub Check: vortex-test-workflow (2)
  • GitHub Check: vortex-test-workflow (1)
  • GitHub Check: vortex-test-workflow (0)
  • GitHub Check: vortex-test-common
  • GitHub Check: vortex-test-workflow (4)
  • GitHub Check: vortex-test-docs
🔇 Additional comments (10)
.vortex/tests/rector.php (2)

17-17: LGTM!

The import is correctly added and properly ordered among other CodingStyle imports.


54-54: LGTM!

The skip rule is correctly added in alphabetical order, aligning with project coding standards.

.vortex/installer/rector.php (1)

19-19: LGTM!

The import and skip rule additions mirror the changes in .vortex/tests/rector.php, maintaining consistent Rector configuration across test and installer directories.

Also applies to: 60-60

.vortex/tests/phpunit/Functional/PostBuildTest.php (1)

56-57: LGTM!

All other variable renames correctly follow snake_case conventions and align with the updated CircleCiTrait method signatures.

Also applies to: 62-62, 65-66, 77-78, 99-100, 105-107

.vortex/tests/phpunit/Traits/CircleCiTrait.php (6)

60-114: LGTM!

Excellent improvements to input validation and error handling. The method now:

  • Validates required environment variables
  • Checks API response structure at multiple levels
  • Handles malformed data gracefully
  • Provides clear error messages

The refactoring significantly improves robustness.


125-150: LGTM!

The parameter rename and added validation follow the same robust pattern as other methods in this trait.


161-186: LGTM!

Consistent validation pattern applied, improving method robustness.


199-224: LGTM!

Excellent improvements to error handling:

  • Input validation for URL and token
  • HTTP status code checking
  • Explicit handling of curl failures
  • Clear error messages with context

These changes make API interactions much more reliable and debuggable.


237-255: LGTM!

The parameter renames and added validation make this method more robust:

  • Early return for invalid data
  • Per-item validation before property access
  • Strict equality check for node_index

266-286: LGTM!

Excellent data validation:

  • Early return for invalid structure
  • Per-item array validation
  • Explicit string type check for file field

This prevents type errors and ensures the method returns clean data.

Comment thread .vortex/tests/phpunit/Functional/PostBuildTest.php Outdated
Comment thread .vortex/tests/phpunit/Functional/PostBuildTest.php Outdated
Comment on lines +44 to +46
if (empty($data['latest_workflow'] ?? []) || (is_array($data['latest_workflow']) && empty($data['latest_workflow']['id'] ?? ''))) {
throw new \RuntimeException('Unable to retrieve workflow ID from CircleCI API response.');
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider simplifying the validation logic.

The current validation works but is more complex than necessary. The condition checks both if latest_workflow is empty and if the id within it is empty, which can be simplified.

Apply this diff to simplify:

-    if (empty($data['latest_workflow'] ?? []) || (is_array($data['latest_workflow']) && empty($data['latest_workflow']['id'] ?? ''))) {
+    if (empty($data['latest_workflow']['id'] ?? '')) {
       throw new \RuntimeException('Unable to retrieve workflow ID from CircleCI API response.');
     }

This simplified version checks the same condition: whether the workflow ID exists and is non-empty.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (empty($data['latest_workflow'] ?? []) || (is_array($data['latest_workflow']) && empty($data['latest_workflow']['id'] ?? ''))) {
throw new \RuntimeException('Unable to retrieve workflow ID from CircleCI API response.');
}
if (empty($data['latest_workflow']['id'] ?? '')) {
throw new \RuntimeException('Unable to retrieve workflow ID from CircleCI API response.');
}
🤖 Prompt for AI Agents
.vortex/tests/phpunit/Traits/CircleCiTrait.php around lines 44 to 46: the
validation is overly verbose; replace the two-part condition with a single check
that the workflow ID exists and is non-empty by testing
empty($data['latest_workflow']['id'] ?? ''), and throw the same RuntimeException
when that check fails.

@codecov

codecov Bot commented Dec 1, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.89%. Comparing base (87ad5aa) to head (f2a4975).
⚠️ Report is 3 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2139   +/-   ##
========================================
  Coverage    70.89%   70.89%           
========================================
  Files           99       99           
  Lines         5075     5075           
  Branches        44       44           
========================================
  Hits          3598     3598           
  Misses        1477     1477           

☔ 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 force-pushed the feature/workflow-tests-udpate-cs branch from 17f82b9 to f68f0b7 Compare December 1, 2025 04:43
@github-actions github-actions Bot temporarily deployed to commit December 1, 2025 04:45 Inactive
@AlexSkrypnyk AlexSkrypnyk force-pushed the feature/workflow-tests-udpate-cs branch from f68f0b7 to a4c1121 Compare December 1, 2025 04:47
@github-actions github-actions Bot temporarily deployed to commit December 1, 2025 04:49 Inactive

@coderabbitai coderabbitai Bot 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.

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 342bdce and a4c1121.

📒 Files selected for processing (1)
  • .github/workflows/vortex-test-common.yml (1 hunks)
⏰ 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). (5)
  • GitHub Check: build (0)
  • GitHub Check: build (1)
  • GitHub Check: vortex-test-common
  • GitHub Check: vortex-test-installer (8.4)
  • GitHub Check: vortex-test-installer (8.3)

Comment on lines +162 to +165
- name: Lint code
run: php -d memory_limit=-1 $(which composer) lint
working-directory: .vortex/tests

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Simplify the Composer command invocation.

The new lint step is a good addition that aligns with the PR's coding standards objectives. However, line 163 uses $(which composer) when just composer is more idiomatic, since Composer should already be in the PATH after the install step on line 159.

Apply this diff to simplify the command:

-        run: php -d memory_limit=-1 $(which composer) lint
+        run: php -d memory_limit=-1 composer lint
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Lint code
run: php -d memory_limit=-1 $(which composer) lint
working-directory: .vortex/tests
- name: Lint code
run: php -d memory_limit=-1 composer lint
working-directory: .vortex/tests
🤖 Prompt for AI Agents
.github/workflows/vortex-test-common.yml around lines 162 to 165: the lint step
currently invokes Composer via $(which composer); replace that with the simpler,
idiomatic composer invocation so the run line becomes "php -d memory_limit=-1
composer lint" (keeping working-directory .vortex/tests unchanged).

@AlexSkrypnyk AlexSkrypnyk force-pushed the feature/workflow-tests-udpate-cs branch from a4c1121 to 8e2c6ee Compare December 1, 2025 04:52
@github-actions github-actions Bot temporarily deployed to commit December 1, 2025 04:54 Inactive
@AlexSkrypnyk AlexSkrypnyk force-pushed the feature/workflow-tests-udpate-cs branch from 8e2c6ee to f2a4975 Compare December 1, 2025 05:02
@AlexSkrypnyk AlexSkrypnyk merged commit 0e109c4 into develop Dec 1, 2025
8 of 14 checks passed
@AlexSkrypnyk AlexSkrypnyk deleted the feature/workflow-tests-udpate-cs branch December 1, 2025 05:03
@github-project-automation github-project-automation Bot moved this from BACKLOG to Release queue in Vortex 1.x Dec 1, 2025
@github-actions github-actions Bot temporarily deployed to commit December 1, 2025 05:04 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant