actions: cache-pull-request: pull request and cache isolation (#1062)
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>
This commit is contained in:
parent
14d2748a33
commit
069ca6777e
8 changed files with 224 additions and 1 deletions
78
actions/example-cache-pull-request/run.sh
Executable file
78
actions/example-cache-pull-request/run.sh
Executable file
|
|
@ -0,0 +1,78 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue