Skip to content

Instead of os.environ use os.getenv#227

Merged
phracek merged 3 commits intomasterfrom
fix_get_environment
Mar 31, 2026
Merged

Instead of os.environ use os.getenv#227
phracek merged 3 commits intomasterfrom
fix_get_environment

Conversation

@phracek
Copy link
Copy Markdown
Member

@phracek phracek commented Mar 31, 2026

Bump version to 0.9.0

Summary by CodeRabbit

  • Chores

    • Updated daily tests image version to 0.9.0
  • Refactor

    • Improved environment-variable handling for nightly test configuration
    • Fixed parsing of the email send toggle and resolved environment-based URL/mail lookups to behave predictably

Bump version to 0.9.0

Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.69%. Comparing base (51e6765) to head (cbf8294).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #227       +/-   ##
===========================================
+ Coverage   35.50%   50.69%   +15.18%     
===========================================
  Files           7        7               
  Lines        1011     1006        -5     
===========================================
+ Hits          359      510      +151     
+ Misses        652      496      -156     
Flag Coverage Δ
daily-tests-unit 44.26% <100.00%> (+18.02%) ⬆️
ocp-stream-generator-unit 84.47% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ly-tests/daily_tests/daily_nightly_tests_report.py 54.71% <100.00%> (+54.71%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

Warning

Rate limit exceeded

@phracek has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 12 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 17 minutes and 12 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 18f17a3d-e1aa-4050-afd9-f4bd9349c4b7

📥 Commits

Reviewing files that changed from the base of the PR and between 966a721 and cbf8294.

📒 Files selected for processing (2)
  • daily-tests/tests/test_reports.py
  • daily-tests/tox.ini
📝 Walkthrough

Walkthrough

Updated upstream daily-tests image version from 0.8.11 to 0.9.0 in CI/build files and refactored environment-variable handling in the nightly test reporter: added _get_env_variable, switched many reads to os.getenv(...), and changed how SEND_EMAIL is parsed/assigned.

Changes

Cohort / File(s) Summary
Build configuration
.github/workflows/build-and-push.yml, Dockerfile.daily-tests, Makefile
Bumped upstream daily-tests image version tag from 0.8.110.9.0 (workflow tag, RELEASE_UPSTREAM ENV, and image build tag).
Test reporting module
daily-tests/daily_tests/daily_nightly_tests_report.py
Added NightlyTestsReport._get_env_variable(...); replaced direct os.environ[...] checks with os.getenv(...) calls for mail lists, SMTP, and URLs; changed SEND_EMAIL parsing to bool(os.getenv("SEND_EMAIL", "False")) and removed unconditional override.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

ready for review

Poem

🐰 Hopped a tag from eight to nine,
Env vars tidy, parsing fine,
I added a helper, split the mail,
No more index errors to assail,
Upstream tests now sip fresh brine. 🥕

🚥 Pre-merge checks | ✅ 3
✅ 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 summarizes the main code change in daily_nightly_tests_report.py, replacing os.environ usage with os.getenv for safer environment variable access.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix_get_environment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@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

🧹 Nitpick comments (1)
Makefile (1)

10-10: Consider centralizing the image tag to avoid multi-file drift.

Line 10 hardcodes 0.9.0; the same value is duplicated across workflow/Dockerfile/Makefile. Defining one variable in the Makefile (and reusing it where possible) will reduce future mismatch risk.

Proposed refactor
+UPSTREAM_DAILY_TESTS_TAG ?= 0.9.0
+
 build_images:
-	podman build -t quay.io/sclorg/upstream-daily-tests:0.9.0 -f Dockerfile.daily-tests .
+	podman build -t quay.io/sclorg/upstream-daily-tests:$(UPSTREAM_DAILY_TESTS_TAG) -f Dockerfile.daily-tests .
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` at line 10, Centralize the image tag by adding a variable (e.g.,
DAILY_TESTS_TAG or IMAGE_TAG) in the Makefile and replace the hardcoded literal
in the podman build command (the line invoking "podman build -t
quay.io/sclorg/upstream-daily-tests:0.9.0 -f Dockerfile.daily-tests .") with a
reference to that variable; update any other project files that currently
duplicate the tag to read from this Makefile variable (or a single source such
as an exported env file) so the tag is maintained in one place and future
changes won’t drift across Dockerfile/workflow/Makefile.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@daily-tests/daily_tests/daily_nightly_tests_report.py`:
- Around line 190-191: Remove the unconditional override of self.send_email and
instead parse the environment variable properly: read SEND_EMAIL as a string
(e.g., os.getenv("SEND_EMAIL", "False") or similar), normalize it (strip and
lower) and set self.send_email to True only if the value is one of common truthy
tokens ("1","true","yes","on"); update the assignment where self.send_email is
currently set (replace the two lines referencing self.send_email in the
constructor or initializer) so the env var controls email sending with a safe
default of False.

---

Nitpick comments:
In `@Makefile`:
- Line 10: Centralize the image tag by adding a variable (e.g., DAILY_TESTS_TAG
or IMAGE_TAG) in the Makefile and replace the hardcoded literal in the podman
build command (the line invoking "podman build -t
quay.io/sclorg/upstream-daily-tests:0.9.0 -f Dockerfile.daily-tests .") with a
reference to that variable; update any other project files that currently
duplicate the tag to read from this Makefile variable (or a single source such
as an exported env file) so the tag is maintained in one place and future
changes won’t drift across Dockerfile/workflow/Makefile.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: f3313cb5-024c-4673-94be-374afac02c38

📥 Commits

Reviewing files that changed from the base of the PR and between 51e6765 and 0116132.

📒 Files selected for processing (4)
  • .github/workflows/build-and-push.yml
  • Dockerfile.daily-tests
  • Makefile
  • daily-tests/daily_tests/daily_nightly_tests_report.py

phracek added 2 commits March 31, 2026 13:40
Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
Signed-off-by: Petr "Stone" Hracek <phracek@redhat.com>
@phracek phracek merged commit 5b893e4 into master Mar 31, 2026
11 checks passed
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