#32121: Refactor some common configs and functions out of the git scripts. -------------------------------------+------------------------------------ Reporter: teor | Owner: nickm Type: enhancement | Status: needs_review Priority: Medium | Milestone: Tor: 0.4.4.x-final Component: Core Tor/Tor | Version: Severity: Normal | Resolution: Keywords: git-scripts, 044-should | Actual Points: .5 Parent ID: | Points: Reviewer: | Sponsor: -------------------------------------+------------------------------------ Changes (by teor):
* actualpoints: .3 => .5 Comment: Replying to [comment:6 nickm]: > Branch `ticket32121` with PR at https://github.com/torproject/tor/pull/1720 . > > I have tested this a little, but not extensively. I've done my best to write this in a way so that the individual scripts don't need to change how they use anything. This branch actually removes code from the scripts overall. I really like this change, and I'm glad we've finally made it happen. The design is much better than what I had in mind. > I'm afraid I have no idea how to write tests for this (#32122). Let's use the typical merge and test workflows, but without actually making any commits? Here's a detailed design for some tests: (We should probably make this test script into its own script, so we can run it in CI, and from the git hooks.) Script arguments: * temporary TOR_FULL_GIT_PATH: `mktemp -d` by default, ${TRAVIS_BUILD_DIR }/git-scripts-test` in Travis Useful TOR_EXTRA_CLONE_ARGS: * only clone recent commits: --depth ??? * re-use existing git packs: --reference-if-able "$TOR_FULL_GIT_PATH/tor" Setup: {{{ # list the active tor branches, for testing and diagnostics git-list-tor-branches.sh }}} Help: {{{ git-list-tor-branches.sh -h git-setup-dirs.sh -h git-pull-all.sh -h git-merge-forward.sh -h git-push-all.sh -h }}} Dry Run: {{{ # now dry run all the scripts git-setup-dirs.sh -n git-pull-all.sh -n git-merge-forward.sh -n git-push-all.sh -n }}} List Branches: {{{ git-list-tor-branches.sh git-list-tor-branches.sh -s # Print and eval the bash code, but don't change the current shell's env # branch_path git-list-tor-branches.sh -b echo $(eval "$(git-list-tor-branches.sh -b)"; echo "$WORKTREE") # merge git-list-tor-branches.sh -m echo $(eval "$(git-list-tor-branches.sh -m)"; echo "$WORKTREE") }}} List maint-* and master branches: {{{ git-list-tor-branches.sh -R git-list-tor-branches.sh -s -R # Print and eval the bash code, but don't change the current shell's env # branch_path git-list-tor-branches.sh -b -R echo $(eval "$(git-list-tor-branches.sh -b -R)"; echo "$WORKTREE") # merge git-list-tor-branches.sh -m -R echo $(eval "$(git-list-tor-branches.sh -m -R)"; echo "$WORKTREE") }}} Let's have a test script option that stops here: we can test some things in pre-commit and pre-push hooks (as long as we log output to a file), but cloning tor is too slow. Merge: {{{ # setup directories git-setup-dirs.sh # redundant pull, for testing, the merge script also does a pull before merging git-pull-all.sh # redundant merge forward, no changes, so git won't make merge commits git-merge-forward.sh # redundant push, no changes, so the script won't actually push anything git-push-all.sh }}} Test Branch: {{{ # add a fake remote git remote add fake_ci_remote fake_ci_remote_url # list the suffixes for the active tor branches, for testing and diagnostics git-list-tor-branches.sh -s # setup directories, use existing mode git-setup-dirs.sh -u # merge forward, test branch mode git-merge-forward.sh -t fake_ci_test # merge forward, use existing test branch mode git-merge-forward.sh -t fake_ci_test -u # redundant push, no changes, so the script won't actually push anything git-push-all.sh -t fake_ci_test -r fake_ci_remote }}} Things we don't test: {{{ # we can't test `git-push-all.sh -s`, because it actually pushes branches }}} I'll try to turn these notes into a script later today, after I've fixed some sponsor 55 bugs. > I'm not a very good bash programmer, so I might need your help in fixing up whatever issues you find. shellcheck has made all of us better bash programmers :-) -- Ticket URL: <https://trac.torproject.org/projects/tor/ticket/32121#comment:7> Tor Bug Tracker & Wiki <https://trac.torproject.org/> The Tor Project: anonymity online
_______________________________________________ tor-bugs mailing list tor-bugs@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs