Skip to content

Commit 825a628

Browse files
committed
add ci using static crate
Signed-off-by: Andrei Gherghescu <[email protected]>
1 parent fa80868 commit 825a628

File tree

17 files changed

+139
-90
lines changed

17 files changed

+139
-90
lines changed

.github/workflows/ci.yml

Lines changed: 68 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,20 @@ jobs:
3333
runs-on: ubuntu-latest
3434
steps:
3535
- uses: actions/checkout@v4
36+
- name: Setup Chrome
37+
uses: browser-actions/setup-chrome@v1
38+
with:
39+
chrome-version: 'latest'
40+
install-chromedriver: true
41+
install-dependencies: true
3642
- uses: dtolnay/rust-toolchain@stable
3743
with:
3844
components: clippy
3945
targets: wasm32-unknown-unknown
4046
# lint the main library workspace for non-wasm target
41-
- run: cargo clippy --all-features -- -D warnings
47+
- run: cargo clippy --features all -- -D warnings -A deprecated
4248
# lint the non-wasm examples
43-
- run: cd ${{ github.workspace }}/examples && cargo clippy --workspace --exclude "wasm*" -- -D warnings
49+
- run: cd ${{ github.workspace }}/examples && cargo clippy --workspace --exclude "wasm*" --exclude "kaleido" -- -D warnings
4450
# lint the plotly library for wasm target
4551
- run: cargo clippy --package plotly --target wasm32-unknown-unknown -- -D warnings
4652
# lint the wasm examples
@@ -68,12 +74,56 @@ jobs:
6874
os: [ubuntu-latest, windows-latest, macos-latest]
6975
runs-on: ${{ matrix.os }}
7076
steps:
77+
- name: Setup Chrome
78+
uses: browser-actions/setup-chrome@v1
79+
with:
80+
chrome-version: 'latest'
81+
install-chromedriver: true
82+
install-dependencies: true
7183
- uses: actions/checkout@v4
7284
- uses: dtolnay/rust-toolchain@stable
73-
- run: cargo test --features plotly_ndarray,plotly_image,kaleido
85+
- run: cargo test --features plotly_ndarray,plotly_image,static_export_default
7486
- if: ${{ matrix.os == 'windows-latest' }}
7587
run: gci -recurse -filter "*example*"
7688

89+
test-static-export:
90+
name: Test Static Export
91+
strategy:
92+
fail-fast: false
93+
matrix:
94+
os: [ubuntu-latest, windows-latest, macos-latest]
95+
browser: [firefox, chrome]
96+
runs-on: ${{ matrix.os }}
97+
steps:
98+
- uses: actions/checkout@v4
99+
100+
- name: Setup Firefox
101+
if: matrix.browser == 'firefox'
102+
uses: browser-actions/setup-firefox@v1
103+
with:
104+
firefox-version: 'latest'
105+
106+
- name: Setup Chrome
107+
if: matrix.browser == 'chrome'
108+
uses: browser-actions/setup-chrome@v1
109+
with:
110+
chrome-version: 'latest'
111+
install-chromedriver: true
112+
install-dependencies: true
113+
114+
- uses: dtolnay/rust-toolchain@stable
115+
116+
- name: Test plotly and plotly_static
117+
shell: bash
118+
run: |
119+
if [ "${{ matrix.browser }}" = "firefox" ]; then
120+
cargo test --features static_export_default --lib
121+
cd plotly_static && cargo test --features geckodriver,webdriver_download
122+
else
123+
cargo test --features static_export_chromedriver,static_export_downloader --lib
124+
cd plotly_static && cargo test --features chromedriver,webdriver_download
125+
fi
126+
77127
code-coverage:
78128
name: Code Coverage
79129
runs-on: ubuntu-latest
@@ -103,12 +153,20 @@ jobs:
103153
ndarray,
104154
scientific_charts,
105155
shapes,
156+
static_export,
106157
subplots,
107158
themes,
108159
]
109160
runs-on: ubuntu-latest
110161
steps:
111162
- uses: actions/checkout@v4
163+
164+
- name: Setup Firefox (for static_export)
165+
if: matrix.example == 'static_export'
166+
uses: browser-actions/setup-firefox@v1
167+
with:
168+
firefox-version: 'latest'
169+
112170
- uses: dtolnay/rust-toolchain@stable
113171
- run: cd ${{ github.workspace }}/examples/${{ matrix.example }} && cargo build
114172

