integration

This commit is contained in:
Earl Warren 2023-03-25 16:06:50 +01:00
parent 6ee8ee9999
commit c92246a058
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
5 changed files with 69 additions and 9 deletions

View file

@ -6,8 +6,18 @@ jobs:
- uses: actions/checkout@v3
- run: |
set -x
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
./lxc.sh
./docker.sh
./forgejo.sh setup root admin1234 codeberg.org/forgejo/forgejo:1.19
./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
View 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

View file

@ -35,7 +35,7 @@ function build() {
function register() {
local forgejo="$1"
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() {

23
lxc.sh Executable file
View 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
View file

@ -39,10 +39,11 @@ function push() {
local owner="$2"
local workflow="$3"
mkdir -p $DIR/.forgejo/workflows
cp $DATA/$workflow.yml $DIR/.forgejo/workflows
local dir="$DIR/$workflow"
mkdir -p $dir/.forgejo/workflows
cp $DATA/$workflow.yml $dir/.forgejo/workflows
(
cd $DIR
cd $dir
git init
git checkout -b main
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 owner="${2:-root}"
local workflow="${3:-demo}"
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)
}
"$@"