Add Gitea build, container tests and registry publication
All checks were successful
Build, test and publish / verify (push) Successful in 1m41s
All checks were successful
Build, test and publish / verify (push) Successful in 1m41s
This commit is contained in:
17
ci/runner/agiledancers-runner.service
Normal file
17
ci/runner/agiledancers-runner.service
Normal file
@@ -0,0 +1,17 @@
|
||||
[Unit]
|
||||
Description=Agiledancers Gitea Actions runner
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=%h/.local/share/agiledancers-runner
|
||||
EnvironmentFile=%h/.config/agiledancers-runner/environment
|
||||
ExecStart=%h/.local/bin/act_runner daemon --config %h/.local/share/agiledancers-runner/config.yaml
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
KillSignal=SIGTERM
|
||||
TimeoutStopSec=150
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
11
ci/runner/config.yaml
Normal file
11
ci/runner/config.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
log:
|
||||
level: info
|
||||
runner:
|
||||
file: .runner
|
||||
capacity: 1
|
||||
timeout: 2h
|
||||
shutdown_timeout: 2m
|
||||
labels:
|
||||
- agiledancers-mini-pc:host
|
||||
cache:
|
||||
enabled: false
|
||||
32
ci/runner/configure-docker.py
Normal file
32
ci/runner/configure-docker.py
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Merge this project's HTTP registry into a selected daemon JSON file."""
|
||||
import json
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
sys.exit('Usage: python3 ci/runner/configure-docker.py <daemon.json>')
|
||||
path = Path(sys.argv[1]).expanduser()
|
||||
data = json.loads(path.read_text()) if path.exists() else {}
|
||||
registries = data.setdefault('insecure-registries', [])
|
||||
if not isinstance(registries, list):
|
||||
sys.exit('Existing insecure-registries must be an array; configuration left unchanged')
|
||||
if '192.168.2.28:3000' in registries:
|
||||
print('Internal registry already configured; no change')
|
||||
sys.exit(0)
|
||||
registries.append('192.168.2.28:3000')
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
if path.exists():
|
||||
backup = path.with_name(path.name + '.before-agiledancers')
|
||||
if not backup.exists():
|
||||
shutil.copy2(path, backup)
|
||||
# Write in the same directory, then replace atomically.
|
||||
temporary = path.with_name(path.name + '.agiledancers.tmp')
|
||||
with temporary.open('x') as output:
|
||||
json.dump(data, output, indent=2)
|
||||
output.write('\n')
|
||||
if path.exists():
|
||||
shutil.copymode(path, temporary)
|
||||
temporary.replace(path)
|
||||
print('Internal registry added; restart/apply Docker Engine configuration to activate')
|
||||
3
ci/runner/docker-daemon.json
Normal file
3
ci/runner/docker-daemon.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"insecure-registries": ["192.168.2.28:3000"]
|
||||
}
|
||||
52
ci/runner/install.sh
Normal file
52
ci/runner/install.sh
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run as the development user, not root. Configuration stays outside the checkout.
|
||||
set -Eeuo pipefail
|
||||
script_dir=$(cd -- "$(dirname -- "$0")" && pwd)
|
||||
runner_dir="$HOME/.local/share/agiledancers-runner"
|
||||
config_dir="$HOME/.config/agiledancers-runner"
|
||||
install -d -m 700 "$runner_dir" "$config_dir" "$HOME/.local/bin" "$HOME/.config/systemd/user"
|
||||
[[ "$(uname -s)/$(uname -m)" == Linux/x86_64 ]] || { echo 'This installer targets the existing Linux x86_64 mini-PC'; exit 1; }
|
||||
for tool in node java mvn docker curl python3 flock timeout; do command -v "$tool" >/dev/null; done
|
||||
: "${JAVA_HOME:?Set JAVA_HOME to your JDK 25 directory}"
|
||||
"$JAVA_HOME/bin/java" -version 2>&1 | grep -Eq 'version "25[.\"]' || { echo 'JDK 25 required'; exit 1; }
|
||||
node -e 'const [a,b,c]=process.versions.node.split(".").map(Number); if (!((a===22&&(b>22||(b===22&&c>=3)))||(a===24&&(b>15||(b===15&&c>=0)))||a>=26)) process.exit(1)'
|
||||
if [[ ! -x "$HOME/.local/bin/act_runner" ]]; then
|
||||
download_dir=$(mktemp -d)
|
||||
trap 'rm -rf -- "$download_dir"' EXIT
|
||||
curl --fail --location --retry 3 \
|
||||
https://dl.gitea.com/act_runner/0.2.13/act_runner-0.2.13-linux-amd64 -o "$download_dir/act_runner"
|
||||
printf '%s %s\n' 3acac8b506ac8cadc88a55155b5d6378f0fab0b8f62d1e0c0450f4ccd69733e2 "$download_dir/act_runner" | sha256sum --check
|
||||
install -m 755 "$download_dir/act_runner" "$HOME/.local/bin/act_runner"
|
||||
fi
|
||||
"$HOME/.local/bin/act_runner" --version | grep -F 'v0.2.13'
|
||||
install -m 600 "$script_dir/config.yaml" "$runner_dir/config.yaml"
|
||||
install -m 644 "$script_dir/agiledancers-runner.service" "$HOME/.config/systemd/user/agiledancers-runner.service"
|
||||
# Resolve paths now: user services do not inherit an interactive shell's PATH/context.
|
||||
node_dir=$(dirname -- "$(command -v node)")
|
||||
maven_dir=$(dirname -- "$(command -v mvn)")
|
||||
docker_host=${DOCKER_HOST:-$(docker context inspect --format '{{.Endpoints.docker.Host}}')}
|
||||
umask 077
|
||||
printf 'JAVA_HOME=%s\nPATH=%s/bin:%s:%s:/usr/local/bin:/usr/bin:/bin\nDOCKER_HOST=%s\n' \
|
||||
"$JAVA_HOME" "$JAVA_HOME" "$node_dir" "$maven_dir" "$docker_host" > "$config_dir/environment"
|
||||
systemctl --user daemon-reload
|
||||
if [[ "${1:-}" == --prepare-only ]]; then
|
||||
echo 'Runner installed; registration and startup still required.'
|
||||
exit 0
|
||||
fi
|
||||
docker info >/dev/null
|
||||
if [[ ! -f "$runner_dir/.runner" ]]; then
|
||||
token_file=${RUNNER_REGISTRATION_TOKEN_FILE:-$config_dir/registration-token}
|
||||
[[ -f "$token_file" ]] || { echo "Place the repository runner registration token in $token_file (mode 600), then rerun."; exit 1; }
|
||||
registration_token=$(cat "$token_file")
|
||||
[[ -n "$registration_token" ]] || { echo 'Empty registration token'; exit 1; }
|
||||
(
|
||||
cd "$runner_dir"
|
||||
"$HOME/.local/bin/act_runner" register --no-interactive \
|
||||
--instance http://192.168.2.28:3000 --name agiledancers-mini-pc \
|
||||
--labels agiledancers-mini-pc:host --token "$registration_token"
|
||||
chmod 600 .runner
|
||||
)
|
||||
unset registration_token
|
||||
fi
|
||||
systemctl --user enable --now agiledancers-runner.service
|
||||
echo 'Runner registered and started. The mini-PC and Docker must remain available.'
|
||||
Reference in New Issue
Block a user