Skip to content

Commit 48ab52e

Browse files
committed
chore: selfci and jotup
1 parent c6178d8 commit 48ab52e

File tree

10 files changed

+127
-27
lines changed

10 files changed

+127
-27
lines changed

.config/selfci/ci.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/usr/bin/env bash
2+
set -eou pipefail
3+
4+
5+
function job_lint() {
6+
set -x
7+
8+
# Get zero-terminated list of non-symlink files (reusable)
9+
git_ls_files="$(git ls-files -z | while IFS= read -r -d '' file; do
10+
[ ! -L "$file" ] && printf '%s\0' "$file"
11+
done)"
12+
13+
selfci step start "check leftover dbg!"
14+
while IFS= read -r -d '' path; do
15+
if grep -q 'dbg!(' "$path"; then
16+
>&2 echo "$path contains dbg! macro"
17+
selfci step fail
18+
fi
19+
done <<< "$git_ls_files"
20+
21+
selfci step start "nixfmt"
22+
nix_files=()
23+
while IFS= read -r -d '' path; do
24+
[[ "$path" == *.nix ]] && nix_files+=("$path")
25+
done <<< "$git_ls_files"
26+
if [ ${#nix_files[@]} -gt 0 ]; then
27+
if ! nixfmt -c "${nix_files[@]}"; then
28+
selfci step fail
29+
fi
30+
fi
31+
32+
selfci step start "cargo fmt"
33+
if ! cargo fmt --all --check ; then
34+
selfci step fail
35+
fi
36+
}
37+
38+
# check the things involving cargo
39+
# We're using Nix + crane + flakebox,
40+
# this gives us caching between different
41+
# builds and decent isolation.
42+
function job_cargo() {
43+
selfci step start "cargo.lock up to date"
44+
if ! cargo update --workspace --locked -q; then
45+
selfci step fail
46+
fi
47+
48+
# there's not point continuing if we can't build
49+
selfci step start "build"
50+
nix build -L .#ci.workspace
51+
52+
selfci step start "clippy"
53+
if ! nix build -L .#ci.clippy ; then
54+
selfci step fail
55+
fi
56+
57+
selfci step start "nextest"
58+
if ! nix build -L .#ci.tests ; then
59+
selfci step fail
60+
fi
61+
}
62+
63+
case "$SELFCI_JOB_NAME" in
64+
main)
65+
selfci job start "lint"
66+
selfci job start "cargo"
67+
;;
68+
69+
cargo)
70+
job_cargo
71+
;;
72+
73+
lint)
74+
# use develop shell to ensure all the tools are provided at pinned versions
75+
export -f job_lint
76+
nix develop -c bash -c "job_lint"
77+
;;
78+
79+
80+
*)
81+
echo "Unknown job: $SELFCI_JOB_NAME"
82+
exit 1
83+
esac

.config/selfci/ci.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
job:
2+
clone-mode: partial
3+
command: ./.config/selfci/ci.sh
4+
5+
mq:
6+
base-branch: master
7+
merge-style: rebase

Cargo.lock

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ iroh = { version = "0.95.1", default-features = false }
6666
iroh-base = { version = "0.95.1", default-features = false }
6767
iroh-io = "0.6.0"
6868
itertools = "0.13.0"
69-
jotdown = { version = "0.9.0", features = ["async"] }
69+
jotup = { version = "0.10.0", features = ["async"] }
7070
pkarr = "3.10.0"
7171
proptest = "1.6.0"
7272
maud = "*"
@@ -151,6 +151,3 @@ debug = false
151151

152152
[patch.crates-io]
153153
redb-bincode = { git = "https://github.com/rustshop/redb-bincode", rev = "b33cedb787d452dc3735a153aca55086fea7c306" }
154-
jotdown = { git = "https://github.com/dpc/jotdown", rev = "6a4528812cd9a4621b56dab02b724f5d5a5371a1", features = [
155-
"async",
156-
] }

crates/rostra-web-ui/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ bytes = { workspace = true }
2020
brotli = { workspace = true }
2121
futures = { workspace = true }
2222
futures-util = { workspace = true }
23-
jotdown = { workspace = true }
23+
jotup = { workspace = true }
2424
maud = { workspace = true }
2525
listenfd = { workspace = true }
2626
snafu = { workspace = true }

crates/rostra-web-ui/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mod error;
2-
mod layout;
32
pub mod html_utils;
3+
mod layout;
44
mod routes;
55
// TODO: move to own crate
66
mod serde_util;

crates/rostra-web-ui/src/routes/content.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::borrow::Cow;
22
use std::str::FromStr as _;
33

