Skip to content

🐛 Location-agnostic sign release - #268

Merged
knative-prow[bot] merged 2 commits into
knative:mainfrom
cardil:bugfix/darwin-signing-checksum-location
Feb 10, 2023
Merged

knative-prow[bot] merged 2 commits into
knative:mainfrom
cardil:bugfix/darwin-signing-checksum-location

Conversation

@cardil

@cardil cardil commented Feb 7, 2023

Copy link
Copy Markdown
Contributor

Changes

  • 🐛 Location-agnostic sign release

/kind bug

Fixes #240
Related to knative-extensions/homebrew-kn-plugins#134

@knative-prow knative-prow Bot added the kind/bug Categorizes issue or PR as related to a bug. label Feb 7, 2023
@knative-prow knative-prow Bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 7, 2023
@cardil

cardil commented Feb 7, 2023

Copy link
Copy Markdown
Contributor Author

/cc @upodroid
/cc @kvmware

@knative-prow
knative-prow Bot requested a review from upodroid February 7, 2023 14:26
@cardil

cardil commented Feb 7, 2023

Copy link
Copy Markdown
Contributor Author

/cc @psschwei
/cc @evankanderson

Comment thread release.sh Resolved
@krsna-m

krsna-m commented Feb 7, 2023

Copy link
Copy Markdown
Contributor

Awesome work on adding the tests 👍
Got my LGTM

@cardil

cardil commented Feb 7, 2023

Copy link
Copy Markdown
Contributor Author

/hold

I'd say to wait for @upodroid as this is mostly his code.

@knative-prow knative-prow Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 7, 2023

@upodroid upodroid left a comment

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.

LGTM

We can test this by bumping the deps and rerunning the nightly. The final artifacts will be in the nightly GCS bucket

@knative-prow knative-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Feb 7, 2023
@knative-prow

knative-prow Bot commented Feb 7, 2023

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cardil, upodroid

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

@cardil cardil left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This needs to be adjusted

Comment thread release.sh Resolved
Comment thread release.sh Resolved
@knative-prow knative-prow Bot removed the lgtm Indicates that a PR is ready to be merged. label Feb 7, 2023
@cardil
cardil requested review from krsna-m and upodroid February 7, 2023 16:22
@krsna-m

krsna-m commented Feb 7, 2023

Copy link
Copy Markdown
Contributor

/retest

@cardil

cardil commented Feb 7, 2023

Copy link
Copy Markdown
Contributor Author

Infra failure

/test integration-tests

Comment thread release.sh
macos_artifacts+=("${file}")
rcodesign sign "${file}" --p12-file="${APPLE_CODESIGN_KEY}" \
--code-signature-flags=runtime \
--p12-password-file="${APPLE_CODESIGN_PASSWORD_FILE}"

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.

I'll admit I'm slightly confused on preferring while ...; done < <(command) over command | while ...; done.

The explanation about subshells didn't make sense to me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't know to what you are referring exactly. Is it https://www.shellcheck.net/wiki/SC2013 ?

It shows couple valid options on how to iterate lines from a file/pipe/stdin. All of them are equally valid.

The problem is people keep using the invalid iteration patterns. Habits from other programming languages often makes writing shell code harder, as bash is unique in many ways.

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.

I meant that this format:

grep -v '^ *#' < file | while IFS= read -r line
do
  echo "Line: $line"
done

Seems clearer to me, because the set of things you're looping over is at the start.

The linked docs suggest that the form using process substitution (<(...)) "avoids a subshell", but I'm not sure I understand why that would be true. In any case, it feels like having the set of things to loop over at the beginning of the loop is a bit more natural.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Both forms are equally valid. Matter of preference, I guess.

Giving things to iterate over before the loop, can be very cloudy, especially if the command is long.

Passing it to done is clear to me, and avoids long lines. Feeding data to commands with < is quite common in shell. No point, IMHO, of making bash to look like other programming languages, it isn't similar.

Your proposal has only one minor downside. Because it uses pipe, it may fail silently without stopping the script (if pipefail option isn't set ofc).

Comment thread release.sh
echo "🧮 Post Notarization Checksum:"
cat checksums.txt
local macos_artifacts
declare -a macos_artifacts=()

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.

Would this be better as that fancy glob-equals used above?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't see any glob-equal anywhere. Could you explain it exactly?

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.

On line 333, you wrote:

    if [[ "${file}" == *"checksums.txt" ]]; then

I wondered if that form would be better than echo | grep

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.

Oops, this was supposed to be on line 368:

      if echo "$file" | grep -q "darwin"; then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, it may be written as

if [[ "$file" == *"darwin"* ]]; then

IDK if it's worth changing though. This form is way less known, and it's very error prone.

For example, someone could rewrite it to:

if [[ "$file" == "*darwin*" ]]; then

Which means completely different thing, and will not work.

But, going back to your question: I'm not seeing much benefit in a rewrite, but we definitely could do it if you feel like it.

Comment thread release.sh
zip_file="$(mktemp -d)/files.zip"
zip "$zip_file" -@ < <(printf "%s\n" "${macos_artifacts[@]}")
rcodesign notary-submit "$zip_file" --api-key-path="${APPLE_NOTARY_API_KEY}" --wait
true > "${checksums_file}" # Clear the checksums file

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.

Should this be a comparison, or do we want to avoid any file with checksums.txt in the name?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't follow, again. There's no comparison here.

This line clears the checksums file content. The true built-in has no stdout, so redirecting it to the file, clears its contents.

@cardil cardil Feb 7, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What could have been done better here, is to not clear the file entirely, but replace just the signed files hashes.

We could make such amend in a follow up, IMHO.

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.

It looks like GitHub made a mess of the line numbers on my comments, let me find the right line.

@cardil

cardil commented Feb 7, 2023

Copy link
Copy Markdown
Contributor Author

/test integration-tests

Infra failure: GKE cluster failed to boot

@cardil
cardil requested a review from evankanderson February 8, 2023 17:20
@evankanderson

Copy link
Copy Markdown
Member

/lgtm

@knative-prow knative-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Feb 10, 2023
@cardil

cardil commented Feb 10, 2023

Copy link
Copy Markdown
Contributor Author

/hold cancel

@knative-prow knative-prow Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 10, 2023
@knative-prow
knative-prow Bot merged commit d71d569 into knative:main Feb 10, 2023
@cardil
cardil deleted the bugfix/darwin-signing-checksum-location branch February 10, 2023 21:57
@cardil

cardil commented Feb 13, 2023

Copy link
Copy Markdown
Contributor Author

Fix confirmed, see: knative-extensions/kn-plugin-event#270 (comment)

/cherrypick release-1.9

@knative-prow-robot

Copy link
Copy Markdown

@cardil: new pull request created: #271

Details

In response to this:

Fix confirmed, see: knative-extensions/kn-plugin-event#270 (comment)

/cherrypick release-1.9

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/test-infra repository.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Signing should respect the ARTIFACTS_TO_PUBLISH variable

5 participants