Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d0b36450d | ||
|
|
b12c83e8b5 | ||
|
|
ff4e2a5c5d | ||
|
|
2ef9f80fc1 | ||
|
|
6fe549e34e |
+13
-72
@@ -2,6 +2,11 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
# CI for the self-hosted, host-executor Podman runners (see container/).
|
||||||
|
# The runner image bakes in the Rust toolchain and all build dependencies,
|
||||||
|
# so jobs go straight to cargo — no apt/rustup setup steps (which also
|
||||||
|
# collided on the dpkg lock when jobs ran concurrently in the same runner).
|
||||||
|
|
||||||
name: CI
|
name: CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
@@ -17,90 +22,26 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install system dependencies
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y --no-install-recommends \
|
|
||||||
build-essential pkg-config cmake clang libclang-dev \
|
|
||||||
libopus-dev libasound2-dev libsoapysdr-dev
|
|
||||||
|
|
||||||
- name: Set up Rust
|
|
||||||
run: |
|
|
||||||
export PATH="$HOME/.cargo/bin:$PATH"
|
|
||||||
if ! command -v rustup >/dev/null 2>&1; then
|
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
|
|
||||||
| sh -s -- -y --profile minimal
|
|
||||||
fi
|
|
||||||
rustup toolchain install stable --profile minimal \
|
|
||||||
--component rustfmt --component clippy
|
|
||||||
rustup default stable
|
|
||||||
|
|
||||||
- name: Cache cargo
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.cargo/registry
|
|
||||||
~/.cargo/git
|
|
||||||
target
|
|
||||||
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
|
|
||||||
restore-keys: cargo-${{ runner.os }}-
|
|
||||||
|
|
||||||
- name: rustfmt
|
- name: rustfmt
|
||||||
run: |
|
run: cargo fmt --all -- --check
|
||||||
export PATH="$HOME/.cargo/bin:$PATH"
|
|
||||||
cargo fmt --all -- --check
|
|
||||||
|
|
||||||
- name: clippy
|
- name: clippy
|
||||||
run: |
|
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
|
||||||
export PATH="$HOME/.cargo/bin:$PATH"
|
|
||||||
cargo clippy --workspace --all-targets --all-features -- -D warnings
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Install system dependencies
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y --no-install-recommends \
|
|
||||||
build-essential pkg-config cmake clang libclang-dev \
|
|
||||||
libopus-dev libasound2-dev libsoapysdr-dev
|
|
||||||
|
|
||||||
- name: Set up Rust
|
|
||||||
run: |
|
|
||||||
export PATH="$HOME/.cargo/bin:$PATH"
|
|
||||||
if ! command -v rustup >/dev/null 2>&1; then
|
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
|
|
||||||
| sh -s -- -y --profile minimal
|
|
||||||
fi
|
|
||||||
rustup toolchain install stable --profile minimal
|
|
||||||
rustup default stable
|
|
||||||
|
|
||||||
- name: Cache cargo
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.cargo/registry
|
|
||||||
~/.cargo/git
|
|
||||||
target
|
|
||||||
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
|
|
||||||
restore-keys: cargo-${{ runner.os }}-
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: cargo build --workspace --all-targets --locked
|
||||||
export PATH="$HOME/.cargo/bin:$PATH"
|
|
||||||
cargo build --workspace --all-targets --locked
|
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: |
|
run: cargo test --workspace --locked
|
||||||
export PATH="$HOME/.cargo/bin:$PATH"
|
|
||||||
cargo test --workspace --locked
|
|
||||||
|
|
||||||
reuse:
|
reuse:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: REUSE compliance
|
- name: REUSE compliance
|
||||||
uses: fsfe/reuse-action@v5
|
# `reuse` CLI instead of fsfe/reuse-action: the latter is a Docker
|
||||||
|
# action, which the host-executor runners cannot run. `reuse` is baked
|
||||||
|
# into the runner image (see container/Containerfile).
|
||||||
|
run: reuse lint
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_MAJOR}.x | bash - \
|
|||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# REUSE >= 3 (Debian's packaged reuse is too old for REUSE.toml).
|
# REUSE >= 3 (Debian's packaged reuse is too old for REUSE.toml).
|
||||||
RUN PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install reuse
|
# The [charset-normalizer] extra provides an encoding-detection backend;
|
||||||
|
# without it (and without libmagic) reuse fails to import at runtime.
|
||||||
|
RUN PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install 'reuse[charset-normalizer]'
|
||||||
|
|
||||||
# Rust stable with rustfmt + clippy, installed system-wide.
|
# Rust stable with rustfmt + clippy, installed system-wide.
|
||||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
|
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
|
||||||
|
|||||||
@@ -1624,6 +1624,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script defer src="https://cdn.jsdelivr.net/npm/opus-decoder@0.7.11/dist/opus-decoder.min.js" charset="UTF-8"></script>
|
<script defer src="https://cdn.jsdelivr.net/npm/opus-decoder@0.7.11/dist/opus-decoder.min.js" charset="UTF-8"></script>
|
||||||
|
<script defer src="/vendor/leaflet.js"></script>
|
||||||
|
<script defer src="/leaflet-ais-tracksymbol.js"></script>
|
||||||
<script defer src="/webgl-renderer.js"></script>
|
<script defer src="/webgl-renderer.js"></script>
|
||||||
<script defer src="/app.js"></script>
|
<script defer src="/app.js"></script>
|
||||||
<script>
|
<script>
|
||||||
@@ -1632,7 +1634,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
var pluginScripts = {
|
var pluginScripts = {
|
||||||
'digital-modes': ['/ft8.js', '/ft4.js', '/ft2.js', '/wspr.js', '/cw.js', '/background-decode.js', '/sat.js', '/wefax.js'],
|
'digital-modes': ['/ft8.js', '/ft4.js', '/ft2.js', '/wspr.js', '/cw.js', '/background-decode.js', '/sat.js', '/wefax.js'],
|
||||||
'map-data': ['/map-core.js', '/ais.js', '/vdes.js', '/aprs.js', '/hf-aprs.js'],
|
'map-data': ['/map-core.js', '/ais.js', '/vdes.js', '/aprs.js', '/hf-aprs.js'],
|
||||||
'map': ['/map-core.js', '/leaflet-ais-tracksymbol.js', '/ais.js', '/vdes.js', '/aprs.js', '/hf-aprs.js', '/sat.js', '/sat-scheduler.js'],
|
'map': ['/map-core.js', '/ais.js', '/vdes.js', '/aprs.js', '/hf-aprs.js', '/sat.js', '/sat-scheduler.js'],
|
||||||
'statistics': ['/map-core.js'],
|
'statistics': ['/map-core.js'],
|
||||||
'bookmarks': ['/bookmarks.js'],
|
'bookmarks': ['/bookmarks.js'],
|
||||||
'recorder': [],
|
'recorder': [],
|
||||||
@@ -1667,6 +1669,5 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
|||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
<!-- Template cloning is handled by navigateToTab() in app.js -->
|
<!-- Template cloning is handled by navigateToTab() in app.js -->
|
||||||
<script defer src="/vendor/leaflet.js"></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ pub struct DecoderHistories {
|
|||||||
pub lrpt: Mutex<VecDeque<(Instant, LrptImage)>>,
|
pub lrpt: Mutex<VecDeque<(Instant, LrptImage)>>,
|
||||||
pub wefax: Mutex<VecDeque<(Instant, WefaxMessage)>>,
|
pub wefax: Mutex<VecDeque<(Instant, WefaxMessage)>>,
|
||||||
/// Approximate total entry count across all decoders, maintained
|
/// Approximate total entry count across all decoders, maintained
|
||||||
/// atomically so `estimated_total_count()` avoids 9 lock acquisitions.
|
/// atomically so `estimated_total_count()` avoids 11 lock acquisitions.
|
||||||
total_count: AtomicUsize,
|
total_count: AtomicUsize,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -845,6 +845,23 @@ impl DecoderHistories {
|
|||||||
pub fn estimated_total_count(&self) -> usize {
|
pub fn estimated_total_count(&self) -> usize {
|
||||||
self.total_count.load(Ordering::Relaxed)
|
self.total_count.load(Ordering::Relaxed)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Rebuild the aggregate count after bulk restoration bypasses the normal
|
||||||
|
/// record methods.
|
||||||
|
pub(crate) fn recalculate_total_count(&self) {
|
||||||
|
let total = lock_or_recover(&self.ais, "ais_history").len()
|
||||||
|
+ lock_or_recover(&self.vdes, "vdes_history").len()
|
||||||
|
+ lock_or_recover(&self.aprs, "aprs_history").len()
|
||||||
|
+ lock_or_recover(&self.hf_aprs, "hf_aprs_history").len()
|
||||||
|
+ lock_or_recover(&self.cw, "cw_history").len()
|
||||||
|
+ lock_or_recover(&self.ft8, "ft8_history").len()
|
||||||
|
+ lock_or_recover(&self.ft4, "ft4_history").len()
|
||||||
|
+ lock_or_recover(&self.ft2, "ft2_history").len()
|
||||||
|
+ lock_or_recover(&self.wspr, "wspr_history").len()
|
||||||
|
+ lock_or_recover(&self.lrpt, "lrpt_history").len()
|
||||||
|
+ lock_or_recover(&self.wefax, "wefax_history").len();
|
||||||
|
self.total_count.store(total, Ordering::Relaxed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Spawn the audio capture thread.
|
/// Spawn the audio capture thread.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use pickledb::{PickleDb, PickleDbDumpPolicy, SerializationMethod};
|
|||||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||||
|
|
||||||
use trx_core::decode::{
|
use trx_core::decode::{
|
||||||
AisMessage, AprsPacket, CwEvent, Ft8Message, VdesMessage, WefaxMessage, WsprMessage,
|
AisMessage, AprsPacket, CwEvent, Ft8Message, LrptImage, VdesMessage, WefaxMessage, WsprMessage,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::audio::DecoderHistories;
|
use crate::audio::DecoderHistories;
|
||||||
@@ -118,6 +118,11 @@ pub fn load_all(db: &PickleDb, rig_id: &str, histories: &Arc<DecoderHistories>)
|
|||||||
h.push_back(e);
|
h.push_back(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let Ok(mut h) = histories.hf_aprs.lock() {
|
||||||
|
for e in load_key::<AprsPacket>(db, &k("hf_aprs")) {
|
||||||
|
h.push_back(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
if let Ok(mut h) = histories.cw.lock() {
|
if let Ok(mut h) = histories.cw.lock() {
|
||||||
for e in load_key::<CwEvent>(db, &k("cw")) {
|
for e in load_key::<CwEvent>(db, &k("cw")) {
|
||||||
h.push_back(e);
|
h.push_back(e);
|
||||||
@@ -128,16 +133,32 @@ pub fn load_all(db: &PickleDb, rig_id: &str, histories: &Arc<DecoderHistories>)
|
|||||||
h.push_back(e);
|
h.push_back(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let Ok(mut h) = histories.ft4.lock() {
|
||||||
|
for e in load_key::<Ft8Message>(db, &k("ft4")) {
|
||||||
|
h.push_back(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Ok(mut h) = histories.ft2.lock() {
|
||||||
|
for e in load_key::<Ft8Message>(db, &k("ft2")) {
|
||||||
|
h.push_back(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
if let Ok(mut h) = histories.wspr.lock() {
|
if let Ok(mut h) = histories.wspr.lock() {
|
||||||
for e in load_key::<WsprMessage>(db, &k("wspr")) {
|
for e in load_key::<WsprMessage>(db, &k("wspr")) {
|
||||||
h.push_back(e);
|
h.push_back(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let Ok(mut h) = histories.lrpt.lock() {
|
||||||
|
for e in load_key::<LrptImage>(db, &k("lrpt")) {
|
||||||
|
h.push_back(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
if let Ok(mut h) = histories.wefax.lock() {
|
if let Ok(mut h) = histories.wefax.lock() {
|
||||||
for e in load_key::<WefaxMessage>(db, &k("wefax")) {
|
for e in load_key::<WefaxMessage>(db, &k("wefax")) {
|
||||||
h.push_back(e);
|
h.push_back(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
histories.recalculate_total_count();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Flush `histories` to the database under `rig_id`-prefixed keys and sync.
|
/// Flush `histories` to the database under `rig_id`-prefixed keys and sync.
|
||||||
@@ -162,6 +183,11 @@ pub fn flush_all(db: &mut PickleDb, rig_id: &str, histories: &Arc<DecoderHistori
|
|||||||
drop(h);
|
drop(h);
|
||||||
save_key(db, &k("aprs"), &snapshot);
|
save_key(db, &k("aprs"), &snapshot);
|
||||||
}
|
}
|
||||||
|
if let Ok(h) = histories.hf_aprs.lock() {
|
||||||
|
let snapshot = h.clone();
|
||||||
|
drop(h);
|
||||||
|
save_key(db, &k("hf_aprs"), &snapshot);
|
||||||
|
}
|
||||||
if let Ok(h) = histories.cw.lock() {
|
if let Ok(h) = histories.cw.lock() {
|
||||||
let snapshot = h.clone();
|
let snapshot = h.clone();
|
||||||
drop(h);
|
drop(h);
|
||||||
@@ -172,11 +198,26 @@ pub fn flush_all(db: &mut PickleDb, rig_id: &str, histories: &Arc<DecoderHistori
|
|||||||
drop(h);
|
drop(h);
|
||||||
save_key(db, &k("ft8"), &snapshot);
|
save_key(db, &k("ft8"), &snapshot);
|
||||||
}
|
}
|
||||||
|
if let Ok(h) = histories.ft4.lock() {
|
||||||
|
let snapshot = h.clone();
|
||||||
|
drop(h);
|
||||||
|
save_key(db, &k("ft4"), &snapshot);
|
||||||
|
}
|
||||||
|
if let Ok(h) = histories.ft2.lock() {
|
||||||
|
let snapshot = h.clone();
|
||||||
|
drop(h);
|
||||||
|
save_key(db, &k("ft2"), &snapshot);
|
||||||
|
}
|
||||||
if let Ok(h) = histories.wspr.lock() {
|
if let Ok(h) = histories.wspr.lock() {
|
||||||
let snapshot = h.clone();
|
let snapshot = h.clone();
|
||||||
drop(h);
|
drop(h);
|
||||||
save_key(db, &k("wspr"), &snapshot);
|
save_key(db, &k("wspr"), &snapshot);
|
||||||
}
|
}
|
||||||
|
if let Ok(h) = histories.lrpt.lock() {
|
||||||
|
let snapshot = h.clone();
|
||||||
|
drop(h);
|
||||||
|
save_key(db, &k("lrpt"), &snapshot);
|
||||||
|
}
|
||||||
if let Ok(h) = histories.wefax.lock() {
|
if let Ok(h) = histories.wefax.lock() {
|
||||||
let snapshot = h.clone();
|
let snapshot = h.clone();
|
||||||
drop(h);
|
drop(h);
|
||||||
@@ -302,4 +343,79 @@ mod tests {
|
|||||||
let _ = std::fs::remove_file(&db_file);
|
let _ = std::fs::remove_file(&db_file);
|
||||||
let _ = std::fs::remove_dir(&dir);
|
let _ = std::fs::remove_dir(&dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn flush_and_load_all_restores_previously_omitted_histories() {
|
||||||
|
let db_file = std::env::temp_dir().join(format!(
|
||||||
|
"trx_history_all_{}_{}.db",
|
||||||
|
std::process::id(),
|
||||||
|
now_unix_ms()
|
||||||
|
));
|
||||||
|
let mut db = PickleDb::new(
|
||||||
|
&db_file,
|
||||||
|
PickleDbDumpPolicy::DumpUponRequest,
|
||||||
|
SerializationMethod::Json,
|
||||||
|
);
|
||||||
|
let source = DecoderHistories::new();
|
||||||
|
let now = Instant::now();
|
||||||
|
|
||||||
|
source.hf_aprs.lock().unwrap().push_back((
|
||||||
|
now,
|
||||||
|
AprsPacket {
|
||||||
|
rig_id: Some("rig-a".into()),
|
||||||
|
ts_ms: Some(now_unix_ms()),
|
||||||
|
src_call: "TEST".into(),
|
||||||
|
dest_call: "APRS".into(),
|
||||||
|
path: String::new(),
|
||||||
|
info: "history".into(),
|
||||||
|
info_bytes: Vec::new(),
|
||||||
|
packet_type: "position".into(),
|
||||||
|
crc_ok: true,
|
||||||
|
lat: None,
|
||||||
|
lon: None,
|
||||||
|
symbol_table: None,
|
||||||
|
symbol_code: None,
|
||||||
|
},
|
||||||
|
));
|
||||||
|
for (queue, mode) in [(&source.ft4, "FT4"), (&source.ft2, "FT2")] {
|
||||||
|
queue.lock().unwrap().push_back((
|
||||||
|
now,
|
||||||
|
Ft8Message {
|
||||||
|
rig_id: Some("rig-a".into()),
|
||||||
|
ts_ms: now_unix_ms(),
|
||||||
|
snr_db: -10.0,
|
||||||
|
dt_s: 0.1,
|
||||||
|
freq_hz: 1_000.0,
|
||||||
|
message: mode.into(),
|
||||||
|
},
|
||||||
|
));
|
||||||
|
}
|
||||||
|
source.lrpt.lock().unwrap().push_back((
|
||||||
|
now,
|
||||||
|
LrptImage {
|
||||||
|
rig_id: Some("rig-a".into()),
|
||||||
|
pass_start_ms: now_unix_ms(),
|
||||||
|
pass_end_ms: now_unix_ms(),
|
||||||
|
mcu_count: 1,
|
||||||
|
path: "/tmp/lrpt.png".into(),
|
||||||
|
ts_ms: Some(now_unix_ms()),
|
||||||
|
satellite: None,
|
||||||
|
channels: None,
|
||||||
|
geo_bounds: None,
|
||||||
|
ground_track: None,
|
||||||
|
},
|
||||||
|
));
|
||||||
|
|
||||||
|
flush_all(&mut db, "rig-a", &source);
|
||||||
|
let restored = DecoderHistories::new();
|
||||||
|
load_all(&db, "rig-a", &restored);
|
||||||
|
|
||||||
|
assert_eq!(restored.hf_aprs.lock().unwrap().len(), 1);
|
||||||
|
assert_eq!(restored.ft4.lock().unwrap().len(), 1);
|
||||||
|
assert_eq!(restored.ft2.lock().unwrap().len(), 1);
|
||||||
|
assert_eq!(restored.lrpt.lock().unwrap().len(), 1);
|
||||||
|
assert_eq!(restored.estimated_total_count(), 4);
|
||||||
|
|
||||||
|
let _ = std::fs::remove_file(db_file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user