Skip to content

Commit 59c0e23

Browse files
jarjkitsjunetime
andauthored
ci cd (#132)
* ci: format * ci: run on tag push, manual dispatch * ci: release a tip on each push to `main` and tag release on tag pushes * ci: run on more platforms * ci: don't fail fast * ci: enable windows * Update .github/workflows/rust.yml Co-authored-by: June <61218022+itsjunetime@users.noreply.github.com> * Update .github/workflows/rust.yml Co-authored-by: June <61218022+itsjunetime@users.noreply.github.com> * Update .github/workflows/rust.yml Co-authored-by: June <61218022+itsjunetime@users.noreply.github.com> * chore: update custom `ratatui-image` rev * Update .github/workflows/rust.yml Co-authored-by: June <61218022+itsjunetime@users.noreply.github.com> * Update .github/workflows/rust.yml Co-authored-by: June <61218022+itsjunetime@users.noreply.github.com> * chore(deps): update kittage * Update kittage for maybe more windows fixes * Update kittage again for more windows fixes * Update kittage again..... * Maybe actually compile windows correctly now? * update kittage * oopsie forgot abt lock file * windows and kittage again ... * maybe fix the file path conversion stuff? * kittage once again........... --------- Co-authored-by: June <61218022+itsjunetime@users.noreply.github.com> Co-authored-by: itsjunetime <junewelker@gmail.com>
1 parent 52994b8 commit 59c0e23

7 files changed

Lines changed: 182 additions & 60 deletions

File tree

.github/workflows/rust.yml

Lines changed: 132 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,144 @@ name: Rust
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: ["main"]
6+
tags: ["v*.*.*"]
67
pull_request:
7-
branches: [ "main" ]
8+
branches: ["main"]
9+
workflow_dispatch:
10+
workflow_call:
811

912
env:
1013
CARGO_TERM_COLOR: always
14+
tip_release_path: RELEASE.md
1115

1216
jobs:
13-
build:
17+
test-build:
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- { os: "macos-latest", target: "aarch64-apple-darwin" }
23+
- { os: "ubuntu-latest", target: "x86_64-unknown-linux-gnu" }
24+
- {
25+
os: "windows-latest",
26+
target: "x86_64-pc-windows-msvc",
27+
ext: ".exe",
28+
}
29+
- { os: "ubuntu-24.04-arm", target: "aarch64-unknown-linux-gnu" }
1430

15-
runs-on: ubuntu-latest
31+
runs-on: ${{ matrix.os }}
1632

1733
steps:
18-
- name: Setup sccache
19-
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
20-
uses: mozilla-actions/sccache-action@v0.0.8
21-
- name: Configure sccache
22-
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
23-
run: |
24-
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
25-
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
26-
- name: Install build dependencies
27-
run: |
28-
sudo apt-get update
29-
sudo apt-get install -y libfontconfig1-dev libgoogle-perftools-dev google-perftools
30-
- uses: actions/checkout@v4
31-
- name: Install clippy and fmt
32-
run: rustup component add clippy rustfmt
33-
- name: Clippy
34-
run: cargo clippy --locked -- -D warnings
35-
- name: Tests
36-
run: cargo test --locked
37-
- name: Check fmt
38-
run: cargo fmt -- --check
39-
- name: Run benchmarks as tests
40-
run: cargo test --locked --benches -- adobe_example
41-
- name: Build
42-
run: cargo build --locked
34+
- uses: actions/checkout@v6
35+
36+
- name: Setup sccache
37+
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
38+
uses: mozilla-actions/sccache-action@v0.0.8
39+
- name: Configure sccache
40+
if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
41+
run: |
42+
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
43+
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
44+
45+
- name: Setup rust cache action
46+
uses: swatinem/rust-cache@v2
47+
with:
48+
cache-on-failure: true
49+
50+
- name: install build dependencies on ubuntu and cache
51+
if: contains(matrix.os, 'ubuntu')
52+
uses: awalsh128/cache-apt-pkgs-action@latest
53+
with:
54+
packages: libfontconfig1-dev libgoogle-perftools-dev google-perftools
55+
version: latest # could be anything
56+
57+
- name: Install clippy and fmt
58+
run: rustup component add clippy rustfmt
59+
- name: Clippy
60+
run: cargo clippy --locked -- -D warnings
61+
- name: Tests
62+
run: cargo test --locked
63+
- name: Check fmt
64+
run: cargo fmt -- --check
65+
- name: Run benchmarks as tests
66+
run: cargo test --locked --benches -- adobe_example
67+
68+
- name: Set build mode
69+
shell: bash
70+
run: if [ "${{github.ref_type}}" == "tag" ] || [ ${{ github.event_name == 'push' && github.ref_name == 'main' }} ]; then echo "BMODE=production">>"$GITHUB_ENV"; fi
71+
72+
- name: Build in ${{env.BMODE || 'debug'}} mode
73+
run: cargo build --verbose --locked --profile ${{env.BMODE || 'dev'}}
74+
75+
- name: Prepare artifact
76+
shell: bash
77+
run: |
78+
mkdir -p dist
79+
cp "target/${{env.BMODE || 'debug'}}/tdf${{ matrix.ext }}" dist/tdf-${{ matrix.target }}${{ matrix.ext }}
80+
tree dist || ls -la dist
81+
82+
- name: Upload artifacts
83+
uses: actions/upload-artifact@v5
84+
with:
85+
name: tdf-${{ matrix.target }}
86+
path: dist/tdf*
87+
88+
tag-release:
89+
name: Release on tag push
90+
runs-on: ubuntu-slim
91+
if: github.ref_type == 'tag'
92+
needs: test-build
93+
steps:
94+
- uses: actions/download-artifact@v6
95+
with:
96+
pattern: "**/tdf-*"
97+
path: release-artifacts
98+
merge-multiple: true
99+
100+
- name: What's up?
101+
run: tree release-artifacts # beautiful!
102+
103+
- name: Create a GitHub release
104+
uses: softprops/action-gh-release@v2
105+
with:
106+
draft: true
107+
generate_release_notes: true
108+
files: release-artifacts/*
109+
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
110+
111+
tip-release:
112+
name: Release tip on push to main
113+
runs-on: ubuntu-slim
114+
if: github.event_name == 'push' && github.ref_name == 'main'
115+
needs: test-build
116+
117+
steps:
118+
- uses: actions/checkout@v6
119+
- name: Download prebuilt artifacts
120+
uses: actions/download-artifact@v7
121+
with:
122+
path: release-artifacts
123+
merge-multiple: true
124+
125+
- name: Generate release notes
126+
run: |
127+
tree release-artifacts/
128+
echo "From commit: $(git rev-parse --short HEAD)" > ${{ env.tip_release_path }}
129+
echo "Generated on: $(date -u +"%Y-%m-%d %H:%M") UTC" >> ${{ env.tip_release_path }}
130+
cat ${{ env.tip_release_path }}
131+
132+
- name: Update the tip tag
133+
run: |
134+
git config user.name "github-actions[bot]"
135+
git config user.email "github-actions[bot]@users.noreply.github.com"
136+
git tag --force tip && git push --force origin tag tip
137+
138+
- name: Update the draft tip release
139+
uses: softprops/action-gh-release@v2
140+
with:
141+
prerelease: true
142+
files: release-artifacts/*
143+
tag_name: tip
144+
name: Tip Build
145+
body_path: ${{ env.tip_release_path }}

Cargo.lock

Lines changed: 16 additions & 16 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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ nix = { version = "0.31.0", features = ["signal"] }
4141
mupdf = { git = "https://github.com/messense/mupdf-rs.git", rev = "d7441b9998c92135e329559c0aa71d9dc92cf4de", default-features = false, features = ["svg", "system-fonts", "img"] }
4242
rayon = { version = "1", default-features = false }
4343
# kittage = { path = "../kittage/", features = ["crossterm-tokio", "image-crate", "log"] }
44-
kittage = { version = "0.1.1", features = ["crossterm-tokio", "image-crate", "log"] }
44+
kittage = { version = "0.3.4", features = ["crossterm-tokio", "image-crate", "log"] }
4545
memmap2 = "0"
4646
csscolorparser = { version = "0.8.0", default-features = false }
4747
debounce = "0.2.2"

src/converter.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,14 @@ pub async fn run_conversion_loop(
144144
.as_nanos() % 1_000_000;
145145

146146
let mut img = if shms_work {
147-
kittage::image::Image::shm_from(dyn_img, &format!("/tdf_{pid}_{rn}_{page_num}"))
148-
.map_err(|e| {
149-
RenderError::Converting(format!("Couldn't write to shm: {e:?}"))
150-
})?
147+
let shm_name = format!("/tdf_{pid}_{rn}_{page_num}");
148+
149+
#[cfg(unix)]
150+
let shm_name = &*shm_name;
151+
152+
kittage::image::Image::shm_from(dyn_img, shm_name).map_err(|e| {
153+
RenderError::Converting(format!("Couldn't create shm: {e:?}"))
154+
})?
151155
} else {
152156
kittage::image::Image::from(dyn_img)
153157
};

src/kitty.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,12 @@ pub async fn run_action<'es>(
7878
pub async fn do_shms_work(ev_stream: &mut EventStream) -> bool {
7979
let img = DynamicImage::new_rgb8(1, 1);
8080
let pid = std::process::id();
81-
let Ok(mut k_img) = kittage::image::Image::shm_from(img, &format!("tdf_test_{pid}")) else {
81+
let shm_name = format!("tdf_test_{pid}");
82+
83+
#[cfg(unix)]
84+
let shm_name = &*shm_name;
85+
86+
let Ok(mut k_img) = kittage::image::Image::shm_from(img, shm_name) else {
8287
return false;
8388
};
8489

src/renderer.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,15 @@ pub fn start_rendering(
113113

114114
let mut need_rerender = VecDeque::new();
115115

116+
#[cfg(windows)]
117+
let path = path.to_string_lossy();
118+
116119
'reload: loop {
117-
let doc = match Document::open(path) {
120+
// Need to do this weird borrow thing so that we convert `Cow<'_, str>` -> `&str` on windows
121+
// and keep unix a `&Path` -> `&Path` 'cause there are different requirements within mupdf
122+
// about file paths per-platform
123+
#[cfg_attr(unix, expect(clippy::borrow_deref_ref))]
124+
let doc = match Document::open(&*path) {
118125
Err(e) => {
119126
// if there's an error, tell the main loop
120127
sender.send(Err(RenderError::Doc(e)))?;

src/tui.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ use crossterm::{
99
}
1010
};
1111
use kittage::display::DisplayLocation;
12-
use nix::{
13-
sys::signal::{Signal::SIGSTOP, kill},
14-
unistd::Pid
15-
};
1612
use ratatui::{
1713
Frame,
1814
layout::{Constraint, Flex, Layout, Position, Rect},
@@ -801,10 +797,17 @@ impl Tui {
801797
.unwrap();
802798
disable_raw_mode().unwrap();
803799

804-
// This process will hang after the SIGSTOP call until we get
805-
// foregrounded again by something else, at which point we need to
806-
// re-setup everything so that it all gets drawn again.
807-
kill(Pid::this(), SIGSTOP).unwrap();
800+
#[cfg(unix)]
801+
{
802+
// This process will hang after the SIGSTOP call until we get
803+
// foregrounded again by something else, at which point we need to
804+
// re-setup everything so that it all gets drawn again.
805+
nix::sys::signal::kill(
806+
nix::unistd::Pid::this(),
807+
nix::sys::signal::Signal::SIGSTOP
808+
)
809+
.unwrap();
810+
}
808811

809812
enable_raw_mode().unwrap();
810813
execute!(

0 commit comments

Comments
 (0)