4-
use jotdown::r#async::{AsyncRender, AsyncRenderOutputExt};
5-
use jotdown::html::filters::AsyncSanitizeExt;
4+
use jotup::r#async::{AsyncRender, AsyncRenderOutputExt};
5+
use jotup::html::filters::AsyncSanitizeExt;
66
use maud::{Markup, PreEscaped};
77
use rostra_client::ClientRef;
88
use rostra_core::ShortEventId;
@@ -55,7 +55,7 @@ impl UiState {
5555
) -> Markup {
5656
// Compose the filters using extension traits: Renderer -> ProfileLinks ->
5757
// Images -> PrismCodeBlocks -> Sanitize
58-
let renderer = jotdown::html::tokio::Renderer::default()
58+
let renderer = jotup::html::tokio::Renderer::default()
5959
.rostra_profile_links(client.clone())
6060
.rostra_images(author_id)
6161
.prism_code_blocks()
@@ -73,7 +73,7 @@ impl UiState {
7373
/// transformations)
7474
pub(crate) async fn render_bio(&self, client: ClientRef<'_>, content: &str) -> Markup {
7575
// Only sanitize for bio - no profile links or image transforms
76-
let renderer = jotdown::html::tokio::Renderer::default()
76+
let renderer = jotup::html::tokio::Renderer::default()
7777
.rostra_profile_links(client)
7878
.sanitize();
7979

crates/rostra-web-ui/src/routes/content/filters.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::borrow::Cow;
22

3-
use jotdown::r#async::{AsyncRender, AsyncRenderOutput};
4-
use jotdown::{AttributeKind, AttributeValue, Attributes, Container, Event};
3+
use jotup::r#async::{AsyncRender, AsyncRenderOutput};
4+
use jotup::{AttributeKind, AttributeValue, Attributes, Container, Event};
55
use rostra_client::ClientRef;
66
use rostra_core::id::RostraId;
77

@@ -42,7 +42,7 @@ where
4242

4343
async fn emit(&mut self, event: Event<'s>) -> Result<(), Self::Error> {
4444
match event {
45-
Event::Start(Container::Link(s, jotdown::LinkType::AutoLink), attr) => {
45+
Event::Start(Container::Link(s, jotup::LinkType::AutoLink), attr) => {
4646
if let Some(rostra_id) = UiState::extra_rostra_id_link(&s) {
4747
let display_name = self
4848
.client
@@ -56,7 +56,7 @@ where
5656
.emit(Event::Start(
5757
Container::Link(
5858
format!("/ui/profile/{rostra_id}").into(),
59-
jotdown::LinkType::Span(jotdown::SpanLinkType::Inline),
59+
jotup::LinkType::Span(jotup::SpanLinkType::Inline),
6060
),
6161
attr,
6262
))
@@ -65,7 +65,7 @@ where
6565
self.container_stack.push(ContainerKind::Other);
6666
self.inner
6767
.emit(Event::Start(
68-
Container::Link(s, jotdown::LinkType::AutoLink),
68+
Container::Link(s, jotup::LinkType::AutoLink),
6969
attr,
7070
))
7171
.await
@@ -132,7 +132,7 @@ enum ImageTransform<'s> {
132132
/// External embeddable media (YouTube, etc.) - stores the HTML and alt text
133133
EmbeddableMedia(String, String),
134134
/// Regular external image - stores the URL, link type, and alt text
135-
ExternalImage(Cow<'s, str>, jotdown::SpanLinkType, String),
135+
ExternalImage(Cow<'s, str>, jotup::SpanLinkType, String),
136136
}
137137

138138
/// Filter that transforms images:
@@ -174,7 +174,7 @@ where
174174
.emit(Event::Start(
175175
Container::Image(
176176
format!("/ui/media/{}/{}", self.author_id, event_id).into(),
177-
jotdown::SpanLinkType::Inline,
177+
jotup::SpanLinkType::Inline,
178178
),
179179
attr,
180180
))
@@ -198,7 +198,7 @@ where
198198
Container::Div {
199199
class: "lazyload-wrapper".into(),
200200
},
201-
jotdown::Attributes::try_from(
201+
jotup::Attributes::try_from(
202202
"{ onclick=\"this.classList.add('-expanded')\" }",
203203
)
204204
.expect("Can't fail"),

crates/rostra-web-ui/src/routes/settings.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,7 @@ pub async fn post_unfollow(
5757

5858
// Return updated followee list
5959
let followees = client_ref.db().get_followees(user_id).await;
60-
Ok(Maud(
61-
state
62-
.render_followee_list(&session, followees)
63-
.await?,
64-
))
60+
Ok(Maud(state.render_followee_list(&session, followees).await?))
6561
}
6662

6763
impl UiState {

flake.nix

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,22 @@
9090
);
9191
in
9292
rec {
93+
workspaceDeps = craneLib.buildWorkspaceDepsOnly { };
94+
95+
workspace = craneLib.buildWorkspace {
96+
cargoArtifacts = workspaceDeps;
97+
};
98+
99+
tests = craneLib.cargoNextest {
100+
cargoArtifacts = workspace;
101+
};
102+
103+
clippy = craneLib.cargoClippy {
104+
# must be deps, otherwise it will not rebuild
105+
# anything and thus not detect anything
106+
cargoArtifacts = workspaceDeps;
107+
};
108+
93109
rostraDeps = craneLib.buildDepsOnly { };
94110
rostra = craneLib.buildPackage {
95111
meta.mainProgram = "rostra";

0 commit comments

Comments
 (0)