Skip to content

test: Implement file based configuration for test environments#2512

Merged
chmouel merged 1 commit intotektoncd:mainfrom
chmouel:implement-file-based-config-for-test
Mar 2, 2026
Merged

test: Implement file based configuration for test environments#2512
chmouel merged 1 commit intotektoncd:mainfrom
chmouel:implement-file-based-config-for-test

Conversation

@chmouel
Copy link
Member

@chmouel chmouel commented Feb 26, 2026

📝 Description of the Change

This PR implements a YAML-based configuration mechanism for the E2E testing framework. The changes enable test engineers to define provider-specific settings in a single e2e-config.yaml file instead of managing numerous individual environment variables across different git providers (GitHub, GitLab, Bitbucket, Gitea, Forgejo).

Key Improvements

  • Centralized Configuration: Single YAML file (e2e-config.yaml) replaces scattered environment variables
  • Provider Flexibility: Supports all 7 git providers with provider-specific configuration sections
  • Environment Variable Precedence: Env vars can still override YAML values for selective testing needs
  • Automatic Loading: Configuration automatically loads when PAC_E2E_CONFIG env var is set
  • Comprehensive Testing: 227 lines of unit tests covering full YAML parsing, env var override, error handling, and edge cases

👨🏻‍ Linked Jira

🔗 Linked GitHub Issue

Fixes #1519

🚀 Type of Change

  • ✨ New feature (feat:)
  • 🐛 Bug fix (fix:)
  • 💥 Breaking change (feat!:, fix!:)
  • 📚 Documentation update (docs:)
  • ⚙️ Chore (chore:)
  • 💅 Refactor (refactor:)
  • 🔧 Enhancement (enhance:)
  • 📦 Dependency update (deps:)

🧪 Testing Strategy

  • Unit tests
  • Integration tests
  • End-to-end tests
  • Manual testing
  • Not Applicable

🤖 AI Assistance

  • I have not used any AI assistance for this PR.
  • I have used AI assistance for this PR.

If you have used AI assistance, please provide the following details:

Which LLM was used?

  • GitHub Copilot
  • ChatGPT (OpenAI)
  • Claude (Anthropic)
  • Cursor
  • Gemini (Google)
  • Other: ____________

Extent of AI Assistance:

  • Documentation and research only
  • Unit tests or E2E tests only
  • Code generation (parts of the code)
  • Full code generation (most of the PR)
  • PR description and comments
  • Commit message(s)

Important

If the majority of the code in this PR was generated by an AI, please add a Co-authored-by trailer to your commit message.
For example:

Co-authored-by: Gemini gemini@google.com
Co-authored-by: ChatGPT noreply@chatgpt.com
Co-authored-by: Claude noreply@anthropic.com
Co-authored-by: Cursor noreply@cursor.com
Co-authored-by: Copilot Copilot@users.noreply.github.com

**💡You can use the script ./hack/add-llm-coauthor.sh to automatically add
these co-author trailers to your commits.

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project's How to write a git commit message guide. The Gitlint linter ensures in CI it's properly validated
  • ✨ I have ensured my commit message prefix (e.g., fix:, feat:) matches the "Type of Change" I selected above.
  • ♽ I have run make test and make lint locally to check for and fix any issues. For an efficient workflow, I have considered installing pre-commit and running pre-commit install to automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

Added a yaml configuration mechanism for the testing framework to map
provider settings directly to environment variables. Excluded the
new execution entrypoint from naming validation checks since it
functioned as a harness. Using a structured file eliminated the overhead
of managing numerous separate variables across different git providers.
Retained environment variable precedence to allow selective overrides.

Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
Copilot AI review requested due to automatic review settings February 26, 2026 19:52
@gemini-code-assist
Copy link

Summary of Changes

