Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update github workflows #43

Merged
merged 2 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,27 @@ jobs:
- name: Install wasm32-unknown-unknown target
run: rustup target add wasm32-unknown-unknown

# With no feature. Target: normal & wasm
# With no feature. Target: normal & wasm & wasm-bindgen
- name: Build
run: cargo build --verbose
- name: Build in wasm
run: cargo build --verbose --target wasm32-unknown-unknown
- name: Build in wasm-bindgen
run: cargo build --verbose -F wasm-bindgen --target wasm32-unknown-unknown

# With feature `svg`. Target: normal & wasm
# With feature `svg`. Target: normal & wasm & wasm-bindgen
- name: Build with `svg`
run: cargo build --verbose -F svg
- name: Build with `svg` in wasm
run: cargo build --verbose -F svg --target wasm32-unknown-unknown
- name: Build with `svg` in wasm-bindgen
run: cargo build --verbose -F svg,wasm-bindgen --target wasm32-unknown-unknown

# With feature `image`. Target: normal only
# With feature `image`. Target: normal & wasm only
- name: Build with `image`
run: cargo build --verbose -F image
- name: Build with `image` in wasm
run: cargo build --verbose -F image --target wasm32-unknown-unknown

# With feature `wasm-bindgen`. Target: wasm only
- name: Build with `wasm-bindgen`
Expand All @@ -49,11 +55,15 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install wasm32-unknown-unknown target
run: rustup target add wasm32-unknown-unknown

# Examples
- name: Build examples
run: |
for example in examples/*.rs; do
cargo run --example "$(basename "${example%.rs}")" -Fsvg,image
cargo build --example "$(basename "${example%.rs}")" -Fsvg,image --target wasm32-unknown-unknown
done
tests:
Expand Down
2 changes: 1 addition & 1 deletion src/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl From<SvgError> for ConvertError {
fn from(err: SvgError) -> Self {
match err {
SvgError::SvgError(svg_err) => Self::Svg(svg_err),
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(feature = "wasm-bindgen"))]
SvgError::IoError(io_err) => Self::Io(io_err),
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/convert/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub struct SvgBuilder {
/// Possible errors when converting to SVG
pub enum SvgError {
/// Error while writing file
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(feature = "wasm-bindgen"))]
IoError(std::io::Error),
/// Error while creating svg
SvgError(String),
Expand Down Expand Up @@ -322,7 +322,7 @@ impl SvgBuilder {
}

/// Saves the svg for a qr code to a file
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(feature = "wasm-bindgen"))]
pub fn to_file(&self, qr: &QRCode, file: &str) -> Result<(), SvgError> {
use std::fs::File;
use std::io::Write;
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ mod default;
mod ecl;
mod encode;
mod hardcode;
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(feature = "wasm-bindgen"))]
mod helpers;
mod module;
mod placement;
Expand Down
6 changes: 3 additions & 3 deletions src/qr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use core::ops::{Index, IndexMut};

use crate::datamasking::Mask;
use crate::encode::Mode;
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(feature = "wasm-bindgen"))]
use crate::helpers;
use crate::{encode, Version, ECL};

Expand Down Expand Up @@ -169,13 +169,13 @@ impl QRCode {

/// Prints the `QRCode` to the terminal
#[must_use]
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(feature = "wasm-bindgen"))]
pub fn to_str(&self) -> String {
helpers::print_matrix_with_margin(self)
}

/// Prints the `QRCode` to the terminal
#[cfg(not(target_arch = "wasm32"))]
#[cfg(not(feature = "wasm-bindgen"))]
pub fn print(&self) {
println!("{}", helpers::print_matrix_with_margin(self));
}
Expand Down