Skip to content

Commit 00e08bf

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

File tree

6 files changed

+75
-8
lines changed

6 files changed

+75
-8
lines changed

.github/workflows/ci.yml

Lines changed: 67 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,55 @@ 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+
run: |
118+
if [ "${{ matrix.browser }}" = "firefox" ]; then
119+
cargo test --features static_export_default --lib
120+
cd plotly_static && cargo test --features geckodriver,webdriver_download
121+
else
122+
cargo test --features static_export_chromedriver,static_export_downloader --lib
123+
cd plotly_static && cargo test --features chromedriver,webdriver_download
124+
fi
125+
77126
code-coverage:
78127
name: Code Coverage
79128
runs-on: ubuntu-latest
@@ -103,12 +152,20 @@ jobs:
103152
ndarray,
104153
scientific_charts,
105154
shapes,
155+
static_export,
106156
subplots,
107157
themes,
108158
]
109159
runs-on: ubuntu-latest
110160
steps:
111161
- uses: actions/checkout@v4
162+
163+
- name: Setup Firefox (for static_export)
164+
if: matrix.example == 'static_export'
165+
uses: browser-actions/setup-firefox@v1
166+
with:
167+
firefox-version: 'latest'
168+
112169
- uses: dtolnay/rust-toolchain@stable
113170
- run: cd ${{ github.workspace }}/examples/${{ matrix.example }} && cargo build
114171

@@ -131,6 +188,12 @@ jobs:
131188
runs-on: ubuntu-latest
132189
steps:
133190
- uses: actions/checkout@v4
191+
192+
- name: Setup Firefox (for static_export example)
193+
uses: browser-actions/setup-firefox@v1
194+
with:
195+
firefox-version: 'latest'
196+
134197
- uses: dtolnay/rust-toolchain@stable
135198
- run: cargo install mdbook --no-default-features --features search --vers "^0.4" --locked --quiet
136199
- name: Build examples to generate needed html files
@@ -143,5 +206,6 @@ jobs:
143206
cd ${{ github.workspace }}/examples/subplots && cargo run
144207
cd ${{ github.workspace }}/examples/shapes && cargo run
145208
cd ${{ github.workspace }}/examples/themes && cargo run
209+
cd ${{ github.workspace }}/examples/static_export && cargo run
146210
- name: Build book
147211
run: mdbook build docs/book

docs/book/src/fundamentals/static_image_export.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ 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

examples/static_export/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ 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

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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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"]

plotly_static/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ pub enum ImageFormat {
332332
since = "0.13.0",
333333
note = "Use SVG or PDF instead. EPS variant will be removed in version 0.14.0"
334334
)]
335+
#[allow(deprecated)]
335336
EPS,
336337
}
337338

0 commit comments

Comments
 (0)