mirror of
https://code.forgejo.org/actions/cascading-pr.git
synced 2025-04-24 17:42:14 +00:00
update HACKING instructions
This commit is contained in:
parent
28c365c695
commit
d92b2a7d3e
2 changed files with 21 additions and 7 deletions
14
README.md
14
README.md
|
@ -92,6 +92,20 @@ The test environment consists of the following (all users password is admin1234)
|
||||||
* An unprivileged user user2
|
* An unprivileged user user2
|
||||||
* The repository user2/destinationrepo
|
* The repository user2/destinationrepo
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git clone https://code.forgejo.org/actions/setup-forgejo
|
||||||
|
export PATH=$(pwd)/setup-forgejo:$PATH
|
||||||
|
git clone https://code.forgejo.org/actions/cascading-pr
|
||||||
|
cd cascading-pr
|
||||||
|
forgejo-curl.sh logout
|
||||||
|
forgejo-runner.sh teardown
|
||||||
|
forgejo.sh teardown
|
||||||
|
forgejo.sh setup root admin1234 codeberg.org/forgejo/forgejo 1.21
|
||||||
|
FORGEJO_RUNNER_CONFIG=$(pwd)/tests/runner-config.yaml forgejo-runner.sh setup
|
||||||
|
url=http://$(cat forgejo-ip):3000
|
||||||
|
firefox $url
|
||||||
|
```
|
||||||
|
|
||||||
The test for a successful run of the cascading-pr action consists of:
|
The test for a successful run of the cascading-pr action consists of:
|
||||||
|
|
||||||
* creating a PR from branch1 to main
|
* creating a PR from branch1 to main
|
||||||
|
|
14
tests/run.sh
14
tests/run.sh
|
@ -30,31 +30,31 @@ function user_curl() {
|
||||||
function user_token() {
|
function user_token() {
|
||||||
local username=$1 name=$2
|
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","read:user"]}' ${options[url]}/api/v1/users/$username/tokens | jq --raw-output .sha1 | tee $TMPDIR/$username/repo-token
|
curl -sS -f -H Content-Type:application/json --user "$username:${options[password]}" --data '{"name":"'$name'","scopes":["write:repository","write:issue","read:user"]}' ${options[url]}/api/v1/users/$username/tokens | jq --raw-output .sha1 | tee $TMPDIR/$username/repo-token
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_secret() {
|
function user_secret() {
|
||||||
local username=$1 name=$2 token=$3
|
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
|
user_curl $username api_json -X PUT --data '{"data":"'$token'"}' ${options[url]}/api/v1/repos/user1/originrepo/actions/secrets/$name
|
||||||
}
|
}
|
||||||
|
|
||||||
function user_create() {
|
function user_create() {
|
||||||
local username="$1" email="$2"
|
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 -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
|
forgejo-curl.sh api_json --data '{"username":"'$username'","email":"'$email'","password":"'${options[password]}'","must_change_password":false}' ${options[url]}/api/v1/admin/users
|
||||||
user_login $username
|
user_login $username
|
||||||
}
|
}
|
||||||
|
|
||||||
function close_pull_request() {
|
function close_pull_request() {
|
||||||
forgejo-curl.sh api_json ${options[url]}/api/v1/repos/user1/originrepo/pulls | jq --raw-output '.[] | .number' | while read pr ; do
|
forgejo-curl.sh api_json ${options[url]}/api/v1/repos/user1/originrepo/pulls | jq --raw-output '.[] | .number' | while read pr ; do
|
||||||
forgejo-curl.sh api_json -X PATCH --data-raw '{"state":"closed"}' ${options[url]}/api/v1/repos/user1/originrepo/issues/$pr
|
forgejo-curl.sh api_json -X PATCH --data '{"state":"closed"}' ${options[url]}/api/v1/repos/user1/originrepo/issues/$pr
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function merge_pull_request() {
|
function merge_pull_request() {
|
||||||
forgejo-curl.sh api_json ${options[url]}/api/v1/repos/user1/originrepo/pulls | jq --raw-output '.[] | .number' | while read pr ; do
|
forgejo-curl.sh api_json ${options[url]}/api/v1/repos/user1/originrepo/pulls | jq --raw-output '.[] | .number' | while read pr ; do
|
||||||
forgejo-curl.sh api_json --data-raw '{"Do":"merge"}' ${options[url]}/api/v1/repos/user1/originrepo/pulls/$pr/merge
|
forgejo-curl.sh api_json --data '{"Do":"merge"}' ${options[url]}/api/v1/repos/user1/originrepo/pulls/$pr/merge
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ function create_pull_request() {
|
||||||
forgejo-curl.sh api_json -X DELETE ${options[url]}/api/v1/repos/user1/originrepo/issues/$pr
|
forgejo-curl.sh api_json -X DELETE ${options[url]}/api/v1/repos/user1/originrepo/issues/$pr
|
||||||
done
|
done
|
||||||
forgejo-curl.sh api_json -X DELETE ${options[url]}/api/v1/repos/user1/originrepo/branches/branch1 >& /dev/null || true
|
forgejo-curl.sh api_json -X DELETE ${options[url]}/api/v1/repos/user1/originrepo/branches/branch1 >& /dev/null || true
|
||||||
forgejo-curl.sh api_json --data-raw '{"new_branch_name":"branch1"}' ${options[url]}/api/v1/repos/user1/originrepo/branches
|
forgejo-curl.sh api_json --data '{"new_branch_name":"branch1"}' ${options[url]}/api/v1/repos/user1/originrepo/branches
|
||||||
(
|
(
|
||||||
cd $TMPDIR
|
cd $TMPDIR
|
||||||
rm -fr originrepo
|
rm -fr originrepo
|
||||||
|
@ -78,7 +78,7 @@ function create_pull_request() {
|
||||||
git rev-parse HEAD > ../originrepo.sha
|
git rev-parse HEAD > ../originrepo.sha
|
||||||
)
|
)
|
||||||
|
|
||||||
forgejo-curl.sh api_json --data-raw '{"title":"PR","base":"main","head":"branch1"}' ${options[url]}/api/v1/repos/user1/originrepo/pulls
|
forgejo-curl.sh api_json --data '{"title":"PR","base":"main","head":"branch1"}' ${options[url]}/api/v1/repos/user1/originrepo/pulls
|
||||||
}
|
}
|
||||||
|
|
||||||
function finalize_options() {
|
function finalize_options() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue