Skip to content

perf(ci): shallow clone for most CI jobs#19293

Draft
davdhacs wants to merge 1 commit intomasterfrom
davdhacs/ci-shallow-clone
Draft

perf(ci): shallow clone for most CI jobs#19293
davdhacs wants to merge 1 commit intomasterfrom
davdhacs/ci-shallow-clone

Conversation

@davdhacs
Copy link
Contributor

@davdhacs davdhacs commented Mar 4, 2026

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.

@openshift-ci
Copy link

openshift-ci bot commented Mar 4, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@davdhacs
Copy link
Contributor Author

davdhacs commented Mar 4, 2026

/test all

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@rhacs-bot
Copy link
Contributor

rhacs-bot commented Mar 4, 2026

Images are ready for the commit at c696008.

To use with deploy scripts, first export MAIN_IMAGE_TAG=4.11.x.

@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.61%. Comparing base (04dcf46) to head (c696008).

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     
Flag Coverage Δ
go-unit-tests 49.61% <ø> (-0.01%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@davdhacs davdhacs force-pushed the davdhacs/ci-shallow-clone branch 10 times, most recently from b351ce1 to 0180ba4 Compare March 5, 2026 01:30
@davdhacs davdhacs force-pushed the davdhacs/ci-shallow-clone branch from 0180ba4 to c696008 Compare March 5, 2026 01:45
@davdhacs
Copy link
Contributor Author

davdhacs commented Mar 5, 2026

/test gke-qa-e2e-tests

@openshift-ci
Copy link

openshift-ci bot commented Mar 5, 2026

@davdhacs: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/gke-operator-e2e-tests bcfe8df link false /test gke-operator-e2e-tests
ci/prow/gke-upgrade-tests bcfe8df link false /test gke-upgrade-tests
ci/prow/gke-nongroovy-e2e-tests bcfe8df link true /test gke-nongroovy-e2e-tests
ci/prow/gke-qa-e2e-tests c696008 link false /test gke-qa-e2e-tests

Full PR test history. Your PR dashboard.

Details

Instructions 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants