diff --git a/README.md b/README.md index 610e6a1..b7c3244 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,16 @@ The test environment consists of the following * The repository user1/originrepo * contains a pull_request workflow using cascading-pr that targets user2/destinationrepo * contains a script that will modify user2/destinationrepo - * a PR from branch1 to main + * a branch1 at the same commit as main * The repository user1/cascading-pr with the action under test * An unprivileged user user2 * The repository user2/destinationrepo +The test for a successful run of the cascading-pr action consists of: + +* creating a PR from branch1 to main +* wait for the commit status until it is successful + ## testing an update on the action * run `tests/run.sh --debug` once so all is in place diff --git a/tests/run.sh b/tests/run.sh index f87bf89..3335c19 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -67,6 +67,17 @@ function create_pull_request() { forgejo-curl.sh api_json --data-raw '{"title":"PR","base":"main","head":"branch1"}' ${options[url]}/api/v1/repos/user1/originrepo/pulls } +function finalize_options() { + if test -f forgejo-ip; then + : ${options[host_port]:=$(cat forgejo-ip):3000} + fi + options[url]=http://${options[host_port]} + if test -f forgejo-token; then + : ${options[token]:=$(cat forgejo-token)} + fi + options[password]=admin1234 +} + function run() { user_create user2 user2@example.com forgejo-test-helper.sh push tests/destinationrepo http://user2:admin1234@${options[host_port]} user2 destinationrepo @@ -76,19 +87,16 @@ function run() { user_secret user1 ORIGIN_TOKEN $(user_token user1 ORIGIN_TOKEN) user_secret user1 DESTINATION_TOKEN $(user_token user2 DESTINATION_TOKEN) + push_self + create_pull_request - push_self echo do something } function main() { local command=run - options[host_port]=$(cat forgejo-ip):3000 - options[url]=http://${options[host_port]} - options[token]=$(cat forgejo-token) - options[password]=admin1234 while true; do case "$1" in @@ -113,6 +121,7 @@ function main() { options[token]=$1 ;; *) + finalize_options "${1:-run}" return 0 ;;