end-to-end/actions/example-pull-request/run.sh

58 lines
1.6 KiB
Bash
Executable file

api=$url/api/v1
export d=/srv/example/pull-request
PROOF='some proof'
function main() {
mkdir -p $d
forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token
forgejo-curl.sh api_json --data-raw '{"username":"fork-org"}' $api/orgs
forgejo-curl.sh api_json --data-raw '{"organization":"fork-org"}' $api/repos/root/example-pull-request/forks
forgejo-curl.sh api_json -X PUT --data-raw '{"data":"AAAA"}' $api/repos/root/example-pull-request/actions/secrets/SECRET
(
cd $d
git clone $url/fork-org/example-pull-request fork
cd fork
git config user.email root@example.com
git config user.name username
echo fork $PROOF >> README
touch file-unique-to-the-pr-branch
git add .
git commit -m 'fork change'
git push
)
forgejo.sh retry forgejo-curl.sh api_json --data-raw '{"title":"PR from fork","base":"main","head":"fork-org:main"}' $api/repos/root/example-pull-request/pulls
(
cd $d
git clone $url/root/example-pull-request
cd example-pull-request
git checkout -b other
git config user.email root@example.com
git config user.name username
touch file-unique-to-the-pr-branch
echo other $PROOF >> README
git add .
git commit -m 'other change'
git push --force -u origin other
)
forgejo.sh retry forgejo-curl.sh api_json --data-raw '{"title":"PR same repo","base":"main","head":"other"}' $api/repos/root/example-pull-request/pulls
export RETRY_DELAYS="60 60 60 60 60 60 60"
for assert in $EXAMPLE_DIR/assert-*.sh ; do
if ! forgejo.sh retry $assert ; then
find $d
sed -e 's/^/[RUNNER LOGS]/' < $FORGEJO_RUNNER_LOGS
false
fi
done
}
main