mirror of
https://code.forgejo.org/actions/setup-forgejo.git
synced 2024-11-23 22:40:58 -05:00
integration
This commit is contained in:
parent
6ee8ee9999
commit
c92246a058
5 changed files with 69 additions and 9 deletions
|
@ -6,8 +6,18 @@ jobs:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- run: |
|
- run: |
|
||||||
set -x
|
set -x
|
||||||
echo deb http://deb.debian.org/debian bullseye-backports main | tee /etc/apt/sources.list.d/backports.list && apt-get update
|
./lxc.sh
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --quiet -y -t bullseye-backports git docker.io
|
./docker.sh
|
||||||
./forgejo.sh setup root admin1234 codeberg.org/forgejo/forgejo:1.19
|
./forgejo.sh setup root admin1234 codeberg.org/forgejo/forgejo:1.19
|
||||||
./forgejo-runner.sh setup
|
./forgejo-runner.sh setup
|
||||||
testdata/run.sh main http://root:admin1234@$(cat forgejo-ip):3000 root demo
|
#
|
||||||
|
# Can this Forgejo & runner combination...
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# ...run a demo workflow (stage 0)
|
||||||
|
#
|
||||||
|
# testdata/run.sh workflow http://root:admin1234@$(cat forgejo-ip):3000 root demo
|
||||||
|
#
|
||||||
|
# ...run this integration test (stage 1)
|
||||||
|
#
|
||||||
|
testdata/run.sh self http://root:admin1234@$(cat forgejo-ip):3000 root
|
||||||
|
|
12
docker.sh
Executable file
12
docker.sh
Executable file
|
@ -0,0 +1,12 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
if ! systemctl is-active --quiet docker; then
|
||||||
|
echo deb http://deb.debian.org/debian bullseye-backports main | tee /etc/apt/sources.list.d/backports.list && apt-get update
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --quiet -y -t bullseye-backports git docker.io
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
setup
|
|
@ -35,7 +35,7 @@ function build() {
|
||||||
function register() {
|
function register() {
|
||||||
local forgejo="$1"
|
local forgejo="$1"
|
||||||
docker exec --user 1000 forgejo forgejo actions --registration-token-admin > forgejo-runner-token
|
docker exec --user 1000 forgejo forgejo actions --registration-token-admin > forgejo-runner-token
|
||||||
timeout --signal=KILL 30 ./forgejo-runner/forgejo-runner register --no-interactive --instance "$forgejo" --name runner --token $(cat forgejo-runner-token)
|
timeout --signal=KILL 30 ./forgejo-runner/forgejo-runner register --no-interactive --instance "$forgejo" --name runner --token $(cat forgejo-runner-token) --labels ubuntu-latest:docker://node:16-buster,self-hosted
|
||||||
}
|
}
|
||||||
|
|
||||||
function run() {
|
function run() {
|
||||||
|
|
23
lxc.sh
Executable file
23
lxc.sh
Executable file
|
@ -0,0 +1,23 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
if ! systemctl is-active --quiet lxc-net; then
|
||||||
|
apt-get update
|
||||||
|
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq make git libvirt0 libpam-cgfs bridge-utils uidmap dnsmasq-base dnsmasq dnsmasq-utils qemu-user-static
|
||||||
|
systemctl disable --now dnsmasq
|
||||||
|
apt-get install -y -qq lxc
|
||||||
|
systemctl stop lxc-net
|
||||||
|
cat >> /etc/default/lxc-net <<'EOF'
|
||||||
|
LXC_ADDR="10.0.7.1"
|
||||||
|
LXC_NETMASK="255.255.255.0"
|
||||||
|
LXC_NETWORK="10.0.7.0/24"
|
||||||
|
LXC_DHCP_RANGE="10.0.7.2,10.0.7.254"
|
||||||
|
LXC_DHCP_MAX="253"
|
||||||
|
EOF
|
||||||
|
systemctl start lxc-net
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
setup
|
25
testdata/run.sh
vendored
25
testdata/run.sh
vendored
|
@ -39,10 +39,11 @@ function push() {
|
||||||
local owner="$2"
|
local owner="$2"
|
||||||
local workflow="$3"
|
local workflow="$3"
|
||||||
|
|
||||||
mkdir -p $DIR/.forgejo/workflows
|
local dir="$DIR/$workflow"
|
||||||
cp $DATA/$workflow.yml $DIR/.forgejo/workflows
|
mkdir -p $dir/.forgejo/workflows
|
||||||
|
cp $DATA/$workflow.yml $dir/.forgejo/workflows
|
||||||
(
|
(
|
||||||
cd $DIR
|
cd $dir
|
||||||
git init
|
git init
|
||||||
git checkout -b main
|
git checkout -b main
|
||||||
git config user.email root@example.com
|
git config user.email root@example.com
|
||||||
|
@ -55,13 +56,27 @@ function push() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
function workflow() {
|
||||||
local forgejo="${1:-http://root:admin1234@$(forgejo-ip):3000}"
|
local forgejo="${1:-http://root:admin1234@$(forgejo-ip):3000}"
|
||||||
local owner="${2:-root}"
|
local owner="${2:-root}"
|
||||||
local workflow="${3:-demo}"
|
local workflow="${3:-demo}"
|
||||||
|
|
||||||
push "$forgejo" "$owner" "$workflow"
|
push "$forgejo" "$owner" "$workflow"
|
||||||
wait_success "$forgejo" "$owner/$workflow" $(cat $DIR/SHA)
|
wait_success "$forgejo" "$owner/$workflow" $(cat $DIR/$workflow/SHA)
|
||||||
|
}
|
||||||
|
|
||||||
|
function self() {
|
||||||
|
local forgejo="$1"
|
||||||
|
local owner="$2"
|
||||||
|
|
||||||
|
local dir="$DIR/self"
|
||||||
|
if git remote | grep -q test-setup-forgejo; then
|
||||||
|
git remote rm test-setup-forgejo
|
||||||
|
fi
|
||||||
|
git remote add test-setup-forgejo $forgejo/$owner/setup-forgejo
|
||||||
|
git push test-setup-forgejo HEAD:main
|
||||||
|
|
||||||
|
wait_success "$forgejo" "$owner/setup-forgejo" $(git rev-parse HEAD)
|
||||||
}
|
}
|
||||||
|
|
||||||
"$@"
|
"$@"
|
||||||
|
|
Loading…
Reference in a new issue