Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,7 @@ jobs:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.14"
- name: Install promtool 3.7.3
run: |
curl -fsSLO https://github.com/prometheus/prometheus/releases/download/v3.7.3/prometheus-3.7.3.linux-amd64.tar.gz
echo 'fc9e5da126817438cf2820d9a7206c75e3122802ba8d20add3a6219a59ca6913 prometheus-3.7.3.linux-amd64.tar.gz' | sha256sum -c -
tar -xzf prometheus-3.7.3.linux-amd64.tar.gz
sudo install -m 0755 prometheus-3.7.3.linux-amd64/promtool /usr/local/bin/promtool
- run: shellcheck -S warning eb-keep-logs tests/test_eb_keep_logs.sh tests/test_metrics.sh tests/corpus/run.sh tests/corpus/make-fixtures.sh
- run: bash tests/test_eb_keep_logs.sh
- run: bash tests/test_metrics.sh
- run: shellcheck -S warning tests/test_eb_keep_logs.sh tests/test_metrics.sh tests/test_output_stability.sh tests/test_tutorial_which.sh tests/corpus/run.sh tests/corpus/make-fixtures.sh
- name: no site names in the tree
run: |
! git grep -nIiE 'snellius|snel-|surf\.nl|/gpfs/|/projects/0|rg\.terra|scratch-shared|scratch-node' -- . ':!.github/workflows/ci.yml'
Expand Down Expand Up @@ -60,7 +49,7 @@ jobs:
tar -xzf "${archive}"
sudo install -m 0755 "prometheus-3.7.3.linux-${arch}/promtool" /usr/local/bin/promtool
- run: zig fmt --check build.zig build.zig.zon src
- run: shellcheck -S warning tests/differential.sh tests/test_metrics.sh tests/test_why.sh tests/test_json_schemas.sh tests/test_crash_safety.sh tests/test_rotate_fsync_durability.sh tests/lib/check.sh tests/test_report_utf8_safety.sh tests/test_lifecycle_modulerc_safety.sh
- run: shellcheck -S warning tests/test_cases.sh tests/test_metrics.sh tests/test_why.sh tests/test_json_schemas.sh tests/test_crash_safety.sh tests/test_rotate_fsync_durability.sh tests/lib/check.sh tests/test_report_utf8_safety.sh tests/test_lifecycle_modulerc_safety.sh
- run: pip install jsonschema
- uses: ./.github/actions/install-strace
- run: zig build test --summary all
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ zig-pkg/
/docs/**/__pycache__/
/.pixi/
/.lycheecache

# Recorded stderr of the stability test; a global *.err ignore must not drop it.
!tests/golden/**/*.err
11 changes: 7 additions & 4 deletions COMPAT.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Compatibility of the Zig build with the shell script

The Zig build (0.2.0 and later) keeps the shell script's (0.1.0) interface. The shell
script stays in the repository as the reference: `tests/test_eb_keep_logs.sh`
runs against either through `TOOL_BIN`, and `tests/differential.sh` runs both
on the same invocations.
The Zig build (0.2.0 and later) keeps the interface of the shell script it
was ported from (0.1.0), which is no longer in the repository. This page is
for a site that ran the script: what the binary keeps, and where it differs.
`tests/test_cases.sh` compares the binary with the script's own output on
fixed invocations, recorded under `tests/golden/cases`, and
`tests/test_output_stability.sh` does the same for `failed` and `rotate`
byte for byte.

## Kept

Expand Down
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ sha256sum --check --ignore-missing SHA256SUMS
install -m 0755 "eb-keep-logs-$v-$arch-linux-musl" ~/.local/bin/eb-keep-logs
```

The shell script `eb-keep-logs` in this repository is the reference for `failed` and `rotate`, with the same options and output; copy it onto `PATH`.
It refuses `why`, `history`, `failures`, `loads`, `runs`, `used`, `usage`, `pending`, `test-bundle`, `test-compare` and `lifecycle` with `is in the Zig build only` and exit 2: only the binary has them.
It needs `bash`, coreutils, GNU `grep` (for `grep -P`), `sed`, `find`, `gzip`, `awk`, `flock` from util-linux for `rotate` and, for `failed`, `eb`.
The binary is the one implementation. The shell script it was ported from, 0.1.0, is no longer in the repository; [COMPAT.md](https://github.com/stackhands/eb-keep-logs/blob/main/COMPAT.md) lists what the binary keeps of its interface and where it differs.
Without `grep -P` it still keeps the log and the command output, but not the meson testlog.

There is no EasyBuild recipe for eb-keep-logs here or in the EasyBuild easyconfigs repository.
Expand All @@ -50,11 +48,9 @@ zig build -Drelease=true
zig-out/bin/eb-keep-logs --version
```

