Skip to content

Add CI test infrastructure and code coverage tools#34

Merged
pthurlow merged 3 commits intomainfrom
feat/test-codecov
Apr 3, 2026
Merged

Add CI test infrastructure and code coverage tools#34
pthurlow merged 3 commits intomainfrom
feat/test-codecov

Conversation

@pthurlow
Copy link
Copy Markdown
Collaborator

@pthurlow pthurlow commented Apr 3, 2026

No description provided.

@sentry
Copy link
Copy Markdown

sentry bot commented Apr 3, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Comment thread .github/workflows/ci.yml
uses: taiki-e/install-action@cargo-llvm-cov

- name: Run tests with coverage
run: cargo llvm-cov --lcov --output-path lcov.info
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: add restore-keys so a cache miss on a lock file change still gets a partial hit, avoiding a full cold rebuild every time dependencies change.

Suggested change
run: cargo llvm-cov --lcov --output-path lcov.info
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

Comment thread src/auth.rs
.unwrap()
.execute(Print(format!("{login_url}\n")))
.unwrap()
.execute(ResetColor)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The exchange_token function has a hidden side effect: it saves the API key to disk via config::save_api_key. The caller in login() destructures LoginResult::Success { workspace, .. } and ignores the returned token field — because it was already persisted inside here. This makes the token field in LoginResult::Success redundant and the function contract surprising.

Non-blocking, but consider either naming this exchange_and_save_token or removing the token field from LoginResult::Success since callers don't need it.

claude[bot]
claude bot previously approved these changes Apr 3, 2026
Comment thread src/config.rs
let tmp = tempfile::tempdir().unwrap();
// SAFETY: tests are serialized via ENV_LOCK mutex, so no concurrent env mutation.
unsafe { std::env::set_var("HOTDATA_CONFIG_DIR", tmp.path()) };
(tmp, guard)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: unset the env var when the guard drops so future tests that don't call with_temp_config_dir() don't accidentally inherit a stale (possibly deleted) path. One pattern is to return a custom RAII guard that removes the var on Drop instead of returning the MutexGuard directly.

Non-blocking — all current tests that touch disk already use this helper.

Comment thread .github/workflows/ci.yml
files: lcov.info
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider pinning to a commit SHA instead of a mutable tag to guard against tag-movement supply chain risk, e.g. codecov/codecov-action@13afa45a3c5ef97eb2c28e9e3f20c3741badc8f0 # v4.

Non-blocking — fail_ci_if_error: false already limits the blast radius.

@pthurlow pthurlow merged commit 49dbeea into main Apr 3, 2026
9 checks passed
@pthurlow pthurlow deleted the feat/test-codecov branch April 3, 2026 18:23
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