Skip to content

Commit

Permalink
ci: add log verification
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenautumns committed Nov 5, 2024
1 parent 4f41c33 commit 9130a1b
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,48 @@ jobs:
- name: Check CGroup
run: systemd-run --user --scope cat /proc/self/cgroup
- name: Run example ${{ matrix.example }}
run: nix develop --command systemd-run-example-${{ matrix.example }} --duration $DURATION
shell: nix develop --command bash -e {0}
run: systemd-run-example-${{ matrix.example }} --duration $DURATION 2>&1 | tee ./output.log
- name: Verify output
run: |
assert_contains() {
local contains="$1"
local msg="$2"
grep "$contains" ./output.log ||
{ printf "$msg"; exit 1; }
}
assert_contains_not() {
local contains="$1"
return ! grep "$contains" ./output.log || false
}
assert_contains_not "ERROR"
assert_contains_not "panic"
if [ "${{ matrix.example }}" = "hello_part" ]; then
assert_contains_not "WARN"
assert_contains "Received via Sampling Port: CustomMessage" \
"no custom message received"
fi
if [ "${{ matrix.example }}" = "fuel_tank" ]; then
assert_contains_not "WARN"
fi
if [ "${{ matrix.example }}" = "ping" ]; then
assert_contains "received valid response" \
"no valid response received"
fi
if [ "${{ matrix.example }}" = "dev_random" ]; then
assert_contains_not "WARN"
assert_contains "got some randomness" \
"missing randomness log info"
fi
if [ "${{ matrix.example }}" = "ping_queue" ]; then
assert_contains "Received valid response" \
"no valid response received"
fi
if [ "${{ matrix.example }}" = "redirect_stdio" ]; then
assert_contains_not "WARN"
assert_contains "Terminating partition" \
"partition didn't terminate as expected"
fi

0 comments on commit 9130a1b

Please sign in to comment.