Hello @chmouel, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the end-to-end testing framework by implementing a file-based YAML configuration mechanism. This change streamlines the management of test environment settings for various providers, reducing the need to juggle numerous individual environment variables. The new system prioritizes existing environment variables, allowing for seamless integration and selective overrides, while also refining test naming conventions to properly account for test harness functions.

Highlights

  • YAML-based E2E Test Configuration: Introduced a new YAML-based configuration system for end-to-end tests, allowing test environment settings for various providers (GitHub, GitLab, Gitea, Bitbucket) to be defined in a structured file.
  • Environment Variable Precedence: Implemented logic where existing environment variables take precedence over values specified in the YAML configuration, providing flexibility for selective overrides, especially useful for CI secrets.
  • Refined Test Naming Validation: Updated the E2E test naming validation script to explicitly exclude TestMain functions, recognizing them as test harnesses rather than individual tests that require specific naming conventions.
Changelog
  • hack/check-e2e-test-naming.sh
    • Modified the script to exclude TestMain functions from the E2E test naming convention checks.
  • test/README.md
    • Added a new section detailing how to use the YAML configuration file for E2E tests.
    • Provided instructions on setting PAC_E2E_CONFIG and copying the example file.
    • Clarified that environment variables override YAML values.
  • test/e2e-config.yaml.example
    • Added a new example YAML file outlining the structure for E2E test configurations across different providers (common, GitHub, GitLab, Gitea, Bitbucket).
  • test/main_test.go
    • Added a TestMain function that loads the E2E configuration from the path specified by PAC_E2E_CONFIG environment variable, if set.
  • test/pkg/configfile/config.go
    • Created a new package configfile with Go structs to represent the E2E configuration for various providers.
    • Implemented LoadConfig function to read a YAML file, unmarshal it into the E2EConfig struct, and set corresponding environment variables, respecting existing env var precedence.
    • Added setEnvsFromStruct helper function to recursively process struct fields and set environment variables based on env tags.
  • test/pkg/configfile/config_test.go
    • Added comprehensive unit tests for the configfile package, covering valid configuration loading, environment variable overrides, missing files, partial configurations, invalid YAML, and loading all provider settings.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a YAML-based configuration mechanism for E2E tests, allowing provider settings to be loaded from a single file and mapped into the existing TEST_* environment variables while keeping env-var precedence for overrides.

Changes:

  • Introduce test/pkg/configfile with YAML parsing and env-var export logic, plus unit tests.
  • Add an E2E-only TestMain entrypoint to optionally load config from PAC_E2E_CONFIG.
  • Document the new config flow and provide an example e2e-config.yaml.example; update naming-check script to ignore TestMain.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/pkg/configfile/config.go Implements YAML load + reflection-based env-var population for E2E provider settings.
test/pkg/configfile/config_test.go Adds unit tests for valid config, env override, missing file, partial config, invalid YAML, and all-providers coverage.
test/main_test.go Adds TestMain (build-tagged e2e) to load config from PAC_E2E_CONFIG before running tests.
test/e2e-config.yaml.example Provides a template YAML config file documenting all supported provider sections/fields.
test/README.md Documents using PAC_E2E_CONFIG and the YAML config file approach.
hack/check-e2e-test-naming.sh Excludes TestMain from E2E test naming validation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a convenient file-based configuration system for the e2e tests, which is a great improvement for managing test environments. The implementation uses a TestMain entrypoint to load a YAML file and populate environment variables, with existing environment variables taking precedence. The code is well-structured and includes comprehensive unit tests.

I have a couple of suggestions to improve the robustness and clarity of the new configuration loading logic. My main points are about making the reflection-based logic safer for future changes and improving the readability and reliability of the test setup code, especially concerning environment variable management to prevent flaky tests. Overall, this is a solid contribution.

@chmouel chmouel merged commit e83a17f into tektoncd:main Mar 2, 2026
12 checks passed
@chmouel chmouel deleted the implement-file-based-config-for-test branch March 2, 2026 13:10
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.

Let be able to specify a YAML file for e2e testing

3 participants