@@ -131,6 +189,12 @@ jobs:
131189
runs-on: ubuntu-latest
132190
steps:
133191
- uses: actions/checkout@v4
192+
193+
- name: Setup Firefox (for static_export example)
194+
uses: browser-actions/setup-firefox@v1
195+
with:
196+
firefox-version: 'latest'
197+
134198
- uses: dtolnay/rust-toolchain@stable
135199
- run: cargo install mdbook --no-default-features --features search --vers "^0.4" --locked --quiet
136200
- name: Build examples to generate needed html files
@@ -143,5 +207,6 @@ jobs:
143207
cd ${{ github.workspace }}/examples/subplots && cargo run
144208
cd ${{ github.workspace }}/examples/shapes && cargo run
145209
cd ${{ github.workspace }}/examples/themes && cargo run
210+
cd ${{ github.workspace }}/examples/static_export && cargo run
146211
- name: Build book
147212
run: mdbook build docs/book

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Add this to your `Cargo.toml`:
6161

6262
```toml
6363
[dependencies]
64-
plotly = "0.12"
64+
plotly = "0.13"
6565
```
6666

6767
## Exporting a single Interactive Plot
@@ -113,7 +113,7 @@ The recommended way to export static images is using the `plotly_static` backend
113113

114114
```toml
115115
[dependencies]
116-
plotly = { version = "0.12", features = ["static_export_default"] }
116+
plotly = { version = "0.13", features = ["static_export_default"] }
117117
```
118118

119119
This supports PNG, JPEG, WEBP, SVG, and PDF formats:
@@ -140,7 +140,7 @@ Enable the `kaleido` feature and opt in for automatic downloading of the `kaleid
140140
# Cargo.toml
141141

142142
[dependencies]
143-
plotly = { version = "0.12", features = ["kaleido", "kaleido_download"] }
143+
plotly = { version = "0.13", features = ["kaleido", "kaleido_download"] }
144144
```
145145

146146
Alternatively, enable only the `kaleido` feature and manually install Kaleido.

docs/book/src/fundamentals/static_image_export.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ The static export functionality is controlled by feature flags in the main `plot
1616

1717
### Optional Features:
1818
- `static_export_downloader`: Automatically downloads WebDriver binaries at build time
19-
- `static_export_default`: Convenience feature that includes geckodriver + downloader
19+
- `static_export_default`: Convenience feature that includes chromedriver + downloader
2020

2121
### Cargo.toml Configuration Examples:
2222

2323
```toml
2424
# Basic usage with manual WebDriver installation
2525
[dependencies]
26-
plotly = { version = "0.12", features = ["static_export_chromedriver"] }
26+
plotly = { version = "0.13", features = ["static_export_chromedriver"] }
2727

2828
# With automatic WebDriver download
2929
[dependencies]
30-
plotly = { version = "0.12", features = ["static_export_chromedriver", "static_export_downloader"] }
30+
plotly = { version = "0.13", features = ["static_export_chromedriver", "static_export_downloader"] }
3131

3232
# Recommended: Default configuration with Firefox + auto-download
3333
[dependencies]
34-
plotly = { version = "0.12", features = ["static_export_default"] }
34+
plotly = { version = "0.13", features = ["static_export_default"] }
3535
```
3636

3737
## Prerequisites

examples/static_export/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ The `plotly_static` crate provides a high-level interface for converting Plotly
2424

2525
The example uses `static_export_default` which includes:
2626
- `plotly_static`: Core static export functionality
27-
- `plotly_static/geckodriver`: Firefox WebDriver support
27+
- `plotly_static/chromedriver`: Chrome WebDriver support
2828
- `plotly_static/webdriver_download`: Automatic WebDriver download
2929

3030
### Alternative Configurations
3131

3232
```toml
3333
# Use Chrome/Chromium instead of Firefox
34-
plotly = { version = "0.12", features = ["static_export_chromedriver", "static_export_downloader"] }
34+
plotly = { version = "0.13", features = ["static_export_chromedriver", "static_export_downloader"] }
3535

3636
# Manual WebDriver installation (no automatic download)
37-
plotly = { version = "0.12", features = ["static_export_geckodriver"] }
37+
plotly = { version = "0.13", features = ["static_export_geckodriver"] }
3838

3939
# Chrome with manual installation
40-
plotly = { version = "0.12", features = ["static_export_chromedriver"] }
40+
plotly = { version = "0.13", features = ["static_export_chromedriver"] }
4141
```
4242

4343
## Running the Example

examples/static_export/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use env_logger;
21
use log::info;
32
use plotly::plotly_static::{ImageFormat, StaticExporterBuilder};
43
use plotly::{Plot, Scatter};
@@ -41,7 +40,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
4140

4241
// Demonstrate string-based export (useful for web applications)
4342
info!("Exporting to base64 and SVG strings...");
44-
43+
4544
// Get base64 data (useful for embedding in HTML or APIs)
4645
let base64_data =
4746
plot1.to_base64_with_exporter(&mut exporter, ImageFormat::PNG, 400, 300, 1.0)?;

plotly/Cargo.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "plotly"
3-
version = "0.12.1"
3+
version = "0.13.0"
44
description = "A plotting library powered by Plotly.js"
55
authors = ["Ioannis Giagkiozis <[email protected]>", "Andrei Gherghescu <[email protected]>"]
66
license = "MIT"
@@ -22,7 +22,10 @@ kaleido_download = ["plotly_kaleido/download"]
2222
static_export_downloader = ["plotly_static/webdriver_download"]
2323
static_export_chromedriver = ["plotly_static", "plotly_static/chromedriver"]
2424
static_export_geckodriver = ["plotly_static", "plotly_static/geckodriver"]
25-
static_export_default = ["plotly_static", "plotly_static/geckodriver", "plotly_static/webdriver_download"]
25+
static_export_default = ["plotly_static", "plotly_static/chromedriver", "plotly_static/webdriver_download"]
26+
27+
# All non-conflicting features
28+
all = ["plotly_ndarray", "plotly_image", "plotly_embed_js", "static_export_default"]
2629

2730
plotly_ndarray = ["ndarray"]
2831
plotly_image = ["image"]
@@ -33,7 +36,7 @@ askama = { version = "0.14.0", features = ["serde_json"] }
3336
dyn-clone = "1"
3437
erased-serde = "0.4"
3538
image = { version = "0.25", optional = true }
36-
plotly_derive = { version = "0.12", path = "../plotly_derive" }
39+
plotly_derive = { version = "0.13", path = "../plotly_derive" }
3740
plotly_static = { version = "0.0.1", path = "../plotly_static", optional = true }
3841
plotly_kaleido = { version = "0.12", path = "../plotly_kaleido", optional = true }
3942
ndarray = { version = "0.16", optional = true }

plotly/src/layout/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,19 @@ impl std::fmt::Display for ControlBuilderError {
6565
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
6666
match self {
6767
ControlBuilderError::RestyleSerializationError(e) => {
68-
write!(f, "Failed to serialize restyle: {}", e)
68+
write!(f, "Failed to serialize restyle: {e}")
6969
}
7070
ControlBuilderError::RelayoutSerializationError(e) => {
71-
write!(f, "Failed to serialize relayout: {}", e)
71+
write!(f, "Failed to serialize relayout: {e}")
7272
}
7373
ControlBuilderError::ValueSerializationError(e) => {
74-
write!(f, "Failed to serialize value: {}", e)
74+
write!(f, "Failed to serialize value: {e}")
7575
}
7676
ControlBuilderError::InvalidRestyleObject(s) => {
77-
write!(f, "Invalid restyle object: expected object but got {}", s)
77+
write!(f, "Invalid restyle object: expected object but got {s}")
7878
}
7979
ControlBuilderError::InvalidRelayoutObject(s) => {
80-
write!(f, "Invalid relayout object: expected object but got {}", s)
80+
write!(f, "Invalid relayout object: expected object but got {s}")
8181
}
8282
}
8383
}

plotly/src/plot.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl Plot {
233233
let mut temp = env::temp_dir();
234234
let mut plot_name = Alphanumeric.sample_string(&mut rng(), 22);
235235
plot_name.push_str(".html");
236-
plot_name = format!("plotly_{}", plot_name);
236+
plot_name = format!("plotly_{plot_name}");
237237
temp.push(plot_name);
238238

239239
// Save the rendered plot to the temp file.
@@ -276,7 +276,7 @@ impl Plot {
276276
let mut temp = env::temp_dir();
277277
let mut plot_name = Alphanumeric.sample_string(&mut rng(), 22);
278278
plot_name.push_str(".html");
279-
plot_name = format!("plotly_{}", plot_name);
279+
plot_name = format!("plotly_{plot_name}");
280280
temp.push(plot_name);
281281

282282
// Save the rendered plot to the temp file.
@@ -351,17 +351,15 @@ impl Plot {
351351
pub fn notebook_display(&self) {
352352
let plot_data = self.to_jupyter_notebook_html();
353353
println!(
354-
"EVCXR_BEGIN_CONTENT text/html\n{}\nEVCXR_END_CONTENT",
355-
plot_data
354+
"EVCXR_BEGIN_CONTENT text/html\n{plot_data}\nEVCXR_END_CONTENT"
356355
);
357356
}
358357

359358
/// Display plot in Jupyter Lab.
360359
pub fn lab_display(&self) {
361360
let plot_data = self.to_json();
362361
println!(
363-
"EVCXR_BEGIN_CONTENT application/vnd.plotly.v1+json\n{}\nEVCXR_END_CONTENT",
364-
plot_data
362+
"EVCXR_BEGIN_CONTENT application/vnd.plotly.v1+json\n{plot_data}\nEVCXR_END_CONTENT"
365363
);
366364
}
367365

@@ -487,7 +485,7 @@ impl Plot {
487485
) -> Result<(), Box<dyn std::error::Error>> {
488486
let mut exporter = plotly_static::StaticExporterBuilder::default()
489487
.build()
490-
.map_err(|e| format!("Failed to create StaticExporter: {}", e))?;
488+
.map_err(|e| format!("Failed to create StaticExporter: {e}"))?;
491489
self.write_image_with_exporter(&mut exporter, filename, format, width, height, scale)
492490
}
493491

@@ -515,7 +513,7 @@ impl Plot {
515513
) -> Result<String, Box<dyn std::error::Error>> {
516514
let mut exporter = plotly_static::StaticExporterBuilder::default()
517515
.build()
518-
.map_err(|e| format!("Failed to create StaticExporter: {}", e))?;
516+
.map_err(|e| format!("Failed to create StaticExporter: {e}"))?;
519517
self.to_base64_with_exporter(&mut exporter, format, width, height, scale)
520518
}
521519

@@ -538,7 +536,7 @@ impl Plot {
538536
) -> Result<String, Box<dyn std::error::Error>> {
539537
let mut exporter = plotly_static::StaticExporterBuilder::default()
540538
.build()
541-
.map_err(|e| format!("Failed to create StaticExporter: {}", e))?;
539+
.map_err(|e| format!("Failed to create StaticExporter: {e}"))?;
542540
self.to_svg_with_exporter(&mut exporter, width, height, scale)
543541
}
544542

@@ -752,9 +750,8 @@ impl Plot {
752750
let local_plotly_js = include_str!("../resource/plotly.min.js");
753751

754752
format!(
755-
"<script type=\"text/javascript\">{}</script>\n
756-
<script type=\"text/javascript\">{}</script>\n",
757-
local_plotly_js, local_tex_svg_js,
753+
"<script type=\"text/javascript\">{local_plotly_js}</script>\n
754+
<script type=\"text/javascript\">{local_tex_svg_js}</script>\n",
758755
)
759756
.to_string()
760757
}

plotly_derive/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "plotly_derive"
3-
version = "0.12.1"
3+
version = "0.13.0"
44
description = "Internal proc macro crate for Plotly-rs."
55
authors = ["Ioannis Giagkiozis <[email protected]>"]
66
license = "MIT"

0 commit comments

Comments
 (0)