Skip to content

Commit 8adc556

Browse files
committed
chore: add some docs on script checks
Signed-off-by: James Petersen <jpetersenames@gmail.com>
1 parent 6192350 commit 8adc556

3 files changed

Lines changed: 58 additions & 1 deletion

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,7 @@ Exit code is **non-zero** if any check/group fails or errors.
6060

6161
* Use `EDERA_PREFLIGHT_SKIP_GROUPS` to bypass slow or irrelevant checks.
6262
* Script-based checks must be **executable** and located in `EDERA_PREFLIGHT_SCRIPTS_DIR`.
63+
64+
## Script Based Checks
65+
66+
Check the scripts [README.md](./scripts/README.md)

scripts/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Scripted Checks
2+
3+
This directory contains **script-based preflight checks**.
4+
Each script is executed as part of the `Scripted Checks` group when `EDERA_PREFLIGHT_SCRIPTS_DIR` points here.
5+
6+
---
7+
8+
## Writing a Scripted Check
9+
10+
A scripted check is just an **executable shell script** that follows two simple rules:
11+
12+
1. **Set the check name** by printing a line starting with
13+
14+
```
15+
EDERA_PREFLIGHT_CHECK_NAME=<name>
16+
```
17+
18+
This will be used in logs and results.
19+
20+
2. **Exit with the correct status code**:
21+
- `0` → check passed
22+
- non-zero → check failed (the return code is reported)
23+
24+
---
25+
26+
## Example
27+
28+
```sh
29+
#!/bin/sh
30+
31+
# Name shown in preflight output
32+
echo "EDERA_PREFLIGHT_CHECK_NAME=Should Pass"
33+
34+
# Any other output is shown as context
35+
echo "it does pass"
36+
37+
# Exit code decides the result
38+
exit 0
39+
```
40+
41+
---
42+
43+
## Notes
44+
45+
* Scripts must be **executable** (`chmod +x script.sh`).
46+
* You can write in any language (bash, python, etc.) as long as it follows the rules above.
47+
* Errors such as missing files or runtime exceptions will show up as **Errored** checks in the output.

src/system/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct SystemChecks;
1414

1515
impl SystemChecks {
1616
pub fn run_all(&self) -> CheckGroupResult {
17-
let results = vec![self.enough_memory()];
17+
let results = vec![self.enough_memory(), self.enough_disk()];
1818

1919
let mut group_result = Passed;
2020
for res in results.iter() {
@@ -50,6 +50,12 @@ impl SystemChecks {
5050
}
5151
CheckResult::new(&name, result)
5252
}
53+
54+
fn enough_disk(&self) -> CheckResult {
55+
let name = String::from("Enough Disk");
56+
let mut result = Passed;
57+
CheckResult::new(&name, result)
58+
}
5359
}
5460

5561
impl CheckGroup for SystemChecks {

0 commit comments

Comments
 (0)