Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Add CI to check if golang version updated #1264

Merged
merged 1 commit into from
Sep 16, 2024

Conversation

tmshort
Copy link
Contributor

@tmshort tmshort commented Sep 12, 2024

Description

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

@tmshort tmshort requested a review from a team as a code owner September 12, 2024 18:42
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 12, 2024
Copy link

netlify bot commented Sep 12, 2024

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit cc09bdd
🔍 Latest deploy log https://app.netlify.com/sites/olmv1/deploys/66e48ab9208dec0008af865e
😎 Deploy Preview https://deploy-preview-1264--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Sep 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.51%. Comparing base (d1adabd) to head (cc09bdd).
Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1264      +/-   ##
==========================================
+ Coverage   76.18%   76.51%   +0.33%     
==========================================
  Files          40       40              
  Lines        2330     2363      +33     
==========================================
+ Hits         1775     1808      +33     
+ Misses        398      389       -9     
- Partials      157      166       +9     
Flag Coverage Δ
e2e 57.85% <ø> (+0.63%) ⬆️
unit 53.06% <ø> (+0.53%) ⬆️

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.

@tmshort tmshort changed the title [WIP] Add CI to check if golang version updated 🌱 Add CI to check if golang version updated Sep 12, 2024
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 12, 2024
IFS='.' ver=(${whole})
IFS="${OLDIFS}"

if [ ${#ver[*]} -eq 2 ] ; then
Copy link
Contributor

@perdasilva perdasilva Sep 13, 2024

Choose a reason for hiding this comment

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

I'm wondering if we could simplify this block by front loading the precondition that |MAX_VER| >= |ver|, e.g.

    # MAX_VER can only have a length of 2 or 3
    if [ ${#ver[*]} -gt ${#MAX_VER[*]} ]; then
        echo "Badly formatted golang version ${whole} in ${file} (expecting at most ${#MAX_VER[*]} version components)"
        return 1
    fi
    if [ ${ver[0]} -gt ${GO_MAJOR} ]; then
        echo "Bad golang version ${whole} in ${file} (expected ${GO_VER} or less)"
        return 1
    fi
    if [ ${ver[1]} -gt ${GO_MINOR} ]; then
        echo "Bad golang version ${whole} in ${file} (expected ${GO_VER} or less)"
        return 1
    fi
    if [ ${#ver[*]} -eq 3 ] ; then
        if [ ${ver[1]} -eq ${GO_MINOR} -a ${ver[2]} -gt ${GO_PATCH} ]; then
            echo "Bad golang version ${whole} in ${file} (expected ${GO_VER} or less)"
            return 1
        fi
    fi
    echo "Version ${whole} in ${file} is good"
    return 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At this point, we actually know that MAX_VER has 3 elements; because it's retrieved from our go.mod file that has a 3 element version. And there's definitely some simplification that can be done.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think go in go.mod has to have 3 elements. Pretty sure go <major>.<minor> is also allowed.

fi
done

for f in $(find . -name "*.mod"); do
Copy link
Contributor

Choose a reason for hiding this comment

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

would this break if some dependency went from 1.22.1. to 1.22.2?
would it break if we added a new dependency or bingo tool?

Copy link
Contributor

Choose a reason for hiding this comment

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

oh - the go.mod for the dependencies doesn't seem to get pulled down in vendor. Though, dependencies can include mod files, e.g. from catd:

find . -name '*.mod'
./.bingo/go.mod
./.bingo/kustomize.mod
./.bingo/setup-envtest.mod
./.bingo/bingo.mod
./.bingo/controller-gen.mod
./.bingo/golangci-lint.mod
./.bingo/goreleaser.mod
./.bingo/kind.mod
./.bingo/operator-sdk.mod
./.bingo/opm.mod
./.bingo/crd-ref-docs.mod
./go.mod
./vendor/github.com/klauspost/compress/s2sx.mod

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There should be no vendor directory, if so, that's a another problem.
Yes, it's supposed to check .bingo files
Yes, it's supposed to notify us of all go version change to go.mod-type files - but it's just a warning, not a required CI

if ! check_version ${v} ${f}; then
RETCODE=1
fi
old=$(git grep -ohP '^go .*$' "${BASE_REF}" -- "${f}")

Choose a reason for hiding this comment

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

This regex stipulates ONE space after "go"... (beware of fragile regex's)
This is a nit, as this should always hold :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually it stipulates one space after "go", then ANYTHING, including spaces. Since we're not "capturing" the version separately, it doesn't matter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's managed by go mod, so I would hope it always holds.

Signed-off-by: Todd Short <tshort@redhat.com>
@tmshort
Copy link
Contributor Author

tmshort commented Sep 13, 2024

I made the output a little less noisier.

Copy link
Member

@LalatenduMohanty LalatenduMohanty left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 16, 2024
@tmshort tmshort added this pull request to the merge queue Sep 16, 2024
@tmshort tmshort removed this pull request from the merge queue due to a manual request Sep 16, 2024
@tmshort tmshort added this pull request to the merge queue Sep 16, 2024
Merged via the queue into operator-framework:main with commit f10eb1d Sep 16, 2024
17 checks passed
@tmshort tmshort deleted the gover2 branch September 16, 2024 14:53
@skattoju skattoju mentioned this pull request Sep 25, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants