Skip to content

Commit cc920c7

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

File tree

22 files changed

+169
-143
lines changed

22 files changed

+169
-143
lines changed

.github/workflows/ci.yml

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,19 @@ 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
3641
- uses: dtolnay/rust-toolchain@stable
3742
with:
3843
components: clippy
3944
targets: wasm32-unknown-unknown
4045
# lint the main library workspace for non-wasm target
41-
- run: cargo clippy --all-features -- -D warnings
46+
- run: cargo clippy --features all -- -D warnings -A deprecated
4247
# lint the non-wasm examples
43-
- run: cd ${{ github.workspace }}/examples && cargo clippy --workspace --exclude "wasm*" -- -D warnings
48+
- run: cd ${{ github.workspace }}/examples && cargo clippy --workspace --exclude "wasm*" --exclude "kaleido" -- -D warnings
4449
# lint the plotly library for wasm target
4550
- run: cargo clippy --package plotly --target wasm32-unknown-unknown -- -D warnings
4651
# lint the wasm examples
@@ -68,12 +73,54 @@ jobs:
6873
os: [ubuntu-latest, windows-latest, macos-latest]
6974
runs-on: ${{ matrix.os }}
7075
steps:
76+
- name: Setup Chrome
77+
uses: browser-actions/setup-chrome@v1
78+
with:
79+
chrome-version: 'latest'
80+
install-chromedriver: true
7181
- uses: actions/checkout@v4
7282
- uses: dtolnay/rust-toolchain@stable
73-
- run: cargo test --features plotly_ndarray,plotly_image,kaleido
83+
- run: cargo test --features plotly_ndarray,plotly_image,static_export_default
7484
- if: ${{ matrix.os == 'windows-latest' }}
7585
run: gci -recurse -filter "*example*"
7686

87+
test-static-export:
88+
name: Test Static Export
89+
strategy:
90+
fail-fast: false
91+
matrix:
92+
os: [ubuntu-latest, windows-latest, macos-latest]
93+
browser: [firefox, chrome]
94+
runs-on: ${{ matrix.os }}
95+
steps:
96+
- uses: actions/checkout@v4
97+
98+
- name: Setup Firefox
99+
if: matrix.browser == 'firefox'
100+
uses: browser-actions/setup-firefox@v1
101+
with:
102+
firefox-version: 'latest'
103+
104+
- name: Setup Chrome
105+
if: matrix.browser == 'chrome'
106+
uses: browser-actions/setup-chrome@v1
107+
with:
108+
chrome-version: 'latest'
109+
install-chromedriver: true
110+
111+
- uses: dtolnay/rust-toolchain@stable
112+
113+
- name: Test plotly and plotly_static
114+
shell: bash
115+
run: |
116+
if [ "${{ matrix.browser }}" = "firefox" ]; then
117+
cargo test -p plotly --features static_export_default --lib
118+
cargo test -p plotly_static --features geckodriver,webdriver_download
119+
else
120+
cargo test -p plotly --features static_export_chromedriver,static_export_downloader --lib
121+
cargo test -p plotly_static --features chromedriver,webdriver_download
122+
fi
123+
77124
code-coverage:
78125
name: Code Coverage
79126
runs-on: ubuntu-latest
@@ -103,12 +150,20 @@ jobs:
103150
ndarray,
104151
scientific_charts,
105152
shapes,
153+
static_export,
106154
subplots,
107155
themes,
108156
]
109157
runs-on: ubuntu-latest
110158
steps:
111159
- uses: actions/checkout@v4
160+
161+
- name: Setup Firefox (for static_export)
162+
if: matrix.example == 'static_export'
163+
uses: browser-actions/setup-firefox@v1
164+
with:
165+
firefox-version: 'latest'
166+
112167
- uses: dtolnay/rust-toolchain@stable
113168
- run: cd ${{ github.workspace }}/examples/${{ matrix.example }} && cargo build
114169

@@ -131,6 +186,12 @@ jobs:
131186
runs-on: ubuntu-latest
132187
steps:
133188
- uses: actions/checkout@v4
189+
190+
- name: Setup Firefox (for static_export example)
191+
uses: browser-actions/setup-firefox@v1
192+
with:
193+
firefox-version: 'latest'
194+
134195
- uses: dtolnay/rust-toolchain@stable
135196
- run: cargo install mdbook --no-default-features --features search --vers "^0.4" --locked --quiet
136197
- name: Build examples to generate needed html files
@@ -143,5 +204,6 @@ jobs:
143204
cd ${{ github.workspace }}/examples/subplots && cargo run
144205
cd ${{ github.workspace }}/examples/shapes && cargo run
145206
cd ${{ github.workspace }}/examples/themes && cargo run
207+
cd ${{ github.workspace }}/examples/static_export && cargo run
146208
- name: Build book
147209
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

docs/book/src/getting_started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ To start using [plotly.rs](https://github.com/plotly/plotly.rs) in your project
2222

2323
```toml
2424
[dependencies]
25-
plotly = "0.12"
25+
plotly = "0.13"
2626
```
2727

2828
[Plotly.rs](https://github.com/plotly/plotly.rs) is ultimately a thin wrapper around the `plotly.js` library. The main job of this library is to provide `structs` and `enums` which get serialized to `json` and passed to the `plotly.js` library to actually do the heavy lifting. As such, if you are familiar with `plotly.js` or its derivatives (e.g. the equivalent Python library), then you should find [`plotly.rs`](https://github.com/plotly/plotly.rs) intuitive to use.

examples/custom_controls/src/main.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ fn sinusoidal_slider_example(show: bool, file_name: &str) {
280280
Visible::False
281281
}) // Make 10th trace visible
282282
.line(plotly::common::Line::new().color("#00CED1").width(6.0))
283-
.name(format!("ν = {:.1}", frequency));
283+
.name(format!("ν = {frequency:.1}"));
284284
plot.add_trace(trace);
285285
}
286286

@@ -291,12 +291,11 @@ fn sinusoidal_slider_example(show: bool, file_name: &str) {
291291
let mut visible = vec![Visible::False; num_steps];
292292
visible[i] = Visible::True;
293293
let step = SliderStepBuilder::new()
294-
.label(format!("step-{}", i))
295-
.value(format!("{:.1}", frequency))
294+
.label(format!("step-{i}"))
295+
.value(format!("{frequency:.1}"))
296296
.push_restyle(Scatter::<f64, f64>::modify_visible(visible))
297297
.push_relayout(Layout::modify_title(format!(
298-
"Slider switched to step: {}",
299-
i
298+
"Slider switched to step: {i}"
300299
)))
301300
.build()
302301
.unwrap();
@@ -389,12 +388,11 @@ fn gdp_life_expectancy_slider_example(show: bool, file_name: &str) {
389388
visible[start..end].fill(Visible::True);
390389

391390
SliderStepBuilder::new()
392-
.label(format!("year = {}", year))
391+
.label(format!("year = {year}"))
393392
.value(year)
394393
.push_restyle(Scatter::<f64, f64>::modify_visible(visible))
395394
.push_relayout(Layout::modify_title(format!(
396-
"GDP vs. Life Expectancy ({})",
397-
year
395+
"GDP vs. Life Expectancy ({year})"
398396
)))
399397
.build()
400398
.unwrap()

examples/customization/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn multiple_plots_on_same_html_page(show: bool, file_name: &str) {
4949
.to_html_string();
5050

5151
std::fs::create_dir_all("./output").unwrap();
52-
let path = format!("./output/inline_{}.html", file_name);
52+
let path = format!("./output/inline_{file_name}.html");
5353
let mut file = File::create(&path).unwrap();
5454
file.write_all(html.as_bytes())
5555
.expect("failed to write html output");

examples/plotly_utils/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ pub fn write_example_to_html(plot: &Plot, name: &str) -> String {
1818
std::fs::create_dir_all("./output").unwrap();
1919
// Write inline HTML
2020
let html = plot.to_inline_html(Some(name));
21-
let path = format!("./output/inline_{}.html", name);
21+
let path = format!("./output/inline_{name}.html");
2222
std::fs::write(path, html).unwrap();
2323
// Write standalone HTML
24-
let path = format!("./output/{}.html", name);
24+
let path = format!("./output/{name}.html");
2525
plot.write_html(&path);
2626
path
2727
}

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)?;

examples/subplots/src/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,16 +360,16 @@ fn many_subplots_with_titles(show: bool, file_name: &str) {
360360
plot.add_trace(
361361
trace1
362362
.clone()
363-
.y_axis(format!("y{}", i))
364-
.x_axis(format!("x{}", i)),
363+
.y_axis(format!("y{i}"))
364+
.x_axis(format!("x{i}")),
365365
);
366366
layout.add_annotation(
367367
Annotation::new()
368-
.y_ref(format!("y{} domain", i))
368+
.y_ref(format!("y{i} domain"))
369369
.y_anchor(Anchor::Bottom)
370370
.y(1)
371-
.text(format!("Title {}", i))
372-
.x_ref(format!("x{} domain", i))
371+
.text(format!("Title {i}"))
372+
.x_ref(format!("x{i} domain"))
373373
.x_anchor(Anchor::Center)
374374
.x(0.5)
375375
.show_arrow(false),

0 commit comments

Comments
 (0)