Skip to content

Commit d3d431d

Browse files
committed
feat: add new --no-cache build option
fix: #10
1 parent 3da7b72 commit d3d431d

8 files changed

Lines changed: 96 additions & 14 deletions

File tree

README.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,35 @@ This alias is likely set in your `.bash_profile` or `.zshrc`, make sure to remov
5959
version Show the versions of the srtool container. Use --version if you want the version
6060
of this executable
6161

62+
**version**
63+
64+
srtool-version 0.6.0
65+
chevdor <chevdor@gmail.com>
66+
Show the versions of the srtool container. Use --version if you want the version of this executable
67+
68+
USAGE:
69+
srtool version
70+
71+
FLAGS:
72+
-h, --help Prints help information
73+
-V, --version Prints version information
74+
75+
**info**
76+
77+
srtool-info 0.6.0
78+
chevdor <chevdor@gmail.com>
79+
Provide information about the srtool container and your repo
80+
81+
USAGE:
82+
srtool info [path]
83+
84+
ARGS:
85+
<path> [default: .]
86+
87+
FLAGS:
88+
-h, --help Prints help information
89+
-V, --version Prints version information
90+
6291
**build**
6392

6493
srtool-build 0.6.0
@@ -73,12 +102,15 @@ This alias is likely set in your `.bash_profile` or `.zshrc`, make sure to remov
73102
another location, you can pass it here [default: .]
74103

75104
FLAGS:
76-
-a, --app Enable the "app" mode which is a mix of json output and outputing progress
77-
during the build. This flag is recommended for CI. the json output will be
78-
provided as a single line at the end in compact mode
79-
-h, --help Prints help information
80-
-j, --json Enable json output, same than the global --json option
81-
-V, --version Prints version information
105+
-a, --app Enable the "app" mode which is a mix of json output and outputing progress
106+
during the build. This flag is recommended for CI. the json output will be
107+
provided as a single line at the end in compact mode
108+
-h, --help Prints help information
109+
-j, --json Enable json output, same than the global --json option
110+
--no-cache Passsing this flag allows completely disabling caching. As a result, no cargo-
111+
home will be mounted to the srtool image. There is no known issue with having
112+
the cache ON, this is why it is the default
113+
-V, --version Prints version information
82114

83115
OPTIONS:
84116
--build-opts <build-opts>

README_src.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ NOTE: This alias is likely set in your `.bash_profile` or `.zshrc`, make sure to
3636
include::./doc/usage.adoc[]
3737
----
3838

39+
.version
40+
----
41+
include::./doc/usage_version.adoc[]
42+
----
43+
44+
.info
45+
----
46+
include::./doc/usage_info.adoc[]
47+
----
48+
3949
.build
4050
----
4151
include::./doc/usage_build.adoc[]

cli/src/main.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ fn main() {
4949
let runtime_dir = build_opts.runtime_dir.unwrap_or_else(|| PathBuf::from(&default_runtime_dir));
5050
let tmpdir = env::temp_dir().join("cargo");
5151
let digest = get_image_digest(&image, &tag).unwrap_or_default();
52+
let cache_mount = if !build_opts.no_cache {
53+
format!("-v {tmpdir}:/cargo-home", tmpdir = tmpdir.display())
54+
} else {
55+
String::new()
56+
};
5257

5358
debug!("app: '{}'", &app);
5459
debug!("json: '{}'", &json);
@@ -57,6 +62,7 @@ fn main() {
5762
debug!("runtime_dir: '{}'", &runtime_dir.display());
5863
debug!("tmpdir: '{}'", &tmpdir.display());
5964
debug!("digest: '{}'", &digest);
65+
debug!("no-cache: '{}'", build_opts.no_cache);
6066

6167
let path = fs::canonicalize(&build_opts.path).unwrap();
6268

@@ -69,11 +75,11 @@ fn main() {
6975
-e PROFILE={profile} \
7076
-e IMAGE={digest} \
7177
-v {dir}:/build \
72-
-v {tmpdir}:/cargo-home \
78+
{cache_mount} \
7379
{image}:{tag} build{app}{json}",
7480
package = build_opts.package,
7581
dir = path.display(),
76-
tmpdir = tmpdir.display(),
82+
cache_mount = cache_mount,
7783
image = image,
7884
tag = tag,
7985
runtime_dir = runtime_dir.display(),

cli/src/opts.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ pub struct BuildOpts {
9090
/// You may override the default with this flag.
9191
#[clap(long, env = "PROFILE", default_value = "release")]
9292
pub profile: String,
93+
94+
/// Passsing this flag allows completely disabling caching.
95+
/// As a result, no cargo-home will be mounted to the srtool image.
96+
/// There is no known issue with having the cache ON, this is why it is the default.
97+
#[clap(long)]
98+
pub no_cache: bool,
9399
}
94100

95101
/// Info opts

doc/usage_build.adoc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,15 @@ ARGS:
1010
another location, you can pass it here [default: .]
1111

1212
FLAGS:
13-
-a, --app Enable the "app" mode which is a mix of json output and outputing progress
14-
during the build. This flag is recommended for CI. the json output will be
15-
provided as a single line at the end in compact mode
16-
-h, --help Prints help information
17-
-j, --json Enable json output, same than the global --json option
18-
-V, --version Prints version information
13+
-a, --app Enable the "app" mode which is a mix of json output and outputing progress
14+
during the build. This flag is recommended for CI. the json output will be
15+
provided as a single line at the end in compact mode
16+
-h, --help Prints help information
17+
-j, --json Enable json output, same than the global --json option
18+
--no-cache Passsing this flag allows completely disabling caching. As a result, no cargo-
19+
home will be mounted to the srtool image. There is no known issue with having
20+
the cache ON, this is why it is the default
21+
-V, --version Prints version information
1922

2023
OPTIONS:
2124
--build-opts <build-opts>

doc/usage_info.adoc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
srtool-info 0.6.0
2+
chevdor <chevdor@gmail.com>
3+
Provide information about the srtool container and your repo
4+
5+
USAGE:
6+
srtool info [path]
7+
8+
ARGS:
9+
<path> [default: .]
10+
11+
FLAGS:
12+
-h, --help Prints help information
13+
-V, --version Prints version information

doc/usage_version.adoc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
srtool-version 0.6.0
2+
chevdor <chevdor@gmail.com>
3+
Show the versions of the srtool container. Use --version if you want the version of this executable
4+
5+
USAGE:
6+
srtool version
7+
8+
FLAGS:
9+
-h, --help Prints help information
10+
-V, --version Prints version information

justfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ bump level:
1111
usage:
1212
cargo run -q -- --help > doc/usage.adoc
1313
cargo run -q -- build --help > doc/usage_build.adoc
14+
cargo run -q -- version --help > doc/usage_version.adoc
15+
cargo run -q -- info --help > doc/usage_info.adoc
1416

1517
# When comes the time to release, this will set a new tag
1618
tag:

0 commit comments

Comments
 (0)