diff --git a/README.md b/README.md index 16ca5fe..361d4b2 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ not exist, it is created. | origin-pr | number of the PR in {orign-repo} | `true` | | | destination-url | URL of the Forgejo instance where the cascading PR is created or updated (e.g. https://code.forgejo.org) | `true` | | | destination-repo | the repository in which the cascading PR is created or updated | `true` | | -| destination-fork-repo | the fork of {desitnation-repo} in which the {destination-branch} will be created or updated | `false` | | +| destination-fork-repo | the fork of {destination-repo} in which the {destination-branch} will be created or updated | `false` | | | destination-branch | the base branch of the destination repository for the cascading PR | `true` | | | destination-token | a token with write permission on destination-repo | `true` | | | update | path to the script to update the content of the cascading PR | `true` | | diff --git a/action.yml b/action.yml index 4fc807c..cbf010c 100644 --- a/action.yml +++ b/action.yml @@ -59,7 +59,7 @@ inputs: description: 'the repository in which the cascading PR is created or updated' required: true destination-fork-repo: - description: 'the fork of {desitnation-repo} in which the {destination-branch} will be created or updated' + description: 'the fork of {destination-repo} in which the {destination-branch} will be created or updated' destination-branch: description: 'the base branch of the destination repository for the cascading PR' required: true diff --git a/cascading-pr-lib.sh b/cascading-pr-lib.sh index e9eab03..bdbf86f 100644 --- a/cascading-pr-lib.sh +++ b/cascading-pr-lib.sh @@ -28,23 +28,24 @@ function dependencies() { } function retry() { - rm -f $TMPDIR/retry.out + rm -f $TMPDIR/retry.{out,attempt,err} local success=false for delay in $RETRY_DELAYS ; do - if "$@" |& tee -a $TMPDIR/retry.out > $TMPDIR/retry-attempt.out ; then + if "$@" > $TMPDIR/retry.attempt 2>> $TMPDIR/retry.err ; then success=true break fi - cat $TMPDIR/retry-attempt.out >&2 - log waiting $delay "$@" + cat $TMPDIR/retry.{err,attempt} >> $TMPDIR/retry.out + cat $TMPDIR/retry.{err,attempt} >&2 + echo waiting $delay "$@" >&2 sleep $delay done if $success ; then - cat $TMPDIR/retry-attempt.out + cat $TMPDIR/retry.attempt return 0 else - log_error retry failed for "$@" - cat $TMPDIR/retry.out + echo retry failed for "$@" >&2 + cat $TMPDIR/retry.out >&2 return 1 fi } diff --git a/tests/run.sh b/tests/run.sh index 4e96038..5d4a43d 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -171,17 +171,27 @@ function unit_retry() { # Succeeds after two tries # echo 2 > $TMPDIR/unit_retry_two - RETRY_DELAYS='1 1 1 1' retry unit_retry_fail $two > $TMPDIR/retry.test-result 2> $TMPDIR/retry.test-log + if ! RETRY_DELAYS='1 1 1 1' retry unit_retry_fail $two > $TMPDIR/retry.test-result 2> $TMPDIR/retry.test-log ; then + cat $TMPDIR/retry.test-result $TMPDIR/retry.test-log + return 1 + fi test "$(cat $TMPDIR/retry.test-result)" = "RESULT" - cat $TMPDIR/retry.test-log - test "$(grep -c 'waiting 1 unit_retry_fail' $TMPDIR/retry.test-log)" = 2 - + if test "$(grep -c '^waiting 1 unit_retry_fail' $TMPDIR/retry.test-log)" != 2 ; then + cat $TMPDIR/retry.test-log + return 1 + fi # # Succeeds immediately # - RETRY_DELAYS='1' retry unit_retry_fail $two > $TMPDIR/retry.test-result 2> $TMPDIR/retry.test-log + if ! RETRY_DELAYS='1' retry unit_retry_fail $two > $TMPDIR/retry.test-result 2> $TMPDIR/retry.test-log ; then + cat $TMPDIR/retry.test-result $TMPDIR/retry.test-log + return 1 + fi test "$(cat $TMPDIR/retry.test-result)" = "RESULT" - test "$(grep -c 'waiting 1 unit_retry_fail' $TMPDIR/retry.test-log)" = 0 + if test "$(grep -c 'waiting 1 unit_retry_fail' $TMPDIR/retry.test-log)" != 0 ; then + cat $TMPDIR/retry.test-log + return 1 + fi # # Verify the output is only the output of the last run and is not polluted by @@ -194,7 +204,8 @@ function unit_retry() { # Fails after one try # echo 2 > $TMPDIR/unit_retry_two - if RETRY_DELAYS='1' retry unit_retry_fail $two |& tee $TMPDIR/retry.test-log ; then + if RETRY_DELAYS='1' retry unit_retry_fail $two > $TMPDIR/retry.test-result 2> $TMPDIR/retry.test-log ; then + cat $TMPDIR/retry.test-result $TMPDIR/retry.test-log return 1 fi grep --quiet 'retry failed' $TMPDIR/retry.test-log @@ -368,8 +379,7 @@ function integration() { } function unit() { - # do not run in debug mode, it will polute the output and fail - ${BASH_SOURCE[0]} --verbose unit_retry + unit_retry } function run_tests() {