mirror of
https://codeberg.org/scip/jaildk.git
synced 2025-12-19 21:51:02 +01:00
add docs and pipeline
This commit is contained in:
62
.woodpecker/README.md
Normal file
62
.woodpecker/README.md
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
## Running CI Tests with Woodpecker-CI on FreeBSD
|
||||||
|
|
||||||
|
By default the woodpecker intance on Codeberg doesn't support
|
||||||
|
FreeBSD. Running FreeBSD inside a qemu VM in a linux docker image
|
||||||
|
didn't work. So, this is my setup:
|
||||||
|
|
||||||
|
I deployed a freebsd VM on Hetzner Cloud: `ci-agent.daemon.de`. It
|
||||||
|
runs the `woodpecker-agent` build for freebsd.
|
||||||
|
|
||||||
|
The VM does **NOT** run continuously. So in order to execute
|
||||||
|
workflows, first unsuspend the VM:
|
||||||
|
|
||||||
|
```default
|
||||||
|
hcloud server poweron ci-agent
|
||||||
|
```
|
||||||
|
|
||||||
|
When it's running, execute workflows (i.e. push).
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
Deploy a new FreeBSD VM using the latest freebsd-snapshot.
|
||||||
|
|
||||||
|
Upgrade to latest Release (or the one you want to run tests on).
|
||||||
|
|
||||||
|
Clone [woodpecker-ci](https://github.com/woodpecker-ci/woodpecker).
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
|
||||||
|
```default
|
||||||
|
make build-agent GOOS=freebsd
|
||||||
|
```
|
||||||
|
|
||||||
|
Clone [plugin-git](https://github.com/woodpecker-ci/plugin-git.git)
|
||||||
|
|
||||||
|
Execute:
|
||||||
|
|
||||||
|
```default
|
||||||
|
GOOS=freebsd go build
|
||||||
|
```
|
||||||
|
|
||||||
|
Copy the newly built binaries `dist/woodpecker-agent` into the VM to
|
||||||
|
`/usr/local/bin`.
|
||||||
|
|
||||||
|
```default
|
||||||
|
scp woodpecker-ci/dist/woodpecker-agent agent:/usr/local/bin/
|
||||||
|
scp plugin-git/plugin-git agent:/usr/local/bin/
|
||||||
|
```
|
||||||
|
|
||||||
|
Add the agent token to `/etc/rc.conf`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
woodpeckeragent_enable=YES
|
||||||
|
woodpeckeragent_token=*****
|
||||||
|
```
|
||||||
|
|
||||||
|
Create the [rc-Script](woodpeckeragent.sh) in
|
||||||
|
`/usr/local/etc/rc.d/woodpeckeragent`.
|
||||||
|
|
||||||
|
Install `git-lfs`: `pkg install bash git git-lfs`.
|
||||||
|
|
||||||
|
|
||||||
|
Start it: `service woodpeckeragent start`
|
||||||
16
.woodpecker/assets/jail.conf
Normal file
16
.woodpecker/assets/jail.conf
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
* {
|
||||||
|
exec.start = "/bin/sh /etc/rc";
|
||||||
|
exec.stop = "/bin/sh /etc/rc.shutdown";
|
||||||
|
allow.raw_sockets = "false";
|
||||||
|
sysvmsg = "new";
|
||||||
|
sysvsem = "new";
|
||||||
|
sysvshm = "new";
|
||||||
|
host.hostname = $name;
|
||||||
|
path = "/jail/run/$name";
|
||||||
|
exec.prestart = "/jail/bin/jaildk install $name start";
|
||||||
|
exec.clean = "true";
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
ip4.addr = "172.16.0.1";
|
||||||
|
}
|
||||||
@@ -1,14 +1,47 @@
|
|||||||
matrix:
|
#
|
||||||
platform:
|
# CAUTION: this pipeline needs a FreeBSD VM, refer for the README.md
|
||||||
- freebsd/amd64
|
# in this directory for details!
|
||||||
|
|
||||||
|
variables:
|
||||||
|
# will be mapped to *release
|
||||||
|
&release 14.3-RELEASE
|
||||||
|
|
||||||
labels:
|
labels:
|
||||||
platform: ${platform}
|
platform: freebsd/amd64
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
test:
|
test:
|
||||||
image: bash
|
image: bash
|
||||||
when:
|
when:
|
||||||
event: [push]
|
event: [push]
|
||||||
commands:
|
commands: |
|
||||||
- freebsd-version
|
freebsd-version
|
||||||
|
uname -a
|
||||||
|
sysctl hw.model
|
||||||
|
sysctl hw.ncpu
|
||||||
|
sysctl hw.physmem
|
||||||
|
sysctl hw.usermem
|
||||||
|
|
||||||
|
ifconfig vtnet0 172.16.0.1/32 alias
|
||||||
|
ifconfig vtnet0
|
||||||
|
|
||||||
|
sysrc jail_enable="YES"
|
||||||
|
cp .woodpecker/assets/jail.conf /etc/
|
||||||
|
|
||||||
|
cp src/jaildk.sh jaildk
|
||||||
|
sh jaildk setup /jail
|
||||||
|
|
||||||
|
fetch https://download.freebsd.org/ftp/releases/amd64/amd64/*release/base.txz -o /jail/base/*release-base.txz
|
||||||
|
mkdir -p /jail/base/*release
|
||||||
|
tar -xf /jail/base/*release-base.txz -C /jail/base/*release --unlink
|
||||||
|
|
||||||
|
/jail/bin/jaildk create test
|
||||||
|
ls -l /jail/etc/test
|
||||||
|
/jail/bin/jaildk build test -m start
|
||||||
|
df -h /jail/build/test/etc
|
||||||
|
|
||||||
|
echo 'sshd_enable="Yes"' > /jail/build/test/usr/local/etc/rc.conf
|
||||||
|
chroot /jail/build/test /etc/rc.d/sshd keygen
|
||||||
|
|
||||||
|
/jail/bin/jaildk start test
|
||||||
|
/jail/bin/jaildk status | grep -E "test|Jail"
|
||||||
|
|||||||
37
.woodpecker/woodpeckeragent.sh
Normal file
37
.woodpecker/woodpeckeragent.sh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# PROVIDE: woodpeckeragent
|
||||||
|
# REQUIRE: LOGIN
|
||||||
|
# KEYWORD: shutdown
|
||||||
|
#
|
||||||
|
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
|
||||||
|
# to enable this service:
|
||||||
|
#
|
||||||
|
# woodpeckeragent_enable (bool): Set to NO by default.
|
||||||
|
# Set it to YES to enable woodpeckeragent.
|
||||||
|
|
||||||
|
. /etc/rc.subr
|
||||||
|
|
||||||
|
name=woodpeckeragent
|
||||||
|
rcvar=woodpeckeragent_enable
|
||||||
|
|
||||||
|
load_rc_config $name
|
||||||
|
|
||||||
|
: ${woodpeckeragent_enable:="NO"}
|
||||||
|
: ${woodpeckeragent_token:="foo"}
|
||||||
|
: ${woodpeckeragent_server:="grpc.ci.codeberg.org"}
|
||||||
|
|
||||||
|
|
||||||
|
pidfile=/var/run/woodpeckeragent.pid
|
||||||
|
command="/usr/sbin/daemon"
|
||||||
|
procname="/usr/local/bin/woodpecker-agent"
|
||||||
|
command_args="-f -p ${pidfile} -T ${name} \
|
||||||
|
/usr/bin/env PATH=$PATH:/usr/local/bin ${procname} \
|
||||||
|
--server ${woodpeckeragent_server} \
|
||||||
|
--grpc-token ${woodpeckeragent_token} \
|
||||||
|
--grpc-secure true \
|
||||||
|
--agent-config /tmp/woodpecker-agent \
|
||||||
|
--log-level debug"
|
||||||
|
|
||||||
|
load_rc_config $name
|
||||||
|
run_rc_command "$1"
|
||||||
Reference in New Issue
Block a user