Conversation
|
Skipping CI for Draft Pull Request. |
|
/test all |
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tests/roxctl/bats-tests/helpers.bash" line_range="32" />
<code_context>
delete-outdated-binaries() {
local roxctl_ver="${1}"
- current_tag="$(git describe --tags --abbrev=10 --dirty --long --exclude '*-nightly-*')"
+ current_tag="$(git describe --tags --abbrev=10 --dirty --long --exclude '*-nightly-*' 2>/dev/null || cat VERSION 2>/dev/null || echo "0.0.0")"
echo "Roxctl version='${roxctl_ver}'" >&3
echo "Current tag ='${current_tag}'" >&3
</code_context>
<issue_to_address>
**suggestion (testing):** Add tests covering the new fallbacks when `git describe` is unavailable (shallow clone / no git history).
The new fallback chain has two untested paths: (1) `git describe` fails but a `VERSION` file exists, and (2) both `git describe` and `VERSION` are unavailable, so we fall back to `0.0.0`. Please add Bats tests for `delete-outdated-binaries` that simulate these cases (e.g., force `git describe` to fail, with and without a `VERSION` file) and assert that `current_tag` and the cleanup behavior are correct in each scenario. This will validate CI behavior under shallow clones and guard against regressions in outdated-binary detection.
Suggested implementation:
```shell
delete-outdated-binaries() {
local roxctl_ver="${1}"
# Allow tests to override the git command and VERSION file path so that we can
# simulate shallow clones / missing git history and different VERSION file setups.
local _git_cmd="${ROXCTL_GIT_CMD:-git}"
local _version_file="${ROXCTL_VERSION_FILE:-VERSION}"
current_tag="$("$_git_cmd" describe --tags --abbrev=10 --dirty --long --exclude '*-nightly-*' 2>/dev/null \
|| cat "$_version_file" 2>/dev/null \
|| echo "0.0.0")"
echo "Roxctl version='${roxctl_ver}'" >&3
echo "Current tag ='${current_tag}'" >&3
if [[ "${current_tag}" != "${roxctl_ver}" ]]; then
```
To fully implement your test request, you should also:
1. Add a new Bats test file, e.g. `tests/roxctl/bats-tests/delete-outdated-binaries.bats`, that sources `helpers.bash` and tests the new fallback behavior:
- **Test 1 – git describe fails, VERSION exists**:
- Create a temporary directory and `cd` into it.
- Create a fake `git` script in a temp dir that always exits non‑zero, and set `ROXCTL_GIT_CMD` to that script.
- Write a `VERSION` file (or set `ROXCTL_VERSION_FILE` to a temp file) with a test version string, e.g. `1.2.3`.
- Call `delete-outdated-binaries "some-other-version"`.
- Assert that the captured output on FD 3 (or stdout, depending on how helpers are wired) contains `Current tag ='1.2.3'`.
- Assert that the cleanup behavior is correct (e.g., the expected outdated binaries are removed while current ones are kept). This likely mirrors existing tests for `delete-outdated-binaries`; reuse the same fixture setup/teardown.
- **Test 2 – git describe fails and VERSION missing**:
- Similar setup with failing `ROXCTL_GIT_CMD`, but without creating a VERSION file (or point `ROXCTL_VERSION_FILE` to a non-existent path).
- Call `delete-outdated-binaries "some-other-version"`.
- Assert that the output includes `Current tag ='0.0.0'`.
- Assert the correct cleanup behavior for the `0.0.0` tag case.
2. Ensure your Bats tests:
- `load` whatever helper is used to bring in `helpers.bash` (likely via `load helpers` or a project-specific helper loader).
- Use temporary directories (`setup`/`teardown` hooks or `BATS_TMPDIR`) so tests are isolated and do not depend on the real repository git history or VERSION file.
- Restore any modified environment variables (like `ROXCTL_GIT_CMD` and `ROXCTL_VERSION_FILE`) in `teardown` to avoid cross-test contamination.
These tests will directly exercise the two new fallback paths (VERSION and `0.0.0`) and verify that `delete-outdated-binaries` behaves correctly under shallow clones or missing git history in CI.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Images are ready for the commit at c696008. To use with deploy scripts, first |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #19293 +/- ##
==========================================
- Coverage 49.62% 49.61% -0.01%
==========================================
Files 2680 2680
Lines 202214 202214
==========================================
- Hits 100346 100336 -10
- Misses 94393 94399 +6
- Partials 7475 7479 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
b351ce1 to
0180ba4
Compare
0180ba4 to
c696008
Compare
|
/test gke-qa-e2e-tests |
|
@davdhacs: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Remove fetch-depth: 0 from all checkout steps across all workflows. Shallow clones (depth=1, the default) save ~13s per job by skipping git history download.