Skip to content

[#2796] Covered 'ENVIRONMENT_TYPE' in test isolation and container runtime. - #2803

Merged
AlexSkrypnyk merged 8 commits into
mainfrom
feature/2796-env-type-allowlist
Jul 16, 2026
Merged

[#2796] Covered 'ENVIRONMENT_TYPE' in test isolation and container runtime.#2803
AlexSkrypnyk merged 8 commits into
mainfrom
feature/2796-env-type-allowlist

Conversation

@AlexSkrypnyk

@AlexSkrypnyk AlexSkrypnyk commented Jul 16, 2026

Copy link
Copy Markdown
Member

Closes #2796

Summary

The DRUPAL_ENVIRONMENT to ENVIRONMENT_TYPE rename in 1.40 left ENVIRONMENT_TYPE outside two prefix-based allowlists that previously caught it via the DRUPAL_ prefix. A host- or CI-set ENVIRONMENT_TYPE leaked into PHPUnit settings tests that do not set it explicitly, making environment assertions host-dependent, and ENVIRONMENT_TYPE overrides were no longer forwarded into the cli/php/nginx containers at runtime. This PR closes both gaps.

Changes

Test isolation

  • Added ENVIRONMENT_TYPE to SettingsTestCase::ALLOWED_ENV_VARS (tests/phpunit/Drupal/SettingsTestCase.php), so a host-set value is cleared between settings test cases.

Runtime passthrough

  • .ahoy.yml: added the ENVIRONMENT_ prefix to the ahoy cli/ahoy shell environment-forwarding grep pattern (alongside DRUPAL_, VORTEX_, etc.), so an ENVIRONMENT_TYPE override set on the host reaches the cli container.
  • docker-compose.yml: added ENVIRONMENT_TYPE: ${ENVIRONMENT_TYPE:-} to the shared &default-environment anchor, so every service built on it also receives the override.

Tests

  • Extended .vortex/tests/phpunit/Traits/Subtests/SubtestAhoyTrait::subtestAhoyCli() to assert that ahoy cli forwards a host ENVIRONMENT_TYPE into the container. This lives in the template's own test suite (.vortex/tests/), which is not shipped to consumer projects. The docker-compose.yml passthrough is covered by DockerComposeTest and its regenerated fixtures.

Regenerated fixtures

  • Installer handler_process fixtures under .vortex/installer/tests/Fixtures/handler_process/** (docker-compose.yml, .ahoy.yml, SettingsTestCase.php) regenerated via ahoy update-snapshots to match the source changes above.
  • .vortex/tests/phpunit/Fixtures/docker-compose.env*.json fixtures regenerated to include the new ENVIRONMENT_TYPE key in the expected container environment output.

Screenshots

N/A - this change is non-visual (test infrastructure and environment variable passthrough only).

Before / After

BEFORE: ENVIRONMENT_TYPE falls through both allowlists
────────────────────────────────────────────────────────

Host / CI shell
  ENVIRONMENT_TYPE=prod
          │
          ├──▶ SettingsTestCase::ALLOWED_ENV_VARS
          │     [VORTEX_, DRUPAL_, ...]               ✗ no match → value leaks
          │                                               into every test case
          │
          └──▶ .ahoy.yml `cli` grep filter
                TERM|COMPOSE_|...|DRUPAL_|VORTEX_     ✗ no match → dropped,
                          │                               never reaches container
                          ▼
                 docker-compose.yml
                 &default-environment                 ✗ no ENVIRONMENT_TYPE key,
                 (CI, XDEBUG_ENABLE, TZ, ...)             even if forwarded


AFTER: ENVIRONMENT_TYPE is isolated in tests, passed through at runtime
────────────────────────────────────────────────────────────────────────

Host / CI shell
  ENVIRONMENT_TYPE=prod
          │
          ├──▶ SettingsTestCase::ALLOWED_ENV_VARS
          │     [VORTEX_, DRUPAL_, ENVIRONMENT_TYPE]   ✓ cleared between cases,
          │                                                cannot leak into others
          │
          └──▶ .ahoy.yml `cli` grep filter
                ...|DRUPAL_|VORTEX_|ENVIRONMENT_       ✓ matched → forwarded
                          │                                as `-e ENVIRONMENT_TYPE`
                          ▼
                 docker-compose.yml
                 &default-environment                  ✓ ENVIRONMENT_TYPE:
                 (CI, ENVIRONMENT_TYPE, XDEBUG_ENABLE)     ${ENVIRONMENT_TYPE:-}

@github-project-automation github-project-automation Bot moved this to BACKLOG in Vortex 1.x Jul 16, 2026
@AlexSkrypnyk AlexSkrypnyk added this to the 1.41.0 milestone Jul 16, 2026
@AlexSkrypnyk AlexSkrypnyk added the A1 Board worker 1 label Jul 16, 2026
@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The compose setup now supports explicit ENVIRONMENT_TYPE propagation across CLI and services. PHPUnit environment handling clears host-provided values between tests, with regression coverage and updated compose fixtures.

Changes

Compose environment propagation

Layer / File(s) Summary
Compose variable wiring and fixtures
.ahoy.yml, docker-compose.yml, .vortex/tests/phpunit/Fixtures/docker-compose.*.json
ENVIRONMENT_TYPE is forwarded to CLI containers, exposed through the shared compose environment, and represented in service environment fixtures.
PHPUnit environment isolation
tests/phpunit/Drupal/SettingsTestCase.php, tests/phpunit/Drupal/EnvironmentSettingsTest.php
The test allowlist clears ENVIRONMENT_TYPE, and regression coverage verifies host values do not affect settings cases that omit it.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Poem

A bunny passed a variable through,
Compose carried it safely too.
Tests cleared hosts from the trail,
So settings stay steady without fail.
Hop, hop—clean values prevail!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The allowlist update and regression test directly address #2796 by ensuring ENVIRONMENT_TYPE is cleared between settings tests.
Out of Scope Changes check ✅ Passed The remaining fixture and container updates align with the stated PR objectives and do not appear unrelated.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: ENVIRONMENT_TYPE support in test isolation and container runtime.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/2796-env-type-allowlist

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

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/phpunit/Drupal/SettingsTestCase.php`:
- Around line 76-78: Update getRealEnvVarsFilteredNoValues() so ENVIRONMENT_TYPE
is matched only as an exact environment-variable name, while the other allowlist
entries retain their existing prefix matching behavior. Keep the test’s intent
and comment aligned with this separate exact-name handling, preventing matches
such as ENVIRONMENT_TYPE_FOO.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 790d5d18-2615-41b9-8aad-df8c114a9d11

📥 Commits

Reviewing files that changed from the base of the PR and between 0cbb0f8 and 51fdbd1.

⛔ Files ignored due to path filters (31)
  • .vortex/installer/tests/Fixtures/handler_process/_baseline/.ahoy.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/_baseline/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/_baseline/tests/phpunit/Drupal/EnvironmentSettingsTest.php is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/_baseline/tests/phpunit/Drupal/SettingsTestCase.php is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/custom_modules_search_without_solr/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/hosting_acquia/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/hosting_acquia/tests/phpunit/Drupal/SettingsTestCase.php is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/hosting_lagoon/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/hosting_project_name___acquia/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/hosting_project_name___acquia/tests/phpunit/Drupal/SettingsTestCase.php is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/hosting_project_name___lagoon/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_disabled_lagoon/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_enabled/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_enabled_circleci/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_enabled_lagoon/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_fetch_source_acquia/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_fetch_source_container_registry/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_fetch_source_ftp/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_fetch_source_lagoon/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_fetch_source_s3/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/migration_fetch_source_url/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/modules_no_seckit_shield_stage_file_proxy/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/modules_no_shield/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/modules_none/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/non_interactive_config_file/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/non_interactive_config_string/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/provision_database_lagoon/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/services_no_clamav/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/services_no_redis/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/services_no_solr/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
  • .vortex/installer/tests/Fixtures/handler_process/services_none/docker-compose.yml is excluded by !.vortex/installer/tests/Fixtures/**
📒 Files selected for processing (8)
  • .ahoy.yml
  • .vortex/tests/phpunit/Fixtures/docker-compose.env.json
  • .vortex/tests/phpunit/Fixtures/docker-compose.env_local.json
  • .vortex/tests/phpunit/Fixtures/docker-compose.env_mod.json
  • .vortex/tests/phpunit/Fixtures/docker-compose.noenv.json
  • docker-compose.yml
  • tests/phpunit/Drupal/EnvironmentSettingsTest.php
  • tests/phpunit/Drupal/SettingsTestCase.php

Comment thread tests/phpunit/Drupal/SettingsTestCase.php Outdated
@AlexSkrypnyk

This comment has been minimized.

@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

1 similar comment
@AlexSkrypnyk

This comment has been minimized.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

📖 Documentation preview for this pull request has been deployed to Netlify:

https://6a5886c17526f8d8a6e80c18--vortex-docs.netlify.app

This preview is rebuilt on every commit and is not the production documentation site.

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.27%. Comparing base (0cbb0f8) to head (dfa42ce).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2803      +/-   ##
==========================================
- Coverage   86.71%   86.27%   -0.44%     
==========================================
  Files          97       90       -7     
  Lines        4757     4598     -159     
  Branches       47        3      -44     
==========================================
- Hits         4125     3967     -158     
+ Misses        632      631       -1     

☔ 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.

@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

2 similar comments
@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk AlexSkrypnyk added the Needs review Pull request needs a review from assigned developers label Jul 16, 2026
@github-actions

Copy link
Copy Markdown

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   98.55% (204/207)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@AlexSkrypnyk

This comment has been minimized.

2 similar comments
@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk

Copy link
Copy Markdown
Member Author

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   98.55% (204/207)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@AlexSkrypnyk
AlexSkrypnyk merged commit 1d321be into main Jul 16, 2026
34 checks passed
@AlexSkrypnyk
AlexSkrypnyk deleted the feature/2796-env-type-allowlist branch July 16, 2026 07:47
@github-project-automation github-project-automation Bot moved this from BACKLOG to Release queue in Vortex 1.x Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A1 Board worker 1 Needs review Pull request needs a review from assigned developers

Projects

Status: Release queue

Development

Successfully merging this pull request may close these issues.

Tests: SettingsTestCase::ALLOWED_ENV_VARS does not cover 'ENVIRONMENT_TYPE'

1 participant