`zig build test` runs its unit tests, the shell test suite against the
binary, and `tests/differential.sh`, which runs the shell script and the
binary on the same invocations.
[COMPAT.md](https://github.com/stackhands/eb-keep-logs/blob/main/COMPAT.md) lists what the two share and where they differ on
purpose.
`zig build test` runs its unit tests, the shell test suites against the
binary, and `tests/test_cases.sh`, which compares the binary's output on
fixed invocations with the expected output under `tests/golden/cases`.

## Keep a failed build's logs

Expand Down
4 changes: 1 addition & 3 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ leaves to a person.
2. Edit, in a commit of its own, the prose the hook leaves alone: the README
sentence on what `main` has that the latest release lacks, the
"Release X.Y.Z runs ..." rows of `docs/orgmode/howto/install.org`, the
`--version` example of `docs/orgmode/reference/cli.org`, and a row in
`COMPAT.md` with its label in `tests/differential.sh` for each new
deliberate difference from the shell script.
`--version` example of `docs/orgmode/reference/cli.org`.
3. `cog bump --minor` (or `--patch`, `--major`, `--version X.Y.Z`). It runs
the hook, commits `chore(version): X.Y.Z` and creates the tag on that
commit. `cog bump --minor --dry-run` prints the version only.
Expand Down
13 changes: 7 additions & 6 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ pub fn build(b: *std.Build) void {
crash_safety.has_side_effects = true;
b.step("crash-safety", "Run the signal and crash safety suite").dependOn(&crash_safety.step);

// The shell suite of the old implementation, run against this binary.
// It and the differential run below run in the build root: their script
// The shell suite, run against this binary.
// It and the case run below run in the build root: their script
// paths are relative, and zig build may be started in a subdirectory.
// Both run every time, as the cache sees neither their scripts nor the
// date and tzdata of the host, which the suite compares with.
Expand All @@ -73,14 +73,15 @@ pub fn build(b: *std.Build) void {
suite.setCwd(b.path("."));
suite.expectExitCode(0);
suite.has_side_effects = true;
// The same invocations through the shell implementation and this one.
const diff = b.addSystemCommand(&.{ "bash", "-c", "TOOL_BIN=\"$0\" TEST_OPS_BIN=\"$1\" exec bash tests/differential.sh" });
// Fixed invocations, against the expected output under tests/golden/cases.
// The killed-mid-compress case runs the test-ops binary.
const diff = b.addSystemCommand(&.{ "bash", "-c", "TOOL_BIN=\"$0\" TEST_OPS_BIN=\"$1\" exec bash tests/test_cases.sh" });
diff.addArtifactArg(exe);
diff.addArtifactArg(test_ops_exe);
diff.setCwd(b.path("."));
diff.expectExitCode(0);
diff.has_side_effects = true;
// why, which the shell implementation does not have, on the kept logs
// why on the kept logs
// of real EasyBuild failures.
const why = b.addSystemCommand(&.{ "bash", "-c", "TOOL_BIN=\"$0\" exec bash tests/test_why.sh" });
why.addArtifactArg(exe);
Expand Down Expand Up @@ -164,7 +165,7 @@ pub fn build(b: *std.Build) void {
modulerc_safety_test.expectExitCode(0);
modulerc_safety_test.has_side_effects = true;

const test_step = b.step("test", "Run the unit tests, the command-line suites and the differential run");
const test_step = b.step("test", "Run the unit tests, the command-line suites and the expected-output cases");
test_step.dependOn(&b.addRunArtifact(unit).step);
test_step.dependOn(&suite.step);
test_step.dependOn(&diff.step);
Expand Down
1 change: 1 addition & 0 deletions changelog.d/+retire-shell-script.removal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The shell script `eb-keep-logs` 0.1.0 is no longer in the repository; the binary is the one implementation. `tests/test_cases.sh` holds the binary to the script's recorded output on the invocations `tests/differential.sh` compared, and COMPAT.md stays as the record of what changed for a site that ran the script.
5 changes: 2 additions & 3 deletions docs/orgmode/contributing.org
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ With Zig 0.17.1, from the top of the repository:
zig build test
#+end_src

This runs the unit tests, the command-line suite =tests/test_eb_keep_logs.sh= against the binary, and =tests/differential.sh=, which runs the shell script and the binary on the same invocations.
=bash tests/test_eb_keep_logs.sh= runs the suite against the shell script.
A deliberate difference between the two has its row in =COMPAT.md=, which [[file:reference/compatibility.org][Compatibility]] shows, and its label in =tests/differential.sh=.
This runs the unit tests, the command-line suites such as =tests/test_eb_keep_logs.sh= against the binary, and =tests/test_cases.sh=, which compares the binary's output on fixed invocations with the files under =tests/golden/cases=.
A change that alters one of those outputs on purpose rewrites them with =RECORD=1 TOOL_BIN=zig-out/bin/eb-keep-logs bash tests/test_cases.sh=; the diff of =tests/golden= shows what changed.

** The log corpus

Expand Down
4 changes: 2 additions & 2 deletions docs/orgmode/howto/check-prefix-use.org
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Before uninstalling or retiring an install tree, see whether XALT or Lmod record

** Before starting

- The Zig build of =eb-keep-logs=. The shell script answers =used= with =used is in the Zig build only=.
- =eb-keep-logs= 0.2.0 or later. The shell script 0.1.0 answers =used= with =used is in the Zig build only=.
- Files of XALT JSON objects and/or Lmod ModuleUsageTracking lines, as the site already keeps.
Run records carry =userT= and optionally =libA=. Link records carry =resultT= and =linkA=.
Package records carry =package_path=. Lmod lines carry =path= under the module tree.
Expand Down Expand Up @@ -45,7 +45,7 @@ Before uninstalling or retiring an install tree, see whether XALT or Lmod record

| Message | Cause | What to do |
|---|---|---|
| =eb-keep-logs: used is in the Zig build only= | The =eb-keep-logs= on =PATH= is the shell script. | Put the Zig build first on =PATH=. |
| =eb-keep-logs: used is in the Zig build only= | The =eb-keep-logs= on =PATH= is the shell script 0.1.0. | Put the Zig build first on =PATH=. |
| =eb-keep-logs: used needs --prefix= | =--prefix= was omitted or empty. | Pass the install tree to check. |
| =eb-keep-logs: used needs a record file= | No file was given. | Pass at least one record file. |
| =eb-keep-logs: used: PATH is not XALT run JSON= | A file held truncated or invalid JSON. | Fix the file; partial hits from a bad object are not printed. |
Expand Down
4 changes: 2 additions & 2 deletions docs/orgmode/howto/find-why-a-build-failed.org
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Use this after a run in which builds failed, to see for each the EasyBuild step

** Before you start

- =eb-keep-logs= on your =PATH= as the release binary or a Zig build; the shell script in the repository has no =why= or =history=.
- =eb-keep-logs= 0.2.0 or later on your =PATH=; the shell script 0.1.0 has no =why= or =history=.
- A log tree, here =~/build-logs=, whose runs are named by their date and time, =YYYYMMDD_HHMMSS=, as [[file:call-from-a-pipeline.org][Call eb-keep-logs from a build pipeline]] makes them.
A run keeps each build's =NAME.stdout.log= and, for a failed build, =NAME.failed.ebout.log=, in its own directory or in a directory per target, as eb-pipeline keeps them.

Expand Down Expand Up @@ -126,7 +126,7 @@ Use this after a run in which builds failed, to see for each the EasyBuild step

| Message | Cause | What to do |
|----------------------------------------------+-----------------------------------------------------------------------------------------------------------+------------------------------------------------------------------|
| =eb-keep-logs: why is in the Zig build only= | The =eb-keep-logs= on your =PATH= is the shell script. | Put the Zig build first on =PATH=. |
| =eb-keep-logs: why is in the Zig build only= | The =eb-keep-logs= on your =PATH= is the shell script 0.1.0. | Put the Zig build first on =PATH=. |
| =eb-keep-logs: ROOT PATH is not a directory= | =--root= names no directory. | Give =--root= the log tree. |
| =eb-keep-logs: no run under ROOT; it holds no directory named YYYYMMDD_HHMMSS. Give --root the directory of the runs, or name one run= | =ROOT= holds no directory named =YYYYMMDD_HHMMSS=. =ROOT= is the current directory when =--root= is left out. | Give =--root= the directory that holds the runs, or name one run. |
| =RUN: 0 failed builds of 0= | The run holds no =NAME.stdout.log= or =NAME.failed.ebout.log=, in its own directory or one below it. | Check that the pipeline writes its logs where =why= reads them. |
Expand Down
4 changes: 2 additions & 2 deletions docs/orgmode/howto/what-a-dry-run-would-build.org
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A module marked =[x]= is already installed and is not listed.

** Before you start

- The Zig build of =eb-keep-logs=. The shell script answers =pending= with =pending is in the Zig build only=.
- =eb-keep-logs= 0.2.0 or later. The shell script 0.1.0 answers =pending= with =pending is in the Zig build only=.
- A file that holds the report. =eb -Dr= prints a dry run, and =eb -M= prints the missing modules.
The shapes are the ones in [[https://docs.easybuild.io/using-easybuild/][Getting an overview of planned installations]].

Expand All @@ -33,7 +33,7 @@ A module marked =[x]= is already installed and is not listed.

| Message | Cause | What to do |
|---|---|---|
| =eb-keep-logs: pending is in the Zig build only= | The =eb-keep-logs= on =PATH= is the shell script. | Put the Zig build first on =PATH=. |
| =eb-keep-logs: pending is in the Zig build only= | The =eb-keep-logs= on =PATH= is the shell script 0.1.0. | Put the Zig build first on =PATH=. |
| =eb-keep-logs: pending needs a report= | No file was given. | Pass the path of the saved report. |
| =eb-keep-logs: pending: PATH is not a dry-run or missing-modules report= | The file has neither shape. | Point it at the output of =eb --dry-run= or =eb --missing-modules=. |
| =eb-keep-logs: pending does not know 'OPTION'= | An option was given. | The command takes the report path and nothing else. |
Expand Down
4 changes: 2 additions & 2 deletions docs/orgmode/howto/who-loaded-a-module.org
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Lmod can syslog each load as =user=USER module=NAME path=PATH host=HOST time=TIM

** Before you start

- The Zig build of =eb-keep-logs=. The shell script answers =loads= with =loads is in the Zig build only=.
- =eb-keep-logs= 0.2.0 or later. The shell script 0.1.0 answers =loads= with =loads is in the Zig build only=.
Put the Zig build first on =PATH=, as [[file:find-why-a-build-failed.org][Find why a build failed]] does for =why=.
- A file of tracking lines. A syslog prefix in front of the record is fine. =journalctl= output redirected to a file is one.

Expand Down Expand Up @@ -42,7 +42,7 @@ Lmod can syslog each load as =user=USER module=NAME path=PATH host=HOST time=TIM

| Message | Cause | What to do |
|---|---|---|
| =eb-keep-logs: loads is in the Zig build only= | The =eb-keep-logs= on =PATH= is the shell script. | Put the Zig build first on =PATH=. |
| =eb-keep-logs: loads is in the Zig build only= | The =eb-keep-logs= on =PATH= is the shell script 0.1.0. | Put the Zig build first on =PATH=. |
| =eb-keep-logs: loads needs --module= | =--module= was omitted, or its value was empty. | Pass the full module name, as =GROMACS/2024.1=. |
| =eb-keep-logs: loads needs a log file= | No file was given. | Pass the path of the tracking log. |
| =eb-keep-logs: cannot read FILE: ERROR= | The file cannot be opened or is larger than 64 MiB. | Point at the log you can read, or split a larger one. |
Expand Down
4 changes: 2 additions & 2 deletions docs/orgmode/howto/who-ran-an-executable.org
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ A link record, the one that lists libraries, is not a run and is skipped.

** Before you start

- The Zig build of =eb-keep-logs=. The shell script answers =runs= with =runs is in the Zig build only=.
- =eb-keep-logs= 0.2.0 or later. The shell script 0.1.0 answers =runs= with =runs is in the Zig build only=.
- A file of XALT run records. Each record is a JSON object, and several may follow one another.
=userT= holds =user=, =exec_path= and, when XALT wrote them, =syshost= and =start_time=.
The shape is the one in [[https://xalt.readthedocs.io/en/latest/120_xalt_json.html][XALT's JSON record]].
Expand All @@ -32,7 +32,7 @@ A link record, the one that lists libraries, is not a run and is skipped.

| Message | Cause | What to do |
|---|---|---|
| =eb-keep-logs: runs is in the Zig build only= | The =eb-keep-logs= on =PATH= is the shell script. | Put the Zig build first on =PATH=. |
| =eb-keep-logs: runs is in the Zig build only= | The =eb-keep-logs= on =PATH= is the shell script 0.1.0. | Put the Zig build first on =PATH=. |
| =eb-keep-logs: runs needs --exec= | =--exec= was omitted, or its value was empty. | Pass the executable path, or its last component, as =gmx=. |
| =eb-keep-logs: runs needs a record file= | No file was given. | Pass the path of the XALT records. |
| =eb-keep-logs: runs: PATH is not XALT run JSON= | The file is not one or more JSON objects. | Point it at the run records, not a log of another shape. |
Expand Down
2 changes: 1 addition & 1 deletion docs/orgmode/index.org
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Keep the logs of EasyBuild builds that a build pipeline would otherwise lose, an
After a failed build, =eb-keep-logs failed= copies the EasyBuild log and the failing command's own output next to the build's output, where the end of the job does not take them, and closes the copies to other users, because a failed compile line of licensed software can print the licence number.
=eb-keep-logs rotate= compresses the logs of old runs and removes the oldest runs.
=eb-keep-logs why= says from the kept logs why a run's builds failed, and =eb-keep-logs history= how a package's builds went run by run.
Each release is one static binary per architecture that needs nothing but =eb=; the shell script it was ported from stays in the repository as the same tool, without =why= and =history=.
Each release is one static binary per architecture that needs nothing but =eb=.

New here?
[[file:tutorials/keep-a-failed-build-log.org][Keep a failed build's logs]] runs an EasyBuild build that fails and ends with its log and the compiler's error kept in a directory of your own.
Expand Down
2 changes: 1 addition & 1 deletion docs/orgmode/reference/json-schemas.org
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

The Zig build's =--json= on =why=, =history=, =failures=, =loads=, =runs=, =used=, =usage=, =pending=, =test-compare= and =lifecycle= prints one line of JSON with =schema_version= 1.
The =test-bundle= command always writes one JSON document with =schema_version= 1.
The shell script refuses those commands; see [[file:compatibility.org][Compatibility]].
The shell script 0.1.0 refused those commands; see [[file:compatibility.org][Compatibility]].
Each document is validated in CI against a JSON Schema file in the repository tree under =docs/orgmode/reference/json/=.
The schemas use draft 2020-12; a new =schema_version= may drop or rename a key, or change what one means.

Expand Down
1 change: 0 additions & 1 deletion docs/orgmode/tutorials/keep-a-failed-build-log.org
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ eb-keep-logs 0.3.1 (x86_64-linux-musl, zig 0.17.1, abc1234)
#+end_example

[[file:../howto/install.org][Install eb-keep-logs]] has the release binary when you do not need the main-branch fix.
The shell script in the repository runs =failed= and =rotate= only; =why= and =history= are in the Zig build only, and the script says so when it is asked for them.

** Make a directory for this run's logs

Expand Down
Loading
Loading