mirror of
https://code.forgejo.org/actions/cascading-pr
synced 2025-03-15 14:54:40 +01:00
initial
This commit is contained in:
parent
c1016ee0f2
commit
7d02d44019
5 changed files with 223 additions and 51 deletions
84
.forgejo/run-test.sh
Executable file
84
.forgejo/run-test.sh
Executable file
|
@ -0,0 +1,84 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
VERBOSE=false
|
||||||
|
DEBUG=false
|
||||||
|
: ${EXIT_ON_ERROR:=true}
|
||||||
|
|
||||||
|
function debug() {
|
||||||
|
DEBUG=true
|
||||||
|
set -x
|
||||||
|
PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: '
|
||||||
|
}
|
||||||
|
|
||||||
|
function verbose() {
|
||||||
|
VERBOSE=true
|
||||||
|
}
|
||||||
|
|
||||||
|
function log() {
|
||||||
|
echo "$@" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
function log_error() {
|
||||||
|
log "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
function log_verbose() {
|
||||||
|
if $VERBOSE ; then
|
||||||
|
log "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function log_info() {
|
||||||
|
log "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
function fatal_error() {
|
||||||
|
log_error "$@"
|
||||||
|
if $EXIT_ON_ERROR ; then
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function push_self() {
|
||||||
|
local host_port=$1
|
||||||
|
|
||||||
|
forgejo-test-helper.sh push_self_action http://root:admin1234@$host_port root cascading-pr vTest
|
||||||
|
}
|
||||||
|
|
||||||
|
function run() {
|
||||||
|
local host_port=$1 url=$2 token=$3
|
||||||
|
|
||||||
|
push_self $host_port
|
||||||
|
|
||||||
|
echo do something
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
local command=run
|
||||||
|
local host_port=$(cat forgejo-ip):3000
|
||||||
|
local url=http://$host_port
|
||||||
|
local token=$(cat forgejo-token)
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
case "$1" in
|
||||||
|
--verbose)
|
||||||
|
shift
|
||||||
|
verbose
|
||||||
|
;;
|
||||||
|
--debug)
|
||||||
|
shift
|
||||||
|
debug
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
"${1:-run}" "$host_port" "$url" "$token"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
${MAIN:-main} "${@}"
|
96
.forgejo/workflows/integration.yml
Normal file
96
.forgejo/workflows/integration.yml
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
name: integration
|
||||||
|
|
||||||
|
on: [push, pull_request_target]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
integration:
|
||||||
|
runs-on: self-hosted
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- id: forgejo
|
||||||
|
uses: https://code.forgejo.org/actions/setup-forgejo@v1
|
||||||
|
with:
|
||||||
|
user: root
|
||||||
|
password: admin1234
|
||||||
|
image: codeberg.org/forgejo-integration/forgejo
|
||||||
|
image-version: 1.21.0-3-rc0
|
||||||
|
lxc-ip-prefix: 10.1.15
|
||||||
|
|
||||||
|
- name: tests
|
||||||
|
run: |
|
||||||
|
.forgejo/run-test.sh
|
||||||
|
forgejo-test-helper.sh push_self_action http://root:admin1234@${{ steps.forgejo.outputs.host-port }} root forgejo-release vTest
|
||||||
|
|
||||||
|
- name: admin user create --username testuser
|
||||||
|
run: |
|
||||||
|
forgejo='docker exec --user 1000 forgejo forgejo'
|
||||||
|
user=testuser
|
||||||
|
if ! $forgejo admin user list | grep -q "$user" ; then
|
||||||
|
$forgejo admin user create --username "$user" --password "admin1324" --email "$user@example.com"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: build & publish
|
||||||
|
run: |
|
||||||
|
set -x
|
||||||
|
|
||||||
|
version=1.2.3
|
||||||
|
cat > /etc/docker/daemon.json <<EOF
|
||||||
|
{
|
||||||
|
"insecure-registries" : ["${{ steps.forgejo.outputs.host-port }}"]
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
systemctl restart docker
|
||||||
|
|
||||||
|
apt-get install -qq -y xz-utils
|
||||||
|
|
||||||
|
dir=$(mktemp -d)
|
||||||
|
trap "rm -fr $dir" EXIT
|
||||||
|
|
||||||
|
url=http://root:admin1234@${{ steps.forgejo.outputs.host-port }}
|
||||||
|
export FORGEJO_RUNNER_LOGS="${{ steps.forgejo.outputs.runner-logs }}"
|
||||||
|
|
||||||
|
cp -a testdata/.forgejo testdata/* $dir
|
||||||
|
|
||||||
|
#
|
||||||
|
# root/forgejo: owner & repository in which the release will be built
|
||||||
|
#
|
||||||
|
forgejo-test-helper.sh push $dir $url root forgejo forgejo-release ${{ steps.forgejo.outputs.token }} |& tee $dir/pushed
|
||||||
|
eval $(grep '^sha=' < $dir/pushed)
|
||||||
|
#
|
||||||
|
# testuser/forgejo: owner & repository in which the release will be published
|
||||||
|
#
|
||||||
|
(
|
||||||
|
git clone $url/root/forgejo tmp-forgejo
|
||||||
|
cd tmp-forgejo
|
||||||
|
git push $url/testuser/forgejo main
|
||||||
|
)
|
||||||
|
|
||||||
|
#
|
||||||
|
# Push a tag to trigger the build workflow and wait for it to complete
|
||||||
|
#
|
||||||
|
forgejo-test-helper.sh api POST $url repos/root/forgejo/tags ${{ steps.forgejo.outputs.token }} --data-raw '{"tag_name": "v'$version'", "target": "'$sha'"}'
|
||||||
|
LOOPS=180 forgejo-test-helper.sh wait_success "$url" root/forgejo $sha
|
||||||
|
|
||||||
|
#
|
||||||
|
# uncomment to see the logs even when everything is reported to be working ok
|
||||||
|
#
|
||||||
|
#cat $FORGEJO_RUNNER_LOGS
|
||||||
|
|
||||||
|
for user in root testuser ; do
|
||||||
|
for arch in amd64 arm64 ; do
|
||||||
|
binary=software-$version-linux-$arch
|
||||||
|
for suffix in '' '.xz' ; do
|
||||||
|
curl --fail -L -sS $url/$user/forgejo/releases/download/v$version/$binary$suffix > $binary$suffix
|
||||||
|
if test "$suffix" = .xz ; then
|
||||||
|
unxz --keep $binary$suffix
|
||||||
|
fi
|
||||||
|
chmod +x $binary
|
||||||
|
./$binary --version | grep $version
|
||||||
|
curl --fail -L -sS $url/$user/forgejo/releases/download/v$version/$binary$suffix.sha256 > $binary$suffix.sha256
|
||||||
|
shasum -a 256 --check $binary$suffix.sha256
|
||||||
|
rm $binary$suffix
|
||||||
|
done
|
||||||
|
done
|
||||||
|
docker pull ${{ steps.forgejo.outputs.host-port }}/$user/forgejo:$version
|
||||||
|
done
|
54
.gitignore
vendored
54
.gitignore
vendored
|
@ -1,51 +1,5 @@
|
||||||
# ---> Emacs
|
forgejo-token
|
||||||
# -*- mode: gitignore; -*-
|
forgejo-api
|
||||||
|
forgejo-header
|
||||||
|
forgejo-ip
|
||||||
*~
|
*~
|
||||||
\#*\#
|
|
||||||
/.emacs.desktop
|
|
||||||
/.emacs.desktop.lock
|
|
||||||
*.elc
|
|
||||||
auto-save-list
|
|
||||||
tramp
|
|
||||||
.\#*
|
|
||||||
|
|
||||||
# Org-mode
|
|
||||||
.org-id-locations
|
|
||||||
*_archive
|
|
||||||
|
|
||||||
# flymake-mode
|
|
||||||
*_flymake.*
|
|
||||||
|
|
||||||
# eshell files
|
|
||||||
/eshell/history
|
|
||||||
/eshell/lastdir
|
|
||||||
|
|
||||||
# elpa packages
|
|
||||||
/elpa/
|
|
||||||
|
|
||||||
# reftex files
|
|
||||||
*.rel
|
|
||||||
|
|
||||||
# AUCTeX auto folder
|
|
||||||
/auto/
|
|
||||||
|
|
||||||
# cask packages
|
|
||||||
.cask/
|
|
||||||
dist/
|
|
||||||
|
|
||||||
# Flycheck
|
|
||||||
flycheck_*.el
|
|
||||||
|
|
||||||
# server auth directory
|
|
||||||
/server/
|
|
||||||
|
|
||||||
# projectiles files
|
|
||||||
.projectile
|
|
||||||
|
|
||||||
# directory configuration
|
|
||||||
.dir-locals.el
|
|
||||||
|
|
||||||
# network security
|
|
||||||
/network-security.data
|
|
||||||
|
|
||||||
|
|
||||||
|
|
14
README.md
14
README.md
|
@ -1,3 +1,17 @@
|
||||||
# cascading-pr
|
# cascading-pr
|
||||||
|
|
||||||
Create a synchronize a PR is a dependent repository
|
Create a synchronize a PR is a dependent repository
|
||||||
|
|
||||||
|
# Hacking
|
||||||
|
|
||||||
|
```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.sh teardown
|
||||||
|
forgejo.sh setup root admin1234 codeberg.org/forgejo/forgejo 1.21
|
||||||
|
firefox http://$(cat forgejo-ip):3000
|
||||||
|
.forgejo/run-test.sh --debug
|
||||||
|
```
|
||||||
|
|
24
action.yml
Normal file
24
action.yml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
name: 'Cascading PR'
|
||||||
|
author: 'Forgejo authors'
|
||||||
|
description: |
|
||||||
|
Create and update a PR in another repository
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
forgejo:
|
||||||
|
description: 'URL of the Forgejo instance where the PR is created (e.g. https://code.forgejo.org)'
|
||||||
|
required: true
|
||||||
|
repo:
|
||||||
|
description: 'the repository into which the PR is created'
|
||||||
|
required: true
|
||||||
|
token:
|
||||||
|
description: 'a token with write permission on repo'
|
||||||
|
required: true
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- run: |
|
||||||
|
echo
|
||||||
|
shell: bash
|
Loading…
Add table
Reference in a new issue