Compare commits
24
Commits
No files matched your search
@@ -1,9 +1,118 @@
|
||||
name: Linux checks
|
||||
description: Shared Linux validation for Gitea CI and release packaging.
|
||||
inputs:
|
||||
protocol-deploy-key:
|
||||
description: >
|
||||
Private half of the read-only deploy key registered on the private
|
||||
Voelin/VoelinProtocol repository (the repository secret
|
||||
VOELIN_PROTOCOL_DEPLOY_KEY, passed in by the workflow: secrets are not
|
||||
visible inside a composite action). The action fails when it is empty.
|
||||
required: true
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
# The workspace depends on the private VoelinProtocol repository over SSH
|
||||
# (docs/ci.md, "VoelinProtocol access"). First, so that a missing key fails
|
||||
# in seconds and before anything runs cargo.
|
||||
- name: Install the VoelinProtocol deploy key
|
||||
# The key reaches this step through the environment only: never in the
|
||||
# script text, never echoed, no `set -x`.
|
||||
env:
|
||||
PROTOCOL_DEPLOY_KEY: ${{ inputs.protocol-deploy-key }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
umask 077
|
||||
if [[ -z "${PROTOCOL_DEPLOY_KEY//[[:space:]]/}" ]]; then
|
||||
echo "::error::The VoelinProtocol deploy key is empty. Set the repository secret VOELIN_PROTOCOL_DEPLOY_KEY to the private key of the read-only deploy key on Voelin/VoelinProtocol (docs/ci.md, VoelinProtocol access). Pull requests from forks get no secrets." >&2
|
||||
exit 1
|
||||
fi
|
||||
for tool in ssh ssh-keygen; do
|
||||
command -v "$tool" > /dev/null || {
|
||||
echo "::error::The job image needs the OpenSSH client: $tool is missing." >&2
|
||||
exit 1
|
||||
}
|
||||
done
|
||||
ssh_dir="$HOME/.ssh"
|
||||
key_file="$ssh_dir/voelin_protocol"
|
||||
mkdir -p "$ssh_dir"
|
||||
chmod 700 "$ssh_dir"
|
||||
|
||||
# Whatever the secret store did to the line ends and the final newline,
|
||||
# OpenSSH needs LF lines, the BEGIN line first and a newline at the end.
|
||||
printf '%s\n' "$PROTOCOL_DEPLOY_KEY" | tr -d '\r' | sed '/^[[:space:]]*$/d' > "$key_file"
|
||||
unset PROTOCOL_DEPLOY_KEY
|
||||
chmod 600 "$key_file"
|
||||
if ! public=$(ssh-keygen -y -f "$key_file" < /dev/null); then
|
||||
rm -f "$key_file"
|
||||
echo "::error::VOELIN_PROTOCOL_DEPLOY_KEY is not an unencrypted OpenSSH or PEM private key." >&2
|
||||
exit 1
|
||||
fi
|
||||
# The fingerprint of the public half, to compare with the deploy key in
|
||||
# the VoelinProtocol settings.
|
||||
printf 'Deploy key installed: %s\n' "$(ssh-keygen -lf - <<< "$public")"
|
||||
|
||||
# The reviewed host key from the repository, never one fetched now.
|
||||
known_hosts="$ssh_dir/known_hosts"
|
||||
touch "$known_hosts"
|
||||
chmod 600 "$known_hosts"
|
||||
[[ -s "${GITHUB_WORKSPACE:-.}/.gitea/known_hosts" ]] || {
|
||||
echo "::error::.gitea/known_hosts is missing from the checkout." >&2
|
||||
exit 1
|
||||
}
|
||||
while IFS= read -r line; do
|
||||
case "$line" in '' | '#'*) continue ;; esac
|
||||
grep -qxF -- "$line" "$known_hosts" || printf '%s\n' "$line" >> "$known_hosts"
|
||||
done < "${GITHUB_WORKSPACE:-.}/.gitea/known_hosts"
|
||||
|
||||
# Use this key, and only this one, for the Gitea server; fail rather than
|
||||
# ask when its host key is unknown or changed. The block goes first: ssh
|
||||
# takes the first value it finds for each option.
|
||||
config="$ssh_dir/config"
|
||||
marker="# VoelinProtocol deploy key (.gitea/actions/checks)"
|
||||
touch "$config"
|
||||
if ! grep -qxF -- "$marker" "$config"; then
|
||||
{
|
||||
cat << EOF
|
||||
$marker
|
||||
Host git.faumaray.com
|
||||
User gitea
|
||||
IdentityFile $key_file
|
||||
IdentitiesOnly yes
|
||||
UserKnownHostsFile $known_hosts
|
||||
StrictHostKeyChecking yes
|
||||
BatchMode yes
|
||||
ConnectTimeout 30
|
||||
|
||||
EOF
|
||||
cat "$config"
|
||||
} > "$config.new"
|
||||
mv "$config.new" "$config"
|
||||
fi
|
||||
chmod 600 "$config"
|
||||
|
||||
# Cargo's built-in git client (libgit2) cannot use IdentityFile; the
|
||||
# system git runs ssh, which reads the config above. `-F` names it
|
||||
# outright: ssh looks for ~/.ssh in the passwd entry's home directory, not
|
||||
# in $HOME, and a job image may set the two apart.
|
||||
{
|
||||
echo "CARGO_NET_GIT_FETCH_WITH_CLI=true"
|
||||
echo "GIT_SSH_COMMAND=ssh -F '$config'"
|
||||
} >> "$GITHUB_ENV"
|
||||
shell: bash
|
||||
- uses: ./.github/actions/system-deps
|
||||
- name: Check read access to VoelinProtocol
|
||||
# The first thing cargo does, with the same git and ssh configuration, so
|
||||
# that a wrong key or a changed host key fails here with a clear message
|
||||
# and not minutes later inside a cargo command.
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if ! GIT_TERMINAL_PROMPT=0 timeout 120 git ls-remote --exit-code \
|
||||
ssh://gitea@git.faumaray.com/Voelin/VoelinProtocol.git HEAD > /dev/null; then
|
||||
echo "::error::git cannot read Voelin/VoelinProtocol over SSH with the deploy key. 'Permission denied (publickey)' above: the key is not registered on that repository (or is not the one in VOELIN_PROTOCOL_DEPLOY_KEY). 'Host key verification failed': .gitea/known_hosts no longer matches the server (docs/ci.md, VoelinProtocol access)." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Voelin/VoelinProtocol is readable with the deploy key."
|
||||
shell: bash
|
||||
- name: Install pinned Rust toolchain
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# SSH host key of git.faumaray.com (Gitea's built-in SSH server, which offers an
|
||||
# RSA host key only). Fingerprint SHA256:fugBYnqAnqmTLsGpafVgQF9gPQzJqps7uHvs48blg2A,
|
||||
# recorded on 2026-10-24 with `ssh-keyscan -t rsa git.faumaray.com`.
|
||||
#
|
||||
# Committed, never fetched while a job runs, so a CI or release build trusts the
|
||||
# key reviewed here and not whatever answers on the network at that moment.
|
||||
# Read by .gitea/actions/checks (appended to ~/.ssh/known_hosts) and COPYed by
|
||||
# docker/*.Dockerfile and crates/voelin-gateway/Dockerfile. How to re-check it
|
||||
# and how to rotate it: docs/ci.md, "VoelinProtocol access".
|
||||
git.faumaray.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCzZEz9JLrzk6oLiloSbueAN28vYL58Y/dTHBgRuBMMib9IJ1aDJShhr3kwC9sfOT0AzK0uwcMAqCAIkwJwttde8dIg0Mee0cmB/1JkoqFF4X3MUGD1r3nk8SSZNhIiPqo16hDF9Hf3FkovztIlBVntkyP9Iy9hYfP818Tiq3yRXROGdHjR7IfY4jR2QGfGrd/RtvPGExVqusxidy141240A8aRAwMFUqFdEvmXWjizrtCUqcrL/k1GEh0yJzbCdNOVUI6OuWd8tPluSBvmmeoNpKnCSl4Mkg36HObbOyrsme0asZqjcj0od65WYWApMPN0pUqhNu2CP83Nfor2VFwkdPRwe7cAZ0OD/8wyT6Hz5q1wWgf82y4tYDoDRYsd8JU86eebkJ07T5nCrEeC4Sj+qT4S5xv/kECAhxyP4QGnunORnY2fYsdNGzpPvbMN7gHe9UcIcQdOIgV3wrR1qpMVNcd8AEC2A3TRv/jzMCHSjmGGpgiy1Db2CZAjp5+PcjNmjvoPNN0NiA9X4rIVSeTfflWnDRmeNRJeZa73StjpU17EcAf97COUQPGWJQDgpJqINSpYU50fuaLBfzKnIRuiHjKQmyKe/zgRSmulnYFYM3AJfn8Ykg2VvkUQGvCt1+fqYiUa1iVFuwPP3ZigYF1mOZRpPnos5kaNmlB01q2sZw==
|
||||
@@ -20,6 +20,11 @@ on:
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
# Cargo fetches the private VoelinProtocol dependency with the system git and
|
||||
# ssh (docs/ci.md, "VoelinProtocol access"). The checks action exports this
|
||||
# too; set here as well, it does not depend on the runner handing a composite
|
||||
# action's GITHUB_ENV on to the later steps.
|
||||
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
|
||||
|
||||
jobs:
|
||||
linux:
|
||||
@@ -32,3 +37,8 @@ jobs:
|
||||
steps:
|
||||
- uses: https://github.com/actions/checkout@v4
|
||||
- uses: ./.gitea/actions/checks
|
||||
with:
|
||||
# A repository secret is not visible inside the composite action, so
|
||||
# it is passed in. Pull requests from forks get no secrets: the
|
||||
# action then fails at once with a message that says so.
|
||||
protocol-deploy-key: ${{ secrets.VOELIN_PROTOCOL_DEPLOY_KEY }}
|
||||
@@ -32,6 +32,38 @@ jobs:
|
||||
docker info >/dev/null
|
||||
# Remove only output owned by this workflow in its checkout.
|
||||
rm -rf dist
|
||||
# The workspace depends on the private VoelinProtocol repository over SSH
|
||||
# (docs/ci.md, "VoelinProtocol access"). The Docker builds fetch it with
|
||||
# this agent (`docker build --ssh default`): the key lives in the agent's
|
||||
# memory, never on disk and never in an image layer. Stopped by the last
|
||||
# step; the lifetime below ends the key anyway if the runner dies first.
|
||||
- name: Start ssh-agent with the VoelinProtocol deploy key
|
||||
env:
|
||||
PROTOCOL_DEPLOY_KEY: ${{ secrets.VOELIN_PROTOCOL_DEPLOY_KEY }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [[ -z "${PROTOCOL_DEPLOY_KEY//[[:space:]]/}" ]]; then
|
||||
echo "::error::The repository secret VOELIN_PROTOCOL_DEPLOY_KEY is missing or empty. It holds the private key of the read-only deploy key on Voelin/VoelinProtocol (docs/ci.md, VoelinProtocol access)." >&2
|
||||
exit 1
|
||||
fi
|
||||
for tool in ssh-agent ssh-add; do
|
||||
command -v "$tool" > /dev/null || { echo "::error::The runner needs the OpenSSH client: $tool is missing." >&2; exit 1; }
|
||||
done
|
||||
eval "$(ssh-agent -s -t 32400)" > /dev/null
|
||||
started=
|
||||
trap '[[ -n "$started" ]] || ssh-agent -k > /dev/null' EXIT
|
||||
# LF lines and one final newline, whatever the secret store did.
|
||||
printf '%s\n' "$PROTOCOL_DEPLOY_KEY" | tr -d '\r' | sed '/^[[:space:]]*$/d' | ssh-add -q -
|
||||
unset PROTOCOL_DEPLOY_KEY
|
||||
# The fingerprint of the public half, to compare with the deploy key.
|
||||
ssh-add -l
|
||||
{
|
||||
echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK"
|
||||
echo "SSH_AGENT_PID=$SSH_AGENT_PID"
|
||||
# Only an agent this job started is stopped at the end.
|
||||
echo "VOELIN_AGENT_STARTED=1"
|
||||
} >> "$GITHUB_ENV"
|
||||
started=1
|
||||
- name: Linux packages
|
||||
run: scripts/docker-build.sh linux --progress=plain
|
||||
- name: Windows packages (MinGW)
|
||||
@@ -77,7 +109,7 @@ jobs:
|
||||
set -euo pipefail
|
||||
version=$(sed -n 's/^version = "\(.*\)"$/\1/p' crates/voelin-gateway/Cargo.toml | head -n 1)
|
||||
test -n "$version"
|
||||
docker build -f crates/voelin-gateway/Dockerfile -t "tsgw:$version" -t tsgw:latest .
|
||||
DOCKER_BUILDKIT=1 docker build --ssh default -f crates/voelin-gateway/Dockerfile -t "tsgw:$version" -t tsgw:latest .
|
||||
mkdir -p dist/gateway
|
||||
docker save "tsgw:$version" tsgw:latest | gzip > dist/gateway/tsgw-image.tar.gz
|
||||
- name: Collect packages and checksums
|
||||
@@ -104,3 +136,9 @@ jobs:
|
||||
# Gitea refuses secret names starting with GITEA_ or GITHUB_.
|
||||
GITEA_RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
|
||||
run: scripts/gitea-release.sh dist/release
|
||||
- name: Stop the ssh-agent
|
||||
if: always()
|
||||
run: |
|
||||
if [[ -n "${VOELIN_AGENT_STARTED:-}" && -n "${SSH_AGENT_PID:-}" ]]; then
|
||||
ssh-agent -k > /dev/null || true
|
||||
fi
|
||||
@@ -2,3 +2,5 @@
|
||||
/dev/.state/
|
||||
/dist/
|
||||
/.cargo/
|
||||
# agent scratch of a worktree (the MAO policy in CLAUDE.md)
|
||||
/.scratch/
|
||||
@@ -199,19 +199,22 @@ async fn receive<R: AsyncRead + Unpin>(
|
||||
let mut done = offset;
|
||||
match sink {
|
||||
Sink::File { part, dest, append } => {
|
||||
// The directory and the file are made in one step, without a pause in
|
||||
// which the task could be stopped: a cancel stops the task, waits for
|
||||
// it and then removes the part file, so what the task made must be
|
||||
// there by then (a pending open on the blocking pool would not be).
|
||||
if let Some(dir) = part.parent().filter(|d| !d.as_os_str().is_empty()) {
|
||||
tokio::fs::create_dir_all(dir)
|
||||
.await
|
||||
.map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||
std::fs::create_dir_all(dir).map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||
}
|
||||
let mut file = tokio::fs::OpenOptions::new()
|
||||
.create(true)
|
||||
.write(true)
|
||||
.append(*append)
|
||||
.truncate(!*append)
|
||||
.open(part)
|
||||
.await
|
||||
.map_err(|e| format!("{}: {e}", part.display()))?;
|
||||
let mut file = tokio::fs::File::from_std(
|
||||
std::fs::OpenOptions::new()
|
||||
.create(true)
|
||||
.write(true)
|
||||
.append(*append)
|
||||
.truncate(!*append)
|
||||
.open(part)
|
||||
.map_err(|e| format!("{}: {e}", part.display()))?,
|
||||
);
|
||||
let received = async {
|
||||
while done < size {
|
||||
let n = stream.read(&mut buf).await.map_err(|e| e.to_string())?;
|
||||
|
||||
@@ -77,7 +77,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use tokio::sync::mpsc;
|
||||
use tokio::task::AbortHandle;
|
||||
use tokio::task::JoinHandle;
|
||||
use tracing::{debug, info, warn};
|
||||
use voelin_audio::EncodedVoice;
|
||||
use voelin_model::replica::{Replica, SCHEMA_GENERATION, ScopeId};
|
||||
@@ -325,7 +325,7 @@ async fn drive(
|
||||
|
||||
/// A transfer a user can cancel.
|
||||
struct Running {
|
||||
task: AbortHandle,
|
||||
task: JoinHandle<()>,
|
||||
part: Option<PathBuf>,
|
||||
report: Report,
|
||||
/// The server has opened it (a part file may exist).
|
||||
@@ -1479,7 +1479,7 @@ impl Conn {
|
||||
receive.await;
|
||||
}
|
||||
});
|
||||
self.running(transfer, Running { task: task.abort_handle(), part, report, started });
|
||||
self.running(transfer, Running { task, part, report, started });
|
||||
}
|
||||
|
||||
fn upload(
|
||||
@@ -1560,7 +1560,7 @@ impl Conn {
|
||||
let stored = async move { done.await.map(|_| ()).map_err(|e| text(&e, false)) };
|
||||
files::upload_to(body, stored, from, size, offset, progress, task_report).await;
|
||||
});
|
||||
self.running(transfer, Running { task: task.abort_handle(), part: None, report, started });
|
||||
self.running(transfer, Running { task, part: None, report, started });
|
||||
}
|
||||
|
||||
fn running(&mut self, transfer: Option<TransferId>, running: Running) {
|
||||
@@ -1572,15 +1572,21 @@ impl Conn {
|
||||
|
||||
fn cancel(&mut self, id: TransferId) {
|
||||
match self.transfers.remove(&id) {
|
||||
Some(running) if !running.task.is_finished() => {
|
||||
running.task.abort();
|
||||
// A part file exists once the server has opened the transfer.
|
||||
if running.started.load(Ordering::Acquire)
|
||||
&& let Some(part) = running.part
|
||||
{
|
||||
let _ = std::fs::remove_file(part);
|
||||
}
|
||||
(running.report)(TransferState::Cancelled);
|
||||
Some(Running { task, part, report, started }) if !task.is_finished() => {
|
||||
task.abort();
|
||||
// The part file goes once the task has stopped, not at once: the task
|
||||
// opens it in one step (files::download), so it is there or it never
|
||||
// will be, and a removal that came before the open would leave it.
|
||||
tokio::spawn(async move {
|
||||
let _ = task.await;
|
||||
// A part file exists once the server has opened the transfer.
|
||||
if started.load(Ordering::Acquire)
|
||||
&& let Some(part) = part
|
||||
{
|
||||
let _ = std::fs::remove_file(part);
|
||||
}
|
||||
report(TransferState::Cancelled);
|
||||
});
|
||||
}
|
||||
_ => debug!(id, "cancel: no such transfer (finished?)"),
|
||||
}
|
||||
|
||||
@@ -607,6 +607,12 @@ async fn a_file_is_downloaded_through_the_connection_the_link_opens() {
|
||||
}
|
||||
tokio::time::sleep(Duration::from_millis(10)).await;
|
||||
}
|
||||
assert!(
|
||||
states.lock().unwrap().iter().any(|s| matches!(s, TransferState::Started { .. })),
|
||||
"the transfer started: {:?}",
|
||||
states.lock().unwrap()
|
||||
);
|
||||
// Cancelled the moment it is Started, when its part file may be opening.
|
||||
rig.give(LinkCmd::CancelTransfer(3));
|
||||
assert_eq!(final_state(&states).await, TransferState::Cancelled);
|
||||
rig.quiet();
|
||||
|
||||
@@ -3410,7 +3410,14 @@ mod tests {
|
||||
assert!(all.is_hardware(backend), "{codec} offered in software");
|
||||
}
|
||||
if all.encoder_codecs().contains(&Codec::H264) && !offer.contains(&Codec::H264) {
|
||||
assert_eq!(offer_codecs(&all, Codec::H264)[..2], [Codec::H264, Codec::Vp8]);
|
||||
// H.264 in software only (so not in `offer`): it leads the same
|
||||
// codecs as with VP8 as the stream codec, whichever hardware
|
||||
// encoders this machine has (a hardware AV1 or VP9 encoder ranks
|
||||
// before VP8, so VP8 is not always second).
|
||||
let h264 = offer_codecs(&all, Codec::H264);
|
||||
assert_eq!(h264[0], Codec::H264, "{h264:?}");
|
||||
assert_eq!(h264.len(), offer.len() + 1, "{h264:?} against {offer:?}");
|
||||
assert!(offer.iter().all(|c| h264.contains(c)), "{h264:?} against {offer:?}");
|
||||
}
|
||||
// Whatever this machine has: codecs every TeamSpeak client decodes
|
||||
// come before H.264, HEVC last, and the automatic stream codec is
|
||||
@@ -3423,10 +3430,23 @@ mod tests {
|
||||
let ranks: Vec<_> = offer[1..].iter().map(rank).collect();
|
||||
assert!(ranks.is_sorted(), "{offer:?}");
|
||||
assert!(preferred_codec(&all, None).is_some_and(decoded_everywhere), "{all:?}");
|
||||
assert_eq!(
|
||||
preferred_codec(&all, Some(Codec::H264)).is_some(),
|
||||
all.encoder_codecs().contains(&Codec::H264)
|
||||
);
|
||||
// A configured codec is the stream codec when this machine can encode
|
||||
// it; otherwise the result is the automatic choice,
|
||||
// `preferred_codec(&all, None)` (some codec on any machine that
|
||||
// encodes anything). Whether H.264 is encodable depends on the
|
||||
// machine (a desktop with FFmpeg or a GPU has an encoder, a CI
|
||||
// runner has none), so the expectation follows `all.encoder_codecs()`.
|
||||
let h264 = preferred_codec(&all, Some(Codec::H264));
|
||||
if all.encoder_codecs().contains(&Codec::H264) {
|
||||
assert_eq!(h264, Some(Codec::H264), "{all:?}");
|
||||
} else {
|
||||
assert_eq!(h264, preferred_codec(&all, None), "{all:?}");
|
||||
}
|
||||
// The built-in codecs are the same everywhere (no OpenH264 loaded):
|
||||
// VP9 is encodable and wins, H.264 is not and falls back to VP8.
|
||||
assert_eq!(preferred_codec(&codecs, Some(Codec::Vp9)), Some(Codec::Vp9));
|
||||
assert_eq!(preferred_codec(&codecs, Some(Codec::H264)), preferred_codec(&codecs, None));
|
||||
assert_eq!(preferred_codec(&codecs, None), Some(Codec::Vp8));
|
||||
}
|
||||
|
||||
/// A sink whose viewers chose `codecs`; keeps every video frame with its
|
||||
@@ -3520,7 +3540,12 @@ mod tests {
|
||||
let count = lock(&sink.formats).len();
|
||||
tokio::time::sleep(Duration::from_millis(200)).await;
|
||||
assert_eq!(lock(&sink.formats).len(), count);
|
||||
assert_eq!(streamer.stats().layers[0].bitrate, auto_bitrate(640, 480, 30));
|
||||
// The stats follow the sink's being told, not the other way round.
|
||||
let deadline = Instant::now() + Duration::from_secs(10);
|
||||
while streamer.stats().layers[0].bitrate != auto_bitrate(640, 480, 30) {
|
||||
assert!(Instant::now() < deadline, "{:?}", streamer.stats().layers);
|
||||
tokio::time::sleep(Duration::from_millis(20)).await;
|
||||
}
|
||||
let update = StreamerConfigUpdate { fps: Some(15), ..StreamerConfigUpdate::default() };
|
||||
streamer.reconfigure(&codecs, update).unwrap();
|
||||
told(15).await;
|
||||
|
||||
@@ -1295,9 +1295,21 @@ mod tests {
|
||||
// Before the viewer asks: its offer is made after this.
|
||||
sink.layer_format(0, format(60_000_000));
|
||||
handles[1].send(StreamCmd::Watch { stream_id: "s-1".into() });
|
||||
wait(&mut rx, |e| match e {
|
||||
Event::WatchState { session: 2, state: WatchState::Connected, .. } => Some(()),
|
||||
_ => None,
|
||||
// Connected for the viewer and for the streamer, in either order: the
|
||||
// streamer asks for a keyframe when its viewer connects, a moment after
|
||||
// the viewer has seen the connection.
|
||||
let (mut watching, mut served) = (false, false);
|
||||
wait(&mut rx, |e| {
|
||||
match e {
|
||||
Event::WatchState { session: 2, state: WatchState::Connected, .. } => {
|
||||
watching = true;
|
||||
}
|
||||
Event::StreamViewers { session: 1, viewers } => {
|
||||
served |= viewers.iter().any(|v| v.state == ViewerState::Connected);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
(watching && served).then_some(())
|
||||
})
|
||||
.await;
|
||||
// 3840x2160 at 60 fps is level 5.2 (0x34) in both profiles.
|
||||
@@ -1312,7 +1324,15 @@ mod tests {
|
||||
sink.take_layer_keyframes(&mut layers);
|
||||
layers.contains(0)
|
||||
};
|
||||
keyframes();
|
||||
// What asked for a keyframe so far (going live, the viewer's connecting
|
||||
// and its first picture request) is done when a moment longer than the
|
||||
// merging interval of requests (250 ms) passes with none.
|
||||
for _ in 0..50 {
|
||||
tokio::time::sleep(Duration::from_millis(300)).await;
|
||||
if !keyframes() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
sink.layer_format(0, format(9_000_000));
|
||||
timeout(Duration::from_secs(5), async {
|
||||
while !keyframes() {
|
||||
@@ -1701,7 +1721,16 @@ mod tests {
|
||||
let stats = pipeline.stats();
|
||||
assert_eq!(stats.codec, Some(Codec::Vp8));
|
||||
assert!(stats.error.is_none(), "{stats:?}");
|
||||
let sent = streamer.stats();
|
||||
// The encoder counts a frame once the sink has taken it, so the picture
|
||||
// can be at the viewer before the count has moved.
|
||||
let mut sent = streamer.stats();
|
||||
for _ in 0..500 {
|
||||
if sent.video_frames >= 15 && sent.audio_frames > 0 {
|
||||
break;
|
||||
}
|
||||
tokio::time::sleep(Duration::from_millis(10)).await;
|
||||
sent = streamer.stats();
|
||||
}
|
||||
assert!(sent.video_frames >= 15 && sent.audio_frames > 0, "{sent:?}");
|
||||
|
||||
handles[0].send(StreamCmd::Stop);
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
# Build: docker build -f crates/voelin-gateway/Dockerfile -t tsgw .
|
||||
# syntax=docker/dockerfile:1
|
||||
# Build: docker build --ssh default -f crates/voelin-gateway/Dockerfile -t tsgw .
|
||||
# (--ssh default hands the build your ssh-agent, which must hold a key that
|
||||
# can read the private VoelinProtocol repository: docs/building.md,
|
||||
# "Depending on VoelinProtocol". The gateway itself does not use it, but
|
||||
# Cargo resolves the whole workspace, which includes voelin-identity.)
|
||||
# Run: docker run -d --name tsgw --init --restart unless-stopped \
|
||||
# -v ./tsgw.toml:/etc/tsgw/tsgw.toml:ro -v tsgw-data:/var/lib/tsgw \
|
||||
# -e TSGW_QUERY_PASSWORD=… -p 7788:7788 tsgw
|
||||
@@ -6,9 +11,19 @@
|
||||
# the volume: -e TSGW_LOG_FILE=logs/tsgw.log). See docs/gateway-admin.md.
|
||||
FROM rust:1.94-bookworm AS build
|
||||
WORKDIR /src
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends cmake libasound2-dev && rm -rf /var/lib/apt/lists/*
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends cmake git libasound2-dev openssh-client && rm -rf /var/lib/apt/lists/*
|
||||
# voelin-identity comes from the private VoelinProtocol repository, fetched
|
||||
# over SSH by Cargo through the system git, with the agent that
|
||||
# `docker build --ssh default` forwards (scripts/docker-build.sh passes it):
|
||||
# the key stays in the agent and never reaches a layer. The host key is the
|
||||
# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so
|
||||
# every cargo command needs this, although this crate does not use
|
||||
# voelin-identity.
|
||||
COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts
|
||||
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
|
||||
COPY . .
|
||||
RUN cargo build --release --locked -p voelin-gateway && cp target/release/tsgw /tsgw && mkdir /data
|
||||
RUN --mount=type=ssh,required=true \
|
||||
cargo build --release --locked -p voelin-gateway && cp target/release/tsgw /tsgw && mkdir /data
|
||||
|
||||
FROM gcr.io/distroless/cc-debian12:nonroot
|
||||
COPY --from=build /tsgw /usr/local/bin/tsgw
|
||||
|
||||
@@ -350,7 +350,22 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn an_unwritable_path_fails_at_once() {
|
||||
assert!(Recorder::start("/nonexistent-root-dir/x/clip.webm", 0, 2).is_err());
|
||||
assert!(Recorder::start("clip.mp4", 0, 2).is_err());
|
||||
let dir = dir("unwritable");
|
||||
// A path below a regular file fails for every user, root included
|
||||
// (ENOTDIR). A directory that is merely missing would be created, and
|
||||
// a read-only one is written to by root.
|
||||
let file = dir.join("not-a-directory");
|
||||
std::fs::write(&file, b"x").unwrap();
|
||||
assert!(Recorder::start(file.join("x").join("clip.webm"), 0, 2).is_err());
|
||||
// The directory is there and the file cannot be created because the
|
||||
// path names a directory (EISDIR, again for every user).
|
||||
let named_like_a_file = dir.join("clip.webm");
|
||||
std::fs::create_dir(&named_like_a_file).unwrap();
|
||||
assert!(Recorder::start(&named_like_a_file, 0, 2).is_err());
|
||||
// A name that asks for no known container is refused before any file
|
||||
// is created.
|
||||
assert!(Recorder::start(dir.join("clip.mp4"), 0, 2).is_err());
|
||||
assert!(!dir.join("clip.mp4").exists());
|
||||
std::fs::remove_dir_all(&dir).ok();
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,15 @@
|
||||
# Android APKs (docs/building.md, docs/android.md): a debug APK, installable
|
||||
# as is, for arm64-v8a and x86_64 (emulators).
|
||||
#
|
||||
# docker build -f docker/android.Dockerfile -o dist/android .
|
||||
# docker build -f docker/android.Dockerfile --build-arg ABIS=arm64-v8a -o dist/android .
|
||||
# docker build --ssh default -f docker/android.Dockerfile -o dist/android .
|
||||
# docker build --ssh default -f docker/android.Dockerfile --build-arg ABIS=arm64-v8a -o dist/android .
|
||||
#
|
||||
# or scripts/docker-build.sh android. A signed release APK needs your keystore
|
||||
# (docs/release.md), passed as build secrets:
|
||||
# or scripts/docker-build.sh android. --ssh default hands the build your
|
||||
# ssh-agent, which must hold a key that can read the private VoelinProtocol
|
||||
# repository (docs/building.md, "Depending on VoelinProtocol"). A signed
|
||||
# release APK needs your keystore (docs/release.md), passed as build secrets:
|
||||
#
|
||||
# docker build -f docker/android.Dockerfile --build-arg APK=release \
|
||||
# docker build --ssh default -f docker/android.Dockerfile --build-arg APK=release \
|
||||
# --secret id=keystore,src=release.jks --secret id=signing,src=signing.env \
|
||||
# -o dist/android .
|
||||
#
|
||||
@@ -21,8 +23,8 @@ FROM ubuntu:24.04 AS toolchain
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
# JDK 17 (Gradle, the Android Gradle plugin), CMake + Ninja (the bundled libopus).
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential ca-certificates cmake curl ninja-build openjdk-17-jdk-headless \
|
||||
pkg-config python3 unzip \
|
||||
build-essential ca-certificates cmake curl git ninja-build openjdk-17-jdk-headless \
|
||||
openssh-client pkg-config python3 unzip \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Extra CA certificates (PEM, one or more), for building behind a
|
||||
@@ -83,8 +85,18 @@ ARG APK=debug
|
||||
# supplies a fresh non-secret nonce so a rotated key cannot reuse an old APK.
|
||||
ARG SIGNING_CACHE_BUST=unsigned
|
||||
WORKDIR /src
|
||||
# voelin-identity comes from the private VoelinProtocol repository, fetched
|
||||
# over SSH by Cargo through the system git, with the agent that
|
||||
# `docker build --ssh default` forwards (scripts/docker-build.sh passes it):
|
||||
# the key stays in the agent and never reaches a layer. The host key is the
|
||||
# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so
|
||||
# every cargo command needs this (Gradle's cargo-ndk inherits the agent and the
|
||||
# variable below).
|
||||
COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts
|
||||
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
|
||||
COPY . .
|
||||
RUN --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
|
||||
RUN --mount=type=ssh,required=true \
|
||||
--mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,id=voelin-target-android,target=/src/target \
|
||||
--mount=type=cache,id=voelin-gradle,target=/root/.gradle \
|
||||
--mount=type=secret,id=keystore,required=false \
|
||||
|
||||
+17
-5
@@ -5,17 +5,20 @@
|
||||
# gateway (servers) as tsgw-<version>-linux-x86_64.tar.gz and
|
||||
# tsgw_<version>_amd64.deb.
|
||||
#
|
||||
# docker build -f docker/linux.Dockerfile -o dist/linux .
|
||||
# docker build --ssh default -f docker/linux.Dockerfile -o dist/linux .
|
||||
#
|
||||
# or scripts/docker-build.sh linux. The cargo registry and target directory
|
||||
# live in cache mounts, so rebuilds are incremental.
|
||||
# or scripts/docker-build.sh linux. --ssh default hands the build your
|
||||
# ssh-agent, which must hold a key that can read the private VoelinProtocol
|
||||
# repository (docs/building.md, "Depending on VoelinProtocol"). The cargo
|
||||
# registry and target directory live in cache mounts, so rebuilds are
|
||||
# incremental.
|
||||
|
||||
FROM ubuntu:24.04 AS toolchain
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
# The same libraries as CI (.github/actions/system-deps), plus dpkg-dev for
|
||||
# the .deb's dependencies and patchelf for the .tar.gz's bundled libraries.
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential ca-certificates cmake curl dpkg-dev patchelf pkg-config \
|
||||
build-essential ca-certificates cmake curl dpkg-dev git openssh-client patchelf pkg-config \
|
||||
libasound2-dev libfontconfig1-dev libxkbcommon-dev \
|
||||
libvpx-dev libdav1d-dev libpipewire-0.3-dev libspa-0.2-dev libclang-dev \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
@@ -37,8 +40,17 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
|
||||
|
||||
FROM toolchain AS build
|
||||
WORKDIR /src
|
||||
# voelin-identity comes from the private VoelinProtocol repository, fetched
|
||||
# over SSH by Cargo through the system git, with the agent that
|
||||
# `docker build --ssh default` forwards (scripts/docker-build.sh passes it):
|
||||
# the key stays in the agent and never reaches a layer. The host key is the
|
||||
# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so
|
||||
# every cargo command needs this.
|
||||
COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts
|
||||
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
|
||||
COPY . .
|
||||
RUN --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
|
||||
RUN --mount=type=ssh,required=true \
|
||||
--mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,id=voelin-target-linux,target=/src/target \
|
||||
cargo build --release --locked -p voelin-ui -p voelin-gateway \
|
||||
&& scripts/package.sh linux /out
|
||||
|
||||
@@ -4,11 +4,15 @@
|
||||
# voelin-<version>-windows-x86_64.zip with voelin.exe, and the NSIS installer
|
||||
# voelin-<version>-setup.exe.
|
||||
#
|
||||
# docker build -f docker/windows.Dockerfile -o dist/windows .
|
||||
# docker build --ssh default -f docker/windows.Dockerfile -o dist/windows .
|
||||
#
|
||||
# or scripts/docker-build.sh windows. This builds for x86_64-pc-windows-gnu
|
||||
# with mingw-w64; CI's Windows jobs build the MSVC target on Windows. Both run
|
||||
# on Windows 10 and 11. Unsigned, like CI's (signing: docs/release.md).
|
||||
# or scripts/docker-build.sh windows. --ssh default hands the build your
|
||||
# ssh-agent, which must hold a key that can read the private VoelinProtocol
|
||||
# repository (docs/building.md, "Depending on VoelinProtocol").
|
||||
#
|
||||
# This builds for x86_64-pc-windows-gnu with mingw-w64; CI's Windows jobs build
|
||||
# the MSVC target on Windows. Both run on Windows 10 and 11. Unsigned, like
|
||||
# CI's (signing: docs/release.md).
|
||||
|
||||
FROM ubuntu:24.04 AS toolchain
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
@@ -16,8 +20,8 @@ ARG DEBIAN_FRONTEND=noninteractive
|
||||
# assembly), CMake (the bundled libopus, aws-lc), Meson and Ninja (dav1d),
|
||||
# NSIS (the installer), zip and unzip.
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential ca-certificates cmake curl git meson mingw-w64 nasm ninja-build nsis perl \
|
||||
pkg-config unzip zip \
|
||||
build-essential ca-certificates cmake curl git meson mingw-w64 nasm ninja-build nsis \
|
||||
openssh-client perl pkg-config unzip zip \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix \
|
||||
&& update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
|
||||
@@ -89,9 +93,18 @@ ENV VPX_LIB_DIR=/opt/libvpx/lib VPX_INCLUDE_DIR=/opt/libvpx/include \
|
||||
SYSTEM_DEPS_DAV1D_NO_PKG_CONFIG=1 SYSTEM_DEPS_DAV1D_SEARCH_NATIVE=/opt/dav1d/lib \
|
||||
SYSTEM_DEPS_DAV1D_LIB=dav1d SYSTEM_DEPS_DAV1D_LINK=static
|
||||
WORKDIR /src
|
||||
# voelin-identity comes from the private VoelinProtocol repository, fetched
|
||||
# over SSH by Cargo through the system git, with the agent that
|
||||
# `docker build --ssh default` forwards (scripts/docker-build.sh passes it):
|
||||
# the key stays in the agent and never reaches a layer. The host key is the
|
||||
# reviewed line from .gitea/known_hosts. Cargo resolves the whole workspace, so
|
||||
# every cargo command needs this.
|
||||
COPY .gitea/known_hosts /etc/ssh/ssh_known_hosts
|
||||
ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
|
||||
COPY . .
|
||||
# FFmpeg's LGPL DLLs go into the packages (scripts/fetch-ffmpeg-windows.sh).
|
||||
RUN --mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
|
||||
RUN --mount=type=ssh,required=true \
|
||||
--mount=type=cache,id=voelin-cargo-registry,target=/usr/local/cargo/registry \
|
||||
--mount=type=cache,id=voelin-target-windows,target=/src/target \
|
||||
cargo build --release --locked --target x86_64-pc-windows-gnu -p voelin-ui \
|
||||
&& scripts/fetch-ffmpeg-windows.sh /tmp/ffmpeg \
|
||||
|
||||
+27
-8
@@ -28,7 +28,8 @@ yet: Windows SmartScreen warns about the installer, and the debug APK is
|
||||
signed with a debug key (fine for testing, not for the Play Store).
|
||||
|
||||
The gateway's image can also be built directly:
|
||||
`docker build -f crates/voelin-gateway/Dockerfile -t tsgw .`.
|
||||
`docker build --ssh default -f crates/voelin-gateway/Dockerfile -t tsgw .`
|
||||
(`--ssh default`: see [Locally with Docker](#locally-with-docker)).
|
||||
|
||||
Gitea at [git.faumaray.ru](https://git.faumaray.ru) builds the same package
|
||||
types through `.gitea/workflows/release.yml`: manual runs produce one
|
||||
@@ -80,7 +81,16 @@ scripts/docker-build.sh android # → dist/android/
|
||||
scripts/docker-build.sh # all three
|
||||
```
|
||||
|
||||
The same with plain Docker, e.g. `docker build -f docker/linux.Dockerfile -o dist/linux .`
|
||||
The same with plain Docker, e.g. `docker build --ssh default -f docker/linux.Dockerfile -o dist/linux .`.
|
||||
|
||||
**The builds need an ssh-agent that holds a key able to read the private
|
||||
VoelinProtocol repository** ([below](#depending-on-voelinprotocol)): Cargo
|
||||
fetches it inside the image, through the agent that `--ssh default` hands to the
|
||||
build. The key stays in the agent; it is not copied into the image or the build
|
||||
cache. `scripts/docker-build.sh` passes `--ssh default` itself and stops with a
|
||||
message when `ssh-add -l` shows no agent or no key (`eval "$(ssh-agent -s)"`,
|
||||
then `ssh-add` your key). The server's host key comes from
|
||||
`.gitea/known_hosts` ([ci.md](ci.md#voelinprotocol-access)).
|
||||
Rebuilds are incremental: the cargo registry, `target/` and Gradle live in
|
||||
BuildKit cache mounts (`docker builder prune` frees them).
|
||||
|
||||
@@ -153,13 +163,22 @@ set `net.git-fetch-with-cli = true` in `~/.cargo/config.toml`.
|
||||
compiler (gcc or clang) and cmake.
|
||||
`deny.toml` allows this one git source.
|
||||
|
||||
**CI and the Docker builds need read access to that repository too**: an SSH
|
||||
deploy key (a repository secret written to `~/.ssh`, with the server's host key
|
||||
in `known_hosts`) or an access token (rewrite the SSH URL to HTTPS with
|
||||
**CI and the Docker builds read it with a read-only SSH deploy key.** The key
|
||||
is registered on VoelinProtocol and stored as the repository secret
|
||||
`VOELIN_PROTOCOL_DEPLOY_KEY`; the Gitea workflows write it to `~/.ssh` (CI) or
|
||||
load it into an ssh-agent (release builds), the server's host key comes from the
|
||||
committed `.gitea/known_hosts`, and Cargo is told to fetch with the system git
|
||||
(`CARGO_NET_GIT_FETCH_WITH_CLI=true`) because its built-in git client ignores
|
||||
`~/.ssh/config`. The Docker builds use the same key through
|
||||
`docker build --ssh default` (see above). What was set up, how to re-check the
|
||||
host key's fingerprint and what each failure means:
|
||||
[ci.md](ci.md#voelinprotocol-access). A runner of your own gets the same setup
|
||||
from the workflows; the alternative to a deploy key is an access token (rewrite
|
||||
the SSH URL to HTTPS with
|
||||
`git config --global url."https://<token>@git.faumaray.com/".insteadOf ssh://gitea@git.faumaray.com/`
|
||||
and set `CARGO_NET_GIT_FETCH_WITH_CLI=true`). Without it `cargo` cannot fetch
|
||||
the dependency and a fresh checkout does not build; the details are in
|
||||
VoelinProtocol's `docs/development.md` ("Depending on VoelinProtocol").
|
||||
and set `CARGO_NET_GIT_FETCH_WITH_CLI=true`), which these workflows do not
|
||||
use. More in VoelinProtocol's `docs/development.md` ("Depending on
|
||||
VoelinProtocol").
|
||||
|
||||
### Working with a sibling VoelinProtocol checkout
|
||||
|
||||
|
||||
+192
-16
@@ -46,21 +46,25 @@ the separate `release.yml` workflow below.
|
||||
this label (the left side must match the workflow's `runs-on`):
|
||||
|
||||
```text
|
||||
ubuntu-24.04:docker://ghcr.io/catthehacker/ubuntu:act-24.04
|
||||
ubuntu-24.04:docker://docker.gitea.com/runner-images:ubuntu-24.04
|
||||
```
|
||||
|
||||
Configure this in the runner's labels when registering/configuring it;
|
||||
an `ubuntu-latest` label alone does not match. The job image must provide
|
||||
Bash, Git, Node.js for checkout v4, and root or passwordless sudo for apt.
|
||||
an `ubuntu-latest` label alone does not match. This is the image of the
|
||||
runner that runs this repository's CI, and the one the tests are checked
|
||||
against ([Tests under the job image](#tests-under-the-job-image)). The job
|
||||
image must provide Bash, Git, the OpenSSH client, Node.js for checkout v4,
|
||||
and root or passwordless sudo for apt.
|
||||
3. Allow network access from the runner and job container to the Gitea
|
||||
instance, GitHub (checkout action, dependencies and RustSec advisories),
|
||||
GHCR (runner image), Ubuntu apt mirrors, rustup distribution servers,
|
||||
crates.io and dependency/license sources used by cargo-about. The
|
||||
`docker.gitea.com` (runner image), Ubuntu apt mirrors, rustup
|
||||
distribution servers, crates.io and dependency/license sources used by
|
||||
cargo-about. The
|
||||
workspace also depends on the **private** VoelinProtocol repository
|
||||
(`voelin-identity`, over SSH), so the job needs read access to it: an SSH
|
||||
deploy key or an access token, set up as in
|
||||
[building.md](building.md#depending-on-voelinprotocol). Until a runner has
|
||||
it, a fresh checkout does not build there.
|
||||
(`voelin-identity`, over SSH), so the job needs read access to it and the
|
||||
server's SSH port. The workflows set that up themselves from a repository
|
||||
secret: [VoelinProtocol access](#voelinprotocol-access). A runner needs
|
||||
nothing for it beyond the network access and the image tools above.
|
||||
4. Provision enough RAM, swap and free disk for a full Slint workspace build
|
||||
plus cargo-deny/cargo-about compilation. These are large builds; monitor
|
||||
the first run and size the runner accordingly. The workflow limits Cargo
|
||||
@@ -93,14 +97,184 @@ No GitHub cache/artifact service or reusable-workflow support is required.
|
||||
The job does not need a Docker socket mounted inside its container; the
|
||||
runner itself still needs Docker access to start that container. Keep this
|
||||
runner isolated from production services and credentials, particularly when
|
||||
accepting untrusted pull requests. No release signing or publishing secrets
|
||||
are needed.
|
||||
accepting untrusted pull requests. CI needs one secret, the VoelinProtocol
|
||||
deploy key below; it needs no release signing or publishing secrets.
|
||||
|
||||
After registering the runner, dispatch **CI** in Gitea Actions and inspect
|
||||
all step results. Local YAML/shell checks do not prove that a particular
|
||||
Gitea instance, runner registration, network policy or resource allocation
|
||||
can complete this job.
|
||||
|
||||
### Tests under the job image
|
||||
|
||||
The test step runs as **root** in an Ubuntu 24.04 container of the
|
||||
`ubuntu-24.04` label ([Runner setup](#runner-setup):
|
||||
`docker.gitea.com/runner-images:ubuntu-24.04`, `HOME=/root`) to which only
|
||||
the apt packages of the system-dependencies action are added. A test that
|
||||
assumes a developer machine fails there, and a run takes about an hour, so
|
||||
check a change to the tests the way CI runs them, with every failing test of
|
||||
every crate listed in one go (`--no-fail-fast`):
|
||||
|
||||
```sh
|
||||
# A bare clone of the private VoelinProtocol repository (see below the block):
|
||||
# git clone --bare ssh://gitea@git.faumaray.com/Voelin/VoelinProtocol.git <dir>
|
||||
: "${PROTOCOL_GIT:?path of a bare clone of VoelinProtocol}"
|
||||
# Root owns what the container writes: keep it in a directory of its own
|
||||
# (.scratch/ is in .gitignore; see below the block for its removal).
|
||||
mkdir -p .scratch
|
||||
docker run --rm --init -v "$PWD":/src -w /src -e HOME=/root \
|
||||
-v "$PROTOCOL_GIT":/protocol.git:ro -e CARGO_NET_GIT_FETCH_WITH_CLI=true \
|
||||
-e CARGO_HOME=/src/.scratch/cargo -e RUSTUP_HOME=/src/.scratch/rustup \
|
||||
-e CARGO_TARGET_DIR=/src/.scratch/target \
|
||||
docker.gitea.com/runner-images:ubuntu-24.04 bash -c '
|
||||
git -C / config --global url."file:///protocol.git".insteadOf \
|
||||
ssh://gitea@git.faumaray.com/Voelin/VoelinProtocol.git
|
||||
apt-get update && apt-get install -y --no-install-recommends \
|
||||
build-essential ca-certificates cmake curl git jq pkg-config python3 \
|
||||
libasound2-dev libfontconfig1-dev libxkbcommon-dev libvpx-dev \
|
||||
libdav1d-dev libpipewire-0.3-dev libspa-0.2-dev libclang-dev xvfb xauth
|
||||
curl --proto =https --tlsv1.2 -sSf https://sh.rustup.rs | \
|
||||
sh -s -- -y --profile minimal --default-toolchain none
|
||||
. "$CARGO_HOME/env" && rustup toolchain install
|
||||
xvfb-run -a bash -c "VOELIN_X11_TEST_DISPLAY=\$DISPLAY \
|
||||
cargo test --workspace --locked --no-fail-fast"'
|
||||
```
|
||||
|
||||
`--init` is required: `bash -c` runs its last command, `xvfb-run`, as the
|
||||
container's process 1, and that never gets to start `cargo` (the command
|
||||
hangs). The runner starts its steps with `docker exec` in a container whose
|
||||
process 1 is something else, so CI itself is not affected.
|
||||
|
||||
The private VoelinProtocol dependency needs the deploy key
|
||||
([below](#voelinprotocol-access)). The block reads it from a local bare clone
|
||||
instead: `PROTOCOL_GIT` is mounted at `/protocol.git` and git is told to use
|
||||
it in place of the SSH URL (with `CARGO_NET_GIT_FETCH_WITH_CLI=true`, as in CI,
|
||||
so that cargo runs the `git` command), which leaves `Cargo.lock` as it is.
|
||||
The `git config` is run with `-C /` because a git worktree's `.git` file points
|
||||
outside the mount, and `git config` in `/src` then fails with `fatal: not a git
|
||||
repository: (null)` (exit 128). To use the deploy key instead, set it up as
|
||||
described below and leave out the `PROTOCOL_GIT` lines and the `git config`
|
||||
command. What the container wrote under `.scratch/` belongs to root; remove it
|
||||
from a container as well:
|
||||
|
||||
```sh
|
||||
docker run --rm -v "$PWD/.scratch":/s alpine:3.20 rm -rf /s/target /s/cargo /s/rustup
|
||||
```
|
||||
|
||||
What the image lacks, and what the tests do about it. A test that is about
|
||||
the missing piece returns without testing it, in most cases after printing a
|
||||
line that says it skipped and names the piece (the wording differs from test
|
||||
to test), or is `#[ignore]`d with the reason, and passes; any other test does
|
||||
not need the piece.
|
||||
|
||||
| A test cannot count on | What the tests do |
|
||||
|---|---|
|
||||
| Regular user (root writes anywhere and creates missing directories) | Nothing relies on a permission bit or a missing directory failing. A path that cannot be written is built from something that fails for root too: below a regular file (`ENOTDIR`) or naming a directory (`EISDIR`), as `an_unwritable_path_fails_at_once` of the recorder does. |
|
||||
| Sound card (`/dev/snd`), PipeWire and WirePlumber daemons | `libpipewire` and ALSA are there to build against only. `tests/pipewire_apps.rs` needs `pipewire`, `wireplumber` and `dbus-daemon` and, without them, prints a skipped line that names them. The camera tests are `#[ignore]`d (a camera and PipeWire). |
|
||||
| D-Bus session bus | `voelin-platform`'s portal proxy test runs itself again under `dbus-run-session` on a bus of its own and, where that cannot be run, prints `skipped, nothing was checked: dbus-run-session cannot be run`; the notification and capture-portal tests run only where no bus is configured, and check that talking to a missing service fails cleanly. |
|
||||
| GPU, `/dev/dri`, VA-API, `/dev/udmabuf` | The VA-API and DMA-BUF tests print a skipped line that names what is missing: a usable `h264_vaapi`, `/dev/udmabuf` or VA-API surfaces to export. |
|
||||
| FFmpeg libraries, `ffmpeg` and `ffprobe` | The FFmpeg tests of `voelin-media` and `voelin-core` print a skipped line that names what is missing (the libraries, `ffmpeg`, `ffprobe`). The studio tests that read a recording back with `ffprobe` write and check the file themselves and skip only the `ffprobe` check; the RTMP tests need all three and skip. |
|
||||
| H.264 encoder (no FFmpeg, no GPU, no OpenH264 library: `VOELIN_OPENH264_LIB` is unset and the download test is `#[ignore]`d) | Tests that need an H.264 encoder print a skipped line that says no H.264 encoder is there. Tests of codec choice state what `preferred_codec` promises with whatever the machine can encode. VP8 and VP9 (libvpx) are built in, so their round trips run. |
|
||||
| X11 or Wayland display | `xvfb-run` supplies one X11 display and the step hands it over as `VOELIN_X11_TEST_DISPLAY` to the X11 capture and hotkey tests. `VOELIN_WLROOTS_TEST_DISPLAY` is unset, so the wlroots capture test prints `skipped`. |
|
||||
| Playwright and Chromium (the image has Node) | The browser interop tests print `skipped: set VOELIN_INTEROP=1 (needs node, Playwright and Chromium)`. |
|
||||
| TeamSpeak dev servers | Without `VOELIN_LIVE=1` the live tests return at once (some print `skipped: set VOELIN_LIVE=1 with the dev servers running`); the gateway's live test is `#[ignore]`d (`needs a running tsgw and TeamSpeak server`). |
|
||||
| DNS and internet while the tests run (the job needs the network for apt, rustup and crates before they start) | The tests use no DNS or internet; those that would are `#[ignore]`d with the reason: four resolver tests of `tsclientlib` (`needs DNS and the internet`) and the OpenH264 download test. |
|
||||
|
||||
`localhost` resolves to `::1` first in this image (it also has `127.0.0.1`).
|
||||
The tests that reach a server of their own go to `127.0.0.1` by name, not
|
||||
through `localhost`, so a machine where connections to `::1` hang (a
|
||||
development machine with a VPN does that) changes nothing for them.
|
||||
|
||||
### VoelinProtocol access
|
||||
|
||||
The workspace depends on `voelin-identity` from the **private** repository
|
||||
`Voelin/VoelinProtocol`, as a git dependency over SSH
|
||||
([building.md](building.md#depending-on-voelinprotocol)). Cargo resolves the
|
||||
whole workspace before it builds anything, so *every* cargo command needs
|
||||
that access: all of CI, all three package images and the gateway image (whose
|
||||
crate does not use `voelin-identity` itself). Without it the first cargo
|
||||
command fails with `unknown SSH host key` (runs 1037 and 1050 did).
|
||||
|
||||
What is set up:
|
||||
|
||||
- **The deploy key.** A read-only SSH deploy key is registered on
|
||||
`Voelin/VoelinProtocol` (Settings → Deploy Keys, write access off). It has
|
||||
no other use and no access to any other repository. Its private half is the
|
||||
repository secret **`VOELIN_PROTOCOL_DEPLOY_KEY`** of `Voelin/VoelinClient`
|
||||
(Settings → Actions → Secrets): the whole OpenSSH private key file, BEGIN
|
||||
and END lines included, without a passphrase. To rotate it, make a new pair
|
||||
(`ssh-keygen -t ed25519 -N '' -C voelin-client-ci -f key`), register
|
||||
`key.pub` on VoelinProtocol, replace the secret with the contents of
|
||||
`key`, run CI, then delete the old deploy key and `key`.
|
||||
- **CI** (`ci.yml`). The workflow hands the secret to the checks action as its
|
||||
input `protocol-deploy-key` (a repository secret is not visible inside a
|
||||
composite action). The action's first step fails at once, naming the secret,
|
||||
if the input is empty or is not a private key. Otherwise it writes the key to
|
||||
`~/.ssh/voelin_protocol` (mode 0600, `~/.ssh` 0700), appends the host key
|
||||
line to `~/.ssh/known_hosts`, writes a `Host git.faumaray.com` block to
|
||||
`~/.ssh/config` (`User gitea`, that `IdentityFile`, `IdentitiesOnly yes`,
|
||||
`StrictHostKeyChecking yes`) and exports `CARGO_NET_GIT_FETCH_WITH_CLI=true`
|
||||
and `GIT_SSH_COMMAND` for the rest of the job (`ci.yml` sets the first one
|
||||
in its own `env` as well). It prints only the key's
|
||||
public fingerprint; the key is never echoed. After the system packages a
|
||||
second step runs `git ls-remote` on VoelinProtocol, so a wrong key or host
|
||||
key fails there, with the reason, and not inside a cargo command. The key
|
||||
lives in the job container and goes with it.
|
||||
- **Release** (`release.yml`). A step after checkout starts an `ssh-agent` on
|
||||
the release host, loads the key into it from stdin (it is never written to
|
||||
disk) and exports `SSH_AUTH_SOCK`; the agent forgets the key after nine
|
||||
hours, and a last step, which also runs after a failure, stops it. The
|
||||
builds pass the agent on with `docker build --ssh default`
|
||||
(`scripts/docker-build.sh` does it for the three packages; the gateway image
|
||||
step does it itself).
|
||||
- **The images.** Each cargo `RUN` of `docker/*.Dockerfile` and
|
||||
`crates/voelin-gateway/Dockerfile` has `--mount=type=ssh,required=true`, so
|
||||
the key exists only inside that step, through the agent socket, and never
|
||||
reaches a layer, a build argument or the cache; a build without `--ssh`
|
||||
stops there with `unset ssh forward key default`. The build stage copies
|
||||
`.gitea/known_hosts` to `/etc/ssh/ssh_known_hosts` and sets the same
|
||||
`CARGO_NET_GIT_FETCH_WITH_CLI=true`; the toolchain stages install `git` and
|
||||
`openssh-client`.
|
||||
- **Cargo uses the system git** (`CARGO_NET_GIT_FETCH_WITH_CLI=true`) because
|
||||
Cargo's built-in git client does not read `~/.ssh/config` (so it cannot use
|
||||
an `IdentityFile`), authenticates with an ssh-agent and checks the host
|
||||
against `~/.ssh/known_hosts` and its own `net.ssh.known-hosts` setting. The
|
||||
system git runs `ssh`, which reads the config above (and
|
||||
`/etc/ssh/ssh_known_hosts` in the images), so the same files serve a plain
|
||||
`git` call, Cargo and the access check.
|
||||
- **The host key** is committed in [`.gitea/known_hosts`](../.gitea/known_hosts),
|
||||
never fetched while a job runs. Gitea's built-in SSH server (`SSH-2.0-Go`)
|
||||
offers an RSA host key only (`ssh-keyscan -t ed25519 git.faumaray.com`
|
||||
prints nothing), so the line is `ssh-rsa`; its fingerprint is
|
||||
`SHA256:fugBYnqAnqmTLsGpafVgQF9gPQzJqps7uHvs48blg2A`. Re-check it:
|
||||
|
||||
```sh
|
||||
ssh-keygen -lf .gitea/known_hosts # the committed line
|
||||
ssh-keyscan -t rsa git.faumaray.com | ssh-keygen -lf - # what the server offers now
|
||||
```
|
||||
|
||||
Both print the fingerprint above. If the server's key is ever replaced on
|
||||
purpose, confirm the new fingerprint with the server's administrator, put the
|
||||
new `ssh-keyscan -t rsa` line and the date in `.gitea/known_hosts` and the
|
||||
fingerprint here, and commit all of it in one change. Until then a changed key
|
||||
makes every job stop with `Host key verification failed`, which is the point.
|
||||
|
||||
Pull requests from forks get no secrets: their CI run stops at the first step
|
||||
with the message about the empty deploy key. Anyone who can change a workflow of
|
||||
this repository, or run code in one of its jobs, can read the key; it can only
|
||||
read VoelinProtocol, and it is replaced as above. That is one more reason to
|
||||
keep the CI runner isolated, as said above.
|
||||
|
||||
If a run fails here:
|
||||
|
||||
| Message | Cause |
|
||||
|---|---|
|
||||
| `The VoelinProtocol deploy key is empty` | the secret is missing, empty or not visible (a fork's pull request) |
|
||||
| `… is not an unencrypted OpenSSH or PEM private key` | the secret holds something else, or a key with a passphrase |
|
||||
| `Permission denied (publickey)` in "Check read access to VoelinProtocol" | the key is valid but is not a deploy key of VoelinProtocol: compare the fingerprint "Deploy key installed" printed with the one in VoelinProtocol's deploy key settings |
|
||||
| `Host key verification failed` | `.gitea/known_hosts` does not match the server: check as above before changing anything |
|
||||
| `unset ssh forward key default` | a Docker build ran without `--ssh default`: a plain `docker build` (`scripts/docker-build.sh` passes it itself and stops earlier when the agent has no key) |
|
||||
|
||||
### Gitea release runner
|
||||
|
||||
The instance at `https://git.faumaray.ru` reported Gitea **1.25.4** on
|
||||
@@ -114,9 +288,10 @@ host** runner with the label:
|
||||
voelin-release:host
|
||||
```
|
||||
|
||||
Provision Bash, Git, Node.js 20+, Python 3.11+, curl, tar, gzip and rootful
|
||||
Docker 23+ with BuildKit. Use **act_runner 0.2.7 or newer** (prefer the latest
|
||||
maintained release), or gitea-runner 2+. Older act_runner does not provide
|
||||
Provision Bash, Git, the OpenSSH client (`ssh-agent` and `ssh-add`), Node.js
|
||||
20+, Python 3.11+, curl, tar, gzip and rootful Docker 23+ with BuildKit. Use
|
||||
**act_runner 0.2.7 or newer** (prefer the latest maintained release), or
|
||||
gitea-runner 2+. Older act_runner does not provide
|
||||
`ACTIONS_RESULTS_URL`, which the pinned artifact action needs. Register the
|
||||
runner against `https://git.faumaray.ru`, reachable from both the host and
|
||||
build containers. Gitea 1.25.4 provides the required artifact-v4 API.
|
||||
@@ -158,8 +333,9 @@ ENDLESS_TASK_TIMEOUT = 9h
|
||||
Keep sufficient RAM/swap and free disk for all package builds and their
|
||||
Docker caches. The package builds run one after another, each with as many
|
||||
Cargo jobs as the host has CPUs. The workflow never prunes shared Docker
|
||||
state or creates host swap. The token and optional Android signing secrets
|
||||
are documented in
|
||||
state or creates host swap. The secrets are the VoelinProtocol deploy key
|
||||
([below](#voelinprotocol-access)), `RELEASE_TOKEN` and the optional Android
|
||||
signing secrets, both documented in
|
||||
[Gitea releases](release.md#gitea-releases).
|
||||
|
||||
The Gitea release job builds packages only: it runs no formatting, Clippy,
|
||||
|
||||
@@ -240,7 +240,7 @@ the unit to `/etc/systemd/system/`.
|
||||
**Container** (`tsgw-image.tar.gz`, or build it):
|
||||
|
||||
```sh
|
||||
docker load -i tsgw-image.tar.gz # or: docker build -f crates/voelin-gateway/Dockerfile -t tsgw .
|
||||
docker load -i tsgw-image.tar.gz # or: docker build --ssh default -f crates/voelin-gateway/Dockerfile -t tsgw .
|
||||
docker run -d --name tsgw --init --restart unless-stopped \
|
||||
-v $PWD/tsgw.toml:/etc/tsgw/tsgw.toml:ro -v tsgw-data:/var/lib/tsgw \
|
||||
-e TSGW_QUERY_PASSWORD=… -p 7788:7788 tsgw
|
||||
|
||||
+18
-1
@@ -7,6 +7,11 @@
|
||||
# docker buildx). Extra arguments go to `docker build`, e.g.
|
||||
# scripts/docker-build.sh android --build-arg ABIS=arm64-v8a
|
||||
#
|
||||
# The workspace depends on the private VoelinProtocol repository, which the
|
||||
# build fetches over SSH with your ssh-agent (`docker build --ssh default`):
|
||||
# the agent must hold a key that can read it (docs/building.md, "Depending on
|
||||
# VoelinProtocol"). The key stays in the agent, never in the image.
|
||||
#
|
||||
# Behind an HTTPS proxy, HTTPS_PROXY/HTTP_PROXY/NO_PROXY are passed on to the
|
||||
# build; a proxy on this machine's loopback is reached with host networking.
|
||||
# If the proxy inspects TLS, point BUILD_CA_CERT at its CA certificate (PEM):
|
||||
@@ -23,7 +28,19 @@ case "$platform" in
|
||||
*) echo "usage: $0 [linux|windows|android|all] [docker build args…]" >&2; exit 2 ;;
|
||||
esac
|
||||
|
||||
args=()
|
||||
# The build's cargo needs VoelinProtocol; fail here, not after the toolchain
|
||||
# stage, when the agent is missing or empty.
|
||||
if ! ssh-add -l > /dev/null 2>&1; then
|
||||
cat >&2 <<'MSG'
|
||||
docker-build.sh: no ssh-agent with a key that can read Voelin/VoelinProtocol.
|
||||
Start one and add the key, then run this again:
|
||||
eval "$(ssh-agent -s)" && ssh-add ~/.ssh/<key>
|
||||
docs/building.md ("Depending on VoelinProtocol") has the details.
|
||||
MSG
|
||||
exit 1
|
||||
fi
|
||||
|
||||
args=(--ssh default)
|
||||
for var in HTTPS_PROXY https_proxy HTTP_PROXY http_proxy NO_PROXY no_proxy; do
|
||||
if [[ -n ${!var:-} ]]; then
|
||||
args+=(--build-arg "$var=${!var}")
|
||||
|
||||
Reference in new issue
Block a user