Skip to content

Commit d608622

Browse files
committed
specify repo on the command line to override configuration
1 parent 8d478ae commit d608622

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

scripts/README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Rhai calls the script's `main() -> i64 {}`.
5858
- rhai_fs::FilesystemPackage - file system access
5959
- [rhai_chrono::ChronoPackage](https://github.com/iganev/rhai-chrono) - standard time formats.
6060

61-
### Modified Rhai behaviod
61+
### Modified Rhai behavior
6262
- The `debug("message")` function is routed to the faux-mgs slog logging.
6363
Prefixing a message with "crit|", "trace|", "error|", "warn|", "error|", or "debug|"
6464
will log at that corresponding level. Leaving off the prefix or using some other
@@ -113,15 +113,26 @@ cargo -q run --bin faux-mgs --features=rhaiscript -- \
113113
--per-attempt-timeout-millis=${PER_ATTEMPT_MS} \
114114
"$@"
115115
```
116+
117+
116118
A `getops` utility function provides command line parsing within
117119
the script.
118120

121+
### An update/rollback test
122+
119123
For the upgrade-rollback script, a JSON configuration file supplies
120124
paths or other parameters needed to configure the script.
121125

122-
then for instance:
126+
For convenience, it is assumed that there are two repos with there
127+
respective Grapefruit SP and RoT images built.
128+
129+
#### Running update-rollback between the master branch and your new code:
130+
123131
```bash
124-
./FM rhai scripts/upgrade-rollback.rhai -- -c scripts/targets.json
132+
BASELINE=$HOME/Oxide/src/hubris/master
133+
UNDER_TEST=$HOME/Oxide/src/hubris/my-new-branch
134+
./FM rhai scripts/upgrade-rollback.rhai -- \
135+
-c scripts/targets.json ${BASELINE} ${UNDER_TEST}
125136
```
126137

127138
See the scripts themselves for further information.

scripts/targets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"repo-home": "${HOME}/Oxide/src",
33
"base_repo": "${repo-home}/hubris/master",
4-
"ut_repo": "${repo-home}/hubris/epoch",
4+
"ut_repo": "${repo-home}/hubris/${UT_WORKTREE}",
55

66
"keyset": "bart",
77
"keyset-dvt-dock": "${repo-home}/dvt-dock/${keyset}",

scripts/upgrade-rollback.rhai

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ fn usage(prog, error) {
55
if error != () {
66
print(`Error: ${error}`);
77
}
8-
print(`Usage: faux-mgs ... rhai ${prog} [-v] [-h] [-c config.json]`);
8+
print(`Usage: faux-mgs ... rhai ${prog} [-v] [-h] [-c config.json] [path0] [path1]`);
99
print(" -c CONFIG.JSON # Path to configuration");
1010
print(" -v # be verbose");
1111
print(" -h # Help. Print this message");
12+
print("path0 - optionally override configuration base_repo value");
13+
print("path1 - optionally override configuration ut_repo value");
1214
print("");
1315
}
1416

@@ -152,7 +154,7 @@ fn main() {
152154

153155
debug(`info|${v.up_down} SP Hubris to ${v.label} image`);
154156
if !update_sp(v.sp_path) {
155-
debug(`error|Failed to ${v.up_down} SP Hubris to ${v.label} image: ${r}`);
157+
debug(`error|Failed to ${v.up_down} SP Hubris to ${v.label} image`);
156158
return 1;
157159
}
158160

@@ -229,6 +231,22 @@ fn process_cli(argv) {
229231
print(`config=${config}`);
230232
}
231233

234+
// Optionally override baseline and under test repo from command line
235+
let repo_path = parsed?.positional[0];
236+
if repo_path != () {
237+
print("override config base_repo:");
238+
print(` was: ${config?.base_repo}`);
239+
config.base_repo = repo_path;
240+
print(` now: ${config?.base_repo}`);
241+
}
242+
let repo_path = parsed?.positional[1];
243+
if repo_path != () {
244+
print("override config ut_repo:");
245+
print(` was: ${config?.ut_repo}`);
246+
config.ut_repo = repo_path;
247+
print(` now: ${config?.ut_repo}`);
248+
}
249+
232250
// Expand the paths to archives so that the config file
233251
// can use vars from the environment and the configuration file itself.
234252
conf["sp_bord"] = util::env_expand(config.bord.sp, config);

0 commit comments

Comments
 (0)