1
0
Fork 0
mirror of https://code.forgejo.org/actions/cascading-pr synced 2025-03-15 14:54:40 +01:00

run.sh also runs in the CI

This commit is contained in:
Earl Warren 2023-10-13 15:23:50 +02:00
parent 84c728fdc5
commit 63ccad04bc
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
2 changed files with 20 additions and 6 deletions

View file

@ -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

View file

@ -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
;;