Skip to content

test: enable integration tests to load GITHUB_TOKEN from .env#40

Merged
petems merged 2 commits intomasterfrom
test/enable-integration-tests-with-dotenv
Oct 17, 2025
Merged

test: enable integration tests to load GITHUB_TOKEN from .env#40
petems merged 2 commits intomasterfrom
test/enable-integration-tests-with-dotenv

Conversation

@petems
Copy link
Copy Markdown
Owner

@petems petems commented Oct 16, 2025

Summary

Enables integration tests to automatically load environment variables from .env file, allowing the TestRealGitHubIntegration test suite to run when a valid GITHUB_TOKEN is available.

Changes

  • Added load_dotenv() call in tests/conftest.py
  • Integration tests now read credentials from .env file automatically
  • Previously 2 integration tests were skipped; now they run when token is available

Impact

  • Local Development: Developers can now run integration tests by adding GITHUB_TOKEN to their .env file
  • CI/CD: Integration tests can be enabled in CI by providing appropriate secrets
  • Test Coverage: Changes test count from 166 passed + 2 skipped → 168 passed (when token available)

Testing

Verified that:

Related

This change complements the Phase 2 implementation in #38 but is independent and can be merged separately.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Test setup now loads environment variables from configuration files, allowing integration and environment-dependent tests to run with configured settings during test execution. This improves test reliability and simplifies local and CI test setup.

- Import and call load_dotenv() in tests/conftest.py
- Allows integration tests to read credentials from .env file
- Previously, 2 integration tests were skipped due to missing token
- Now all 181 tests can run when .env file contains valid GITHUB_TOKEN

This change enables local development and CI/CD to run integration
tests against real GitHub API when appropriate credentials are available.
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @petems, 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 streamlines the execution of integration tests by enabling the automatic loading of environment variables from a .env file. This specifically addresses the need for a GITHUB_TOKEN to run real GitHub integration tests, making it easier for developers to run these tests locally and for CI/CD pipelines to provide necessary credentials, ultimately improving test coverage and reliability for GitHub-related functionalities.

Highlights

  • Environment Variable Loading: Integration tests are now configured to automatically load environment variables from a .env file, simplifying local development and CI/CD setup.
  • Integration Test Enablement: The TestRealGitHubIntegration test suite, which previously skipped tests due to missing GITHUB_TOKEN, can now run successfully when a valid token is provided in the .env file.
  • Test Coverage Improvement: This change allows two previously skipped integration tests to execute, increasing the total number of passing tests from 166 to 168 when the GITHUB_TOKEN is available.
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.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Oct 16, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

The test configuration file tests/conftest.py now imports load_dotenv from the dotenv package and calls it during test setup to load environment variables from a .env file for tests.

Changes

Cohort / File(s) Summary
Test Configuration
tests/conftest.py
Added load_dotenv import and load_dotenv() invocation to initialize environment variables from a .env file during test setup

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 I sniffed the .env and gave a hop,
Secrets tucked in, the tests won't stop.
A tiny load, a gentle cheer,
Integration runs now draw near.
зайчик-approved, we debug with cheer.

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 title clearly and concisely describes the main change, namely enabling integration tests to load the GITHUB_TOKEN from a .env file, and uses standard commit message conventions without extraneous detail. It accurately reflects the addition of load_dotenv in tests/conftest.py to support running previously skipped tests when a token is available.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ 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 test/enable-integration-tests-with-dotenv

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c868e9f and 83f4f07.

📒 Files selected for processing (1)
  • tests/conftest.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
tests/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

Use pytest for all tests, including async tests with shared fixtures in tests/conftest.py; avoid live GitHub calls by default (integration tests are token-gated)

tests/**/*.py: Name test functions test_*
Use pytest-asyncio for async test functions
Mock external dependencies (GitHub API, filesystem) in tests

Files:

  • tests/conftest.py
tests/conftest.py

📄 CodeRabbit inference engine (CLAUDE.md)

Place shared pytest fixtures (HTTP client mock, git context, temp dirs, timeouts) in tests/conftest.py

Common pytest fixtures should reside in tests/conftest.py

Files:

  • tests/conftest.py
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.py: Format Python code with Ruff (ruff format) using a line length of 88 characters
Fix lint issues with Ruff (ruff check --fix), including security (bandit) and import sorting rules
Ensure static typing passes with mypy for Python 3.10+

**/*.py: Code must pass ruff linting with zero violations
Code must be formatted with ruff format
Use type hints for all function parameters and return values
Follow async/await patterns for I/O operations (GitHub API calls, file ops)
Handle errors gracefully with proper logging to stderr
Implement retry logic for transient failures honoring HTTP_MAX_RETRIES
Validate all input parameters (URLs, filenames, numeric limits)
Use safe file operations (e.g., exclusive create, path validation) for writing files
Return meaningful error messages to MCP clients

Files:

  • tests/conftest.py
🧠 Learnings (1)
📚 Learning: 2025-10-05T19:32:53.476Z
Learnt from: CR
PR: cool-kids-inc/github-pr-review-mcp-server#0
File: AGENTS.md:0-0
Timestamp: 2025-10-05T19:32:53.476Z
Learning: Applies to tests/**/*.py : Mock external dependencies (GitHub API, filesystem) in tests

Applied to files:

  • tests/conftest.py
🔇 Additional comments (1)
tests/conftest.py (1)

25-26: Implementation approved; confirm integration tests exist.

  • python-dotenv is listed in project dependencies and .env is ignored.
  • No tests reference GITHUB_TOKEN; please add or confirm integration tests that exercise the real GitHub API using the environment token.

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@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 enables integration tests to load environment variables from a .env file by adding python-dotenv. The change is straightforward and correctly implemented in tests/conftest.py. This is a good improvement for local development, allowing developers to run integration tests that require secrets like GITHUB_TOKEN easily. My review includes one minor suggestion to align with the project's import ordering style.

Comment thread tests/conftest.py
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@petems petems merged commit 28afc86 into master Oct 17, 2025
10 checks passed
petems added a commit that referenced this pull request Jan 28, 2026
* test: enable integration tests to load GITHUB_TOKEN from .env

- Import and call load_dotenv() in tests/conftest.py
- Allows integration tests to read credentials from .env file
- Previously, 2 integration tests were skipped due to missing token
- Now all 181 tests can run when .env file contains valid GITHUB_TOKEN

This change enables local development and CI/CD to run integration
tests against real GitHub API when appropriate credentials are available.

* Apply suggestion from @gemini-code-assist[bot]

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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.

1 participant