diff --git a/tests/destinationrepo/upgraded b/tests/destinationrepo/upgraded new file mode 100755 index 0000000..7aff533 --- /dev/null +++ b/tests/destinationrepo/upgraded @@ -0,0 +1,3 @@ +#!/bin/bash + +echo upgrade done diff --git a/tests/originrepo/.forgejo/workflows/test.yml b/tests/originrepo/.forgejo/workflows/test.yml new file mode 100644 index 0000000..6222bc3 --- /dev/null +++ b/tests/originrepo/.forgejo/workflows/test.yml @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: MIT +name: test +on: [pull_request] +jobs: + test: + runs-on: docker + steps: + - uses: actions/checkout@v4 + - uses: SELF@vTest + with: + origin-url: ${{ env.$GITHUB_SERVER_URL }} + origin-repo: user1/originrepo + origin-token: ${{ secrets.ORIGIN_TOKEN }} + destination-url: ${{ env.$GITHUB_SERVER_URL }} + destination-repo: user2/destinationrepo + destination-token: ${{ secrets.DESTINATION_TOKEN }} + update: upgraded + debug: true diff --git a/tests/run.sh b/tests/run.sh index 3345abd..c25e8ce 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -31,7 +31,19 @@ function user_curl() { ) } -function create_user() { +function user_token() { + local username=$1 name=$2 + + curl -sS -f -H Content-Type:application/json --user "$username:${options[password]}" --data-raw '{"name":"'$name'","scopes":["write:repository","write:issue"]}' ${options[url]}/api/v1/users/$username/tokens | jq --raw-output .sha1 +} + +function user_secret() { + local username=$1 name=$2 token=$3 + + user_curl $username api_json -X PUT --data-raw '{"data":"'$token'"}' ${options[url]}/api/v1/repos/user1/originrepo/actions/secrets/$name +} + +function user_create() { local username="$1" email="$2" forgejo-curl.sh api_json -X DELETE ${options[url]}/api/v1/admin/users/$username?purge=true >& /dev/null || true forgejo-curl.sh api_json --data-raw '{"username":"'$username'","email":"'$email'","password":"'${options[password]}'","must_change_password":false}' ${options[url]}/api/v1/admin/users @@ -39,10 +51,13 @@ function create_user() { } function run() { - create_user user1 user1@example.com - forgejo-test-helper.sh push tests/originrepo http://user1:admin1234@${options[host_port]} user1 originrepo cascading-pr + user_create user2 user2@example.com + forgejo-test-helper.sh push tests/destinationrepo http://user2:admin1234@${options[host_port]} user2 destinationrepo - create_user user2 user2@example.com + user_create user1 user1@example.com + forgejo-test-helper.sh push tests/originrepo http://user1:admin1234@${options[host_port]} user1 originrepo cascading-pr + user_secret user1 ORIGIN_TOKEN $(user_token user1 ORIGIN_TOKEN) + user_secret user1 DESTINATION_TOKEN $(user_token user2 DESTINATION_TOKEN) push_self ${options[host_port]}