Skip to content

cirrus lib.sh: refactor req_env_var()#3053

Merged
openshift-merge-robot merged 1 commit into
containers:masterfrom
edsantiago:fix_req_env_var
May 2, 2019
Merged

cirrus lib.sh: refactor req_env_var()#3053
openshift-merge-robot merged 1 commit into
containers:masterfrom
edsantiago:fix_req_env_var

Conversation

@edsantiago
Copy link
Copy Markdown
Member

Existing code was not working due to a bash gotcha ('exit'
from a pipeline). It also had unnecessary duplication.

New version is safer; also includes unit tests.

Existing invocations of req_env_var replaced via:

$ [ edit setup_environment.sh, move one closing quote to its own line ]
$ perl -ni -e 's/(?<=req_env_var )"(\S+)\s+$\1"/$1/; if (/req_env_var "$/ .. /^\s*"/) { chomp; s/(?<=\S)\s.//; if (/^\s"/) { print "\n" } else { unless (/req_env_var/) { s/^\s+//; print " ";} print;} } else { print }' $(ack -l req_env_var)
$ [ hand-massage an incorrect instance of '@' in lib.sh:ircmsg() ]

Signed-off-by: Ed Santiago santiago@redhat.com

@edsantiago
Copy link
Copy Markdown
Member Author

Sorry; I have no hints for reviewing other than suggesting the use of a good diff colorizer.

Copy link
Copy Markdown
Member

@cevich cevich left a comment

Choose a reason for hiding this comment

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

Thank you so much ed, this is WAY better than I could have done. Only small ask is you add running the unittest script to Makefile under the localunit target. That will give us coverage on all platforms and development environments.

Comment thread contrib/cirrus/lib.sh Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Oh good you caught this possible inf. loop 😄

Comment thread contrib/cirrus/lib.sh.t Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ooooohhhhhhh praise $DIETY thank theee for blessing @edsantiago to write this thy unittest thanks be the $CI

@cevich
Copy link
Copy Markdown
Member

cevich commented May 2, 2019

/approve

1 similar comment
@mheon
Copy link
Copy Markdown
Member

mheon commented May 2, 2019

/approve

@openshift-ci-robot
Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cevich, edsantiago, mheon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 2, 2019
@cevich
Copy link
Copy Markdown
Member

cevich commented May 2, 2019

LGTM pending tests pass with something like this:

diff --git a/Makefile b/Makefile
index 9228ec71..cf4e9364 100644
--- a/Makefile
+++ b/Makefile
@@ -188,6 +188,7 @@ localunit: test/goecho/goecho varlink_generate
                --tags "$(BUILDTAGS)" \
                --succinct
        $(MAKE) -C contrib/cirrus/packer test
+       bash contrib/cirrus/lib.sh.t
 
 ginkgo:
        ginkgo -v -tags "$(BUILDTAGS)" $(GINKGOTIMEOUT) -cover -flakeAttempts 3 -progress -trace -noColor -nodes 3 test/e2e/.

Other option is to add it to .cirrus.yml as part of the gate task. However it's done, it would be great to have it continuously validated. Thanks again for adding those tests, that really means a lot to me.

Existing code was not working due to a bash gotcha ('exit'
from a pipeline). It also had unnecessary duplication.

New version is safer; also includes unit tests run under localunit.

Existing invocations of req_env_var replaced via:

   $ [ edit setup_environment.sh, move one closing quote to its own line ]
   $ perl -ni -e 's/(?<=req_env_var )"(\S+)\s+\$\1"/$1/; if (/req_env_var "$/ .. /^\s*"/) { chomp; s/(?<=\S)\s.*//; if (/^\s*"/) { print "\n" } else { unless (/req_env_var/) { s/^\s+//; print " ";} print;} } else { print }' $(ack -l req_env_var)
   $ [ hand-massage an incorrect instance of '@' in lib.sh:ircmsg() ]

Signed-off-by: Ed Santiago <santiago@redhat.com>
@edsantiago
Copy link
Copy Markdown
Member Author

Force-pushed with requested Makefile change. Thanks for the suggestion.

@cevich
Copy link
Copy Markdown
Member

cevich commented May 2, 2019

@edsantiago fantastic, thanks.

LGTM

@mheon may we fast-track this one please, it adds some sorely needed fixes AND actual CI-unittests for a heavily used function in our Cirrus scripts. It's also needed for my #2561

@cevich
Copy link
Copy Markdown
Member

cevich commented May 2, 2019

/me sprinkles some go-faster and run-clean dust onto the automation pixies

@mheon
Copy link
Copy Markdown
Member

mheon commented May 2, 2019

My bash-fu is very weak, but this LGTM

Copy link
Copy Markdown
Member

@TomSweeneyRedHat TomSweeneyRedHat left a comment

Choose a reason for hiding this comment

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

LGTM assuming happy tests

@cevich
Copy link
Copy Markdown
Member

cevich commented May 2, 2019

Thanks Matt and Tom.

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label May 2, 2019
@edsantiago
Copy link
Copy Markdown
Member Author

@mheon (and future maintainers) the key background for this is that #2561 is making some changes to various invocations of the req_env_var function. While reviewing I noticed that the function was not working as intended; but fixes to it would be too cumbersome to review as part of that PR. If 2561 is rebased on top of this, it should (I hope) be easier to review.

@openshift-merge-robot openshift-merge-robot merged commit 8a1d7c2 into containers:master May 2, 2019
@edsantiago edsantiago deleted the fix_req_env_var branch May 2, 2019 15:02
@github-actions github-actions Bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 26, 2023
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants