- workflow fix
- bump dependencies
This commit is contained in:
1 parent
f94c77c3f8
commit
7af9cdb5a3
7 files changed
+42
-37
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
name: Publish_rs
|
name: Publish_rs
|
||||||
|
|
||||||
on: [workflow_dispatch]
|
on: [ workflow_dispatch ]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@@ -10,24 +10,25 @@ jobs:
|
|||||||
name: Publish (crates.io)
|
name: Publish (crates.io)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 25
|
timeout-minutes: 25
|
||||||
|
env:
|
||||||
|
CARGO_HOME: ${{ github.workspace }}/.cargo
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- name: Restore cache
|
- name: Restore cache
|
||||||
uses: actions/cache/restore@v4
|
uses: actions/cache/restore@v4
|
||||||
with:
|
with:
|
||||||
path: |
|
path: ${{ env.CARGO_HOME }}
|
||||||
~/.cargo
|
|
||||||
key: cache-ubuntu-cargo-publish
|
key: cache-ubuntu-cargo-publish
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
run: |-
|
run: |-
|
||||||
export PATH="${CARGO_HOME:-$HOME/.cargo}/bin:$PATH"
|
export PATH="$CARGO_HOME/bin:$PATH"
|
||||||
if ! command -v rustc >/dev/null 2>&1; then
|
if ! command -v rustc >/dev/null 2>&1; then
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||||
else
|
else
|
||||||
rustup update
|
rustup update
|
||||||
fi
|
fi
|
||||||
echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> "$GITHUB_PATH"
|
echo "$CARGO_HOME/bin" >> "$GITHUB_PATH"
|
||||||
cargo install cargo-release
|
cargo install cargo-release
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
@@ -47,8 +48,9 @@ jobs:
|
|||||||
# which is reasonable, since this job only runs after the Linux, Windows, and WASM builds
|
# which is reasonable, since this job only runs after the Linux, Windows, and WASM builds
|
||||||
# have passed.
|
# have passed.
|
||||||
- name: "cargo release publish"
|
- name: "cargo release publish"
|
||||||
|
env:
|
||||||
|
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_API_TOKEN }}
|
||||||
run: |-
|
run: |-
|
||||||
cargo login ${{ secrets.CRATES_IO_API_TOKEN }}
|
|
||||||
cargo release \
|
cargo release \
|
||||||
publish \
|
publish \
|
||||||
--workspace \
|
--workspace \
|
||||||
@@ -61,6 +63,5 @@ jobs:
|
|||||||
- name: Store cache
|
- name: Store cache
|
||||||
uses: actions/cache/save@v4
|
uses: actions/cache/save@v4
|
||||||
with:
|
with:
|
||||||
path: |
|
path: ${{ env.CARGO_HOME }}
|
||||||
~/.cargo
|
|
||||||
key: cache-ubuntu-cargo-publish
|
key: cache-ubuntu-cargo-publish
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
name: Publish_py
|
name: Publish_py
|
||||||
|
|
||||||
on: [workflow_dispatch]
|
on: [ workflow_dispatch ]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@@ -9,6 +9,8 @@ jobs:
|
|||||||
pypi_publish:
|
pypi_publish:
|
||||||
name: Publish (pypi.org)
|
name: Publish (pypi.org)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
CARGO_HOME: ${{ github.workspace }}/.cargo
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@v6
|
||||||
- uses: actions/setup-python@v5
|
- uses: actions/setup-python@v5
|
||||||
@@ -23,7 +25,7 @@ jobs:
|
|||||||
~/.cache/pip-wheel
|
~/.cache/pip-wheel
|
||||||
~/.cache/sccache
|
~/.cache/sccache
|
||||||
~/.cache/cargo-xwin
|
~/.cache/cargo-xwin
|
||||||
~/.cargo
|
${{ env.CARGO_HOME }}
|
||||||
~/.osxcross
|
~/.osxcross
|
||||||
key: cache-ubuntu-maturin-cross-compile
|
key: cache-ubuntu-maturin-cross-compile
|
||||||
|
|
||||||
@@ -37,17 +39,18 @@ jobs:
|
|||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
run: |
|
run: |
|
||||||
export PATH="$HOME/.cargo/bin:$PATH"
|
export PATH="$CARGO_HOME/bin:$PATH"
|
||||||
if ! command -v rustc >/dev/null 2>&1; then
|
if ! command -v rustc >/dev/null 2>&1; then
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||||
else
|
else
|
||||||
rustup update
|
rustup update
|
||||||
fi
|
fi
|
||||||
|
echo "$CARGO_HOME/bin" >> "$GITHUB_PATH"
|
||||||
|
cargo --version
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: Install sccache and maturin
|
- name: Install sccache and maturin
|
||||||
run: |
|
run: |
|
||||||
export PATH="$HOME/.cargo/bin:$PATH"
|
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install maturin ziglang
|
pip install maturin ziglang
|
||||||
if ! command -v sccache >/dev/null 2>&1; then
|
if ! command -v sccache >/dev/null 2>&1; then
|
||||||
@@ -57,7 +60,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Install xwin
|
- name: Install xwin
|
||||||
run: |
|
run: |
|
||||||
export PATH="$HOME/.cargo/bin:$PATH"
|
|
||||||
if ! command -v cargo-xwin >/dev/null 2>&1; then
|
if ! command -v cargo-xwin >/dev/null 2>&1; then
|
||||||
cargo install cargo-xwin || pip install cargo-xwin
|
cargo install cargo-xwin || pip install cargo-xwin
|
||||||
cargo xwin cache xwin
|
cargo xwin cache xwin
|
||||||
@@ -75,7 +77,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Build wheels
|
- name: Build wheels
|
||||||
run: |
|
run: |
|
||||||
export PATH="$HOME/.cargo/bin:$HOME/.osxcross/bin:$PATH"
|
export PATH="$HOME/.osxcross/bin:$PATH"
|
||||||
rustup default stable
|
rustup default stable
|
||||||
rm -rf dist
|
rm -rf dist
|
||||||
maturin sdist --out dist -m ome-metadata/Cargo.toml
|
maturin sdist --out dist -m ome-metadata/Cargo.toml
|
||||||
@@ -107,7 +109,7 @@ jobs:
|
|||||||
~/.cache/pip-wheel
|
~/.cache/pip-wheel
|
||||||
~/.cache/sccache
|
~/.cache/sccache
|
||||||
~/.cache/cargo-xwin
|
~/.cache/cargo-xwin
|
||||||
~/.cargo
|
${{ env.CARGO_HOME }}
|
||||||
~/.osxcross
|
~/.osxcross
|
||||||
key: cache-ubuntu-maturin-cross-compile
|
key: cache-ubuntu-maturin-cross-compile
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/target
|
/target
|
||||||
|
/.cargo/
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ome-metadata-derive"
|
name = "ome-metadata-derive"
|
||||||
version = "0.5.0"
|
version = "0.6.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.88.0"
|
rust-version = "1.88.0"
|
||||||
authors = ["Wim Pomp <w.pomp@nki.nl>"]
|
authors = ["Wim Pomp <w.pomp@nki.nl>"]
|
||||||
@@ -13,7 +13,7 @@ readme = "README.md"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
quote = "1"
|
quote = "1"
|
||||||
syn = "2"
|
syn = "3"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ome-metadata"
|
name = "ome-metadata"
|
||||||
version = "0.5.0"
|
version = "0.6.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.88.0"
|
rust-version = "1.88.0"
|
||||||
authors = ["Wim Pomp <w.pomp@nki.nl>"]
|
authors = ["Wim Pomp <w.pomp@nki.nl>"]
|
||||||
@@ -21,9 +21,9 @@ crate-type = ["cdylib", "rlib"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
color-eyre = { version = "0.6", optional = true }
|
color-eyre = { version = "0.6", optional = true }
|
||||||
ome-metadata-derive = { path = "../ome-metadata-derive", version = "0.5.0" }
|
ome-metadata-derive = { path = "../ome-metadata-derive", version = "0.6.0" }
|
||||||
pyo3 = { version = "0.29", features = ["abi3-py310", "anyhow", "eyre", "generate-import-lib"], optional = true}
|
pyo3 = { version = "0.29", features = ["abi3-py310", "anyhow", "eyre", "generate-import-lib"], optional = true}
|
||||||
quick-xml = { version = "0.40", features = ["serialize"] }
|
quick-xml = { version = "0.42", features = ["serialize"] }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
strum = { version = "0.28", features = ["derive"] }
|
strum = { version = "0.28", features = ["derive"] }
|
||||||
thiserror = "2"
|
thiserror = "2"
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
namespace,
|
namespace,
|
||||||
quick_xml::name::ResolveResult::Bound(quick_xml::name::Namespace(
|
quick_xml::name::ResolveResult::Bound(quick_xml::name::Namespace(
|
||||||
b"http://www.openmicroscopy.org/Schemas/OME/2016-06"
|
"http://www.openmicroscopy.org/Schemas/OME/2016-06"
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
let root = match event {
|
let root = match event {
|
||||||
@@ -59,18 +59,22 @@ mod tests {
|
|||||||
}
|
}
|
||||||
event => panic!("expected OME root, got {event:?}"),
|
event => panic!("expected OME root, got {event:?}"),
|
||||||
};
|
};
|
||||||
assert_eq!(root.name().as_ref(), b"OME");
|
assert_eq!(root.name().as_ref(), "OME");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
root.try_get_attribute("xmlns:xsi")
|
root.try_get_attribute("xmlns:xsi")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.value
|
.value
|
||||||
.as_ref(),
|
.as_ref(),
|
||||||
b"http://www.w3.org/2001/XMLSchema-instance"
|
"http://www.w3.org/2001/XMLSchema-instance"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
root.try_get_attribute("xsi:schemaLocation").unwrap().unwrap().value.as_ref(),
|
root.try_get_attribute("xsi:schemaLocation")
|
||||||
b"http://www.openmicroscopy.org/Schemas/OME/2016-06 http://www.openmicroscopy.org/Schemas/OME/2016-06/ome.xsd"
|
.unwrap()
|
||||||
|
.unwrap()
|
||||||
|
.value
|
||||||
|
.as_ref(),
|
||||||
|
"http://www.openmicroscopy.org/Schemas/OME/2016-06 http://www.openmicroscopy.org/Schemas/OME/2016-06/ome.xsd"
|
||||||
);
|
);
|
||||||
assert_eq!(Ome::from_xml(&xml)?, ome);
|
assert_eq!(Ome::from_xml(&xml)?, ome);
|
||||||
|
|
||||||
|
|||||||
+9
-12
@@ -15,33 +15,30 @@ pub(crate) fn to_string<T: Serialize>(value: &T) -> Result<String, Error> {
|
|||||||
// Serde sees an escaped string; the public XML API sees an XML fragment.
|
// Serde sees an escaped string; the public XML API sees an XML fragment.
|
||||||
fn rewrite_values(xml: &str, writing: bool) -> Result<String, Error> {
|
fn rewrite_values(xml: &str, writing: bool) -> Result<String, Error> {
|
||||||
let mut reader = quick_xml::Reader::from_str(xml);
|
let mut reader = quick_xml::Reader::from_str(xml);
|
||||||
let mut stack: Vec<(Vec<u8>, BTreeMap<String, String>)> = Vec::new();
|
let mut stack: Vec<(String, BTreeMap<String, String>)> = Vec::new();
|
||||||
let mut output = String::new();
|
let mut output = String::new();
|
||||||
let mut copied = 0;
|
let mut copied = 0;
|
||||||
loop {
|
loop {
|
||||||
match reader.read_event().map_err(quick_xml::DeError::from)? {
|
match reader.read_event().map_err(quick_xml::DeError::from)? {
|
||||||
Event::Start(ref start) => {
|
Event::Start(ref start) => {
|
||||||
let name = start.local_name();
|
let name = start.local_name();
|
||||||
let is_value = (name.as_ref() == b"Value"
|
let is_value = (name.as_ref() == "Value"
|
||||||
&& stack
|
&& stack
|
||||||
.last()
|
.last()
|
||||||
.is_some_and(|(name, _)| name.as_slice() == b"XMLAnnotation"))
|
.is_some_and(|(name, _)| name == "XMLAnnotation"))
|
||||||
|| (stack.is_empty() && name.as_ref() == b"XmlAnnotationValue");
|
|| (stack.is_empty() && name.as_ref() == "XmlAnnotationValue");
|
||||||
let mut namespaces = stack.last().map(|(_, ns)| ns.clone()).unwrap_or_default();
|
let mut namespaces = stack.last().map(|(_, ns)| ns.clone()).unwrap_or_default();
|
||||||
for attribute in start.attributes() {
|
for attribute in start.attributes() {
|
||||||
let attribute = attribute
|
let attribute = attribute
|
||||||
.map_err(quick_xml::Error::from)
|
.map_err(quick_xml::Error::from)
|
||||||
.map_err(quick_xml::DeError::from)?;
|
.map_err(quick_xml::DeError::from)?;
|
||||||
let key = attribute.key.as_ref();
|
let key = attribute.key.as_ref();
|
||||||
if key == b"xmlns" || key.starts_with(b"xmlns:") {
|
if key == "xmlns" || key.starts_with("xmlns:") {
|
||||||
namespaces.insert(
|
namespaces.insert(
|
||||||
String::from_utf8_lossy(key).into_owned(),
|
key.to_owned(),
|
||||||
quick_xml::escape::escape(
|
quick_xml::escape::escape(
|
||||||
attribute
|
attribute
|
||||||
.decoded_and_normalized_value(
|
.normalized_value(quick_xml::XmlVersion::Implicit1_0)
|
||||||
quick_xml::XmlVersion::Implicit1_0,
|
|
||||||
reader.decoder(),
|
|
||||||
)
|
|
||||||
.map_err(quick_xml::DeError::from)?,
|
.map_err(quick_xml::DeError::from)?,
|
||||||
)
|
)
|
||||||
.into_owned(),
|
.into_owned(),
|
||||||
@@ -74,7 +71,7 @@ fn rewrite_values(xml: &str, writing: bool) -> Result<String, Error> {
|
|||||||
}
|
}
|
||||||
copied = inner_end;
|
copied = inner_end;
|
||||||
} else {
|
} else {
|
||||||
stack.push((name.as_ref().to_vec(), namespaces));
|
stack.push((name.as_ref().to_owned(), namespaces));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::End(_) => {
|
Event::End(_) => {
|
||||||
@@ -160,7 +157,7 @@ fn retain_namespaces(
|
|||||||
let attribute = attribute
|
let attribute = attribute
|
||||||
.map_err(quick_xml::Error::from)
|
.map_err(quick_xml::Error::from)
|
||||||
.map_err(quick_xml::DeError::from)?;
|
.map_err(quick_xml::DeError::from)?;
|
||||||
declared.push(String::from_utf8_lossy(attribute.key.as_ref()).into_owned());
|
declared.push(attribute.key.as_ref().to_owned());
|
||||||
}
|
}
|
||||||
let insertion = before + 1 + start.name().as_ref().len();
|
let insertion = before + 1 + start.name().as_ref().len();
|
||||||
output.push_str(&fragment[copied..insertion]);
|
output.push_str(&fragment[copied..insertion]);
|
||||||
|
|||||||
Reference in new issue
Block a user