Skip to content

MyJetTools/ci-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ci-utils

Use cases

Generate Dockerfile + GitHub Actions in build.rs

use ci_utils::ci_generator::{CiGenerator, DockerFileType};

fn main() {
    CiGenerator::new(env!("CARGO_PKG_NAME"))
        .as_basic_service()          // Dockerfile + release.yml
        .with_ff_mpeg()              // optional ffmpeg layer + workflow step
        .add_docker_copy_file("./Rocket.toml", "./Rocket.toml")
        .generate_github_ci_file()
        .with_ci_test()              // optional: only if project has unit tests
        .build();
}

Always pass env!("CARGO_PKG_NAME") to CiGenerator::new in build.rs so generated names match the crate.

Note: Only add .with_ci_test() if the project has at least one unit test (#[test]). Skip it for projects without tests.

For Dioxus web builds (release-dioxus.yaml + Dioxus Dockerfile):

CiGenerator::new(env!("CARGO_PKG_NAME"))
    .as_dioxus_fullstack_service()              // Dockerfile + release.yaml
    .set_docker_container_name("myjettools/dioxus-docker:0.x.y") // optional override
    .generate_github_ci_file()
    // .with_ci_test()                          // optional: only if project has unit tests
    .build();

Proto utilities

use ci_utils::ProtoFileBuilder;

fn main() {
    ProtoFileBuilder::new("https://example.com/protos")
        // optional: .skip_syncing() to reuse existing proto files in ./proto
        .sync_and_build("my.api.proto");
}
  • Downloads my.api.proto into ./proto (unless skip_syncing), then compiles it via tonic_prost_build with --experimental_allow_proto3_optional.
  • You can also call ci_utils::sync_and_build_proto_file(url, name) or ci_utils::compile_protos(path) directly.

File helpers

Download any text file

ci_utils::download_file("https://example.com/file.txt", "local.txt");

CSS concatenation

use ci_utils::css::CssCompiler;

CssCompiler::new("static/css")
    .add_file("reset.css")
    .add_file("app.css")
    .compile("public/app.css");

Reads each file in order and rewrites the output only when content changes.

JS merge (strip leading // comments)

use ci_utils::js::merge_js_files;

merge_js_files(&["vendor.js", "app.js"], "public/app.js");

Reads from JavaScript/<file> and prefixes each chunk with the file name.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages