Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/1062 Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Reviewed-by: Mathieu Fenniak <mfenniak@noreply.code.forgejo.org> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
78 lines
2.4 KiB
Bash
Executable file
78 lines
2.4 KiB
Bash
Executable file
TMPDIR=$(mktemp -d)
|
|
|
|
trap "rm -fr $TMPDIR" EXIT
|
|
|
|
api=$url/api/v1
|
|
export d=/srv/example/cache-pull-request
|
|
|
|
function main() {
|
|
mkdir -p $d
|
|
|
|
#
|
|
# open a pull request
|
|
# - from the same repository
|
|
# - from a forked repository
|
|
#
|
|
forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token
|
|
|
|
forgejo-curl.sh api_json --data-raw '{"username":"cache-fork-org"}' $api/orgs
|
|
forgejo-curl.sh api_json --data-raw '{"organization":"cache-fork-org"}' $api/repos/root/example-cache-pull-request/forks
|
|
|
|
(
|
|
cd $d
|
|
git clone $url/cache-fork-org/example-cache-pull-request fork
|
|
cd fork
|
|
git config user.email root@example.com
|
|
git config user.name username
|
|
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":"cache-fork-org:main"}' $api/repos/root/example-cache-pull-request/pulls
|
|
|
|
(
|
|
cd $d
|
|
git clone $url/root/example-cache-pull-request
|
|
cd example-cache-pull-request
|
|
git checkout -b other
|
|
git config user.email root@example.com
|
|
git config user.name username
|
|
touch file-unique-to-the-forked-pr
|
|
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-cache-pull-request/pulls
|
|
|
|
export RETRY_DELAYS="10 20 60 60 60 60 60"
|
|
|
|
#
|
|
# wait for the opened event to succeed using the cache on all pull requests
|
|
#
|
|
if ! forgejo.sh retry $EXAMPLE_DIR/assert-contexts-opened.sh; then
|
|
find $d
|
|
sed -e 's/^/[RUNNER LOGS]/' <$FORGEJO_RUNNER_LOGS
|
|
return 1
|
|
fi
|
|
|
|
#
|
|
# merge all pull requests
|
|
#
|
|
forgejo-curl.sh api_json $api/repos/root/example-cache-pull-request/pulls | jq -r '.[] | .number' | while read pr; do
|
|
forgejo-curl.sh api_json --data-raw '{"Do":"merge"}' $api/repos/root/example-cache-pull-request/pulls/$pr/merge
|
|
done
|
|
|
|
#
|
|
# wait for the closed event to succeed using the cache on all pull requests
|
|
#
|
|
if ! forgejo.sh retry $EXAMPLE_DIR/assert-contexts-closed.sh; then
|
|
find $d
|
|
sed -e 's/^/[RUNNER LOGS]/' <$FORGEJO_RUNNER_LOGS
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
main
|