-
Notifications
You must be signed in to change notification settings - Fork 39
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
Cache the compressed artifacts #27
Comments
Definitely! This is quite straightforward to do. Also confirms to me that the build crate was the way to go, this would've caused some issues with the previous approach. Until this is implemented you can work around this by manually zipping all outputs:
fn main() {
println!("cargo:rerun-if-changed=build.rs");
let builder = nlprule_build::BinaryBuilder::new(
Some(&["en"]),
std::env::var("OUT_DIR").expect("OUT_DIR is set when build.rs is running"),
)
.build()
.validate();
for output in builder.outputs() {
// `output` is the full path to each binary the builder created, you can gzip here
}
}
// [...]
let mut rules_bytes: &'static [u8] = include_bytes!(concat!(
env!("OUT_DIR"),
"/",
concat!(rules_filename!("en"), ".gz")
));
// [...]
|
I will call this By the way, I saw you where committing some of the nlprule binaries in the cache to the |
That's one option, I would prefer to be able to pass an arbitrary compressor and define the file extension that way. Mostly motivated by making the files contained in the repository as small as possible without needing upstream changes.
I do not have any errors at this point and I think it was only a version mismatch between git and the last release before 0.4.x releases in the first place. |
Oh right that's better! Just having file extension as the second argument and passing that same file extension to
Great, I won't add any retry logic then until someone has issues. |
This seems like the one (blocking) crate that covers a lot of relevant algorithms https://lib.rs/crates/smush |
There is now an implementation of this: #32. I didn't want to commit to using BinaryBuilder::new(Some(&["en"]), tempdir)
.build()
.validate()
.postprocess(
|buffer, mut writer| {
Ok(writer.write_all(&smush::encode(
&buffer,
smush::Codec::Gzip,
smush::Quality::Default,
)?)?)
},
|p| {
let mut path = p.as_os_str().to_os_string();
path.push(".gz");
path
},
)?; What do you think? |
That's even better! |
This works as of v0.4.4 now! |
In order to be able to include the
.bin
artifacts in a repository and craft releases /publish
withcargo
the sources may not be larger than10MB
or failures like:will pop up.
The simplest path is to cache the compressed artifacts rather than the uncompressed and decompress at runtime. An optional builder API could be used to load compressed or decompressed
.bin
variants.The text was updated successfully, but these errors were encountered: