Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(brew-bump.sh): add checks and handle errors #4236

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

Merged
jsjoeio merged 2 commits into main from jsjoeio/fix-brew-bump
Sep 28, 2021
Merged

Conversation

Copy link
Contributor

@jsjoeio jsjoeio commented Sep 23, 2021
edited
Loading

This PR adds a lot of bash helper functions (+ tests) used in brew-bump.sh in order to ensure this script doesn't fail when publishing a release.

image

TODOs

  • add BATS test for steps-lib.sh
  • add check + test for $VERSION
  • add check for cdr/ci/homebrew
  • add check for remote upstream
  • add check for $HOMEBREW_GITHUB_API_TOKEN
  • add check for git-ask-pass.sh
  • add check for cleaning up homebrew-core
  • fix Trivy vulnerability (chore(deps): upgrade ansi-regex to 5.0.1 and tmpl to 1.0.5 #4251 )
  • test the GIT_ASKPASS in isolated environment

Fixes #3962

Test Plan

To test out the other parts of the script (specifically GIT_ASKPASS), here is what I did:

  1. Create new Workspace on https://master.cdr.dev/workspaces
  2. "log out" of git with:
git config --global --unset user.name
git config --global --unset user.email
git config --global --unset credential.helper
  1. Verify log out by trying to clone via HTTPS a private repo:
git clone https://github.com/jsjoeio/dip.chat-v2.git
  1. Create script similar to brew-bump.sh and add steps-lib.sh to Workspace.
  2. Make script executable chmod +x test-brew.sh
  3. Run script: VERSION="1.2.3" HOMEBREW_GITHUB_API_TOKEN="<redcated>" ./test-brew.sh (make sure the token had repo and workflow in scope).

Notes

Ran into issues with scripts that used set -u so that's why I created a new file called steps-lib.sh.

See: sstephenson/bats#171

@jsjoeio jsjoeio self-assigned this Sep 23, 2021
@jsjoeio jsjoeio added chore Related to maintenance or clean up ci Issues related to ci testing Anything related to testing labels Sep 23, 2021
Copy link

codecov bot commented Sep 23, 2021
edited
Loading

Codecov Report

Merging #4236 (9aac550) into main (8f72481) will not change coverage.
The diff coverage is n/a.

❗ Current head 9aac550 differs from pull request most recent head 8ef950a. Consider uploading reports for the commit 8ef950a to get more accurate results
Impacted file tree graph

@@ Coverage Diff @@
## main #4236 +/- ##
=======================================
 Coverage 65.09% 65.09% 
=======================================
 Files 36 36 
 Lines 1882 1882 
 Branches 380 380 
=======================================
 Hits 1225 1225 
 Misses 559 559 
 Partials 98 98 

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f72481...8ef950a. Read the comment docs.

Copy link

github-actions bot commented Sep 23, 2021
edited
Loading

✨ Coder.com for PR #4236 deployed! It will be updated on every commit.

@jsjoeio jsjoeio force-pushed the jsjoeio/fix-brew-bump branch 2 times, most recently from b590dcd to 9aac550 Compare September 27, 2021 23:23
@jsjoeio jsjoeio marked this pull request as ready for review September 27, 2021 23:24
@jsjoeio jsjoeio requested a review from a team as a code owner September 27, 2021 23:24
@jsjoeio jsjoeio changed the title (削除) fix: add checks and handle errors brew-bump.sh (削除ここまで) (追記) fix(brew-bump.sh): add checks and handle errors (追記ここまで) Sep 27, 2021
Copy link

@jawnsy jawnsy left a comment

Choose a reason for hiding this comment

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

left some really minor suggestions for your consideration, this is good-to-go as it is

jsjoeio reacted with hooray emoji jsjoeio reacted with heart emoji jsjoeio reacted with rocket emoji

@test "is_env_var_set should return 1 if env var is not set" {
run is_env_var_set "ASDF_TEST_SET"
[ "$output" = 1 ]
Copy link

Choose a reason for hiding this comment

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

If you change the functions to return stuff instead of echo, then you'd have to change this to check the $status instead of $output

jsjoeio reacted with thumbs up emoji jsjoeio reacted with eyes emoji
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! Okay if/after I refactor, I'll update these!

feat(script): add steps-lib, is_env_var_set & test
feat(brew-bump): add check for VERSION
feat(brew-bump): check HOMEBREW_GITHUB_API_TOKEN
feat(steps-lib): add directory_exists helper fn
fix(brew-bump): check that git clone worked
feat(brew-bump): add check for remote upstream
fix: remove upstream command thing
feat(steps-lib): add file_exists helper function
feat(brew-bump): add check for git-askpass.sh
feat(steps-lib): add is_executable function & test
feat(brew-bump): add check for is_executable
refactor: use GIT_ASKPASS as variable
@jsjoeio jsjoeio merged commit 999960e into main Sep 28, 2021
@jsjoeio jsjoeio deleted the jsjoeio/fix-brew-bump branch September 28, 2021 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
1 more reviewer

@jawnsy jawnsy jawnsy approved these changes

Reviewers whose approvals may not affect merge requirements
Labels
chore Related to maintenance or clean up ci Issues related to ci testing Anything related to testing
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Fix brew-bump.sh script
2 participants

AltStyle によって変換されたページ (->オリジナル) /