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
26 changes: 26 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Testing

- Use `cargo test` to run all tests in this workspace
- To run the full suite of tests CI will run, see `scripts/ci-local.py`.
- Before commiting run `cargo fmt` and `cargo clippy`, as well as `cd decoder && cargo fmt && cargo clippy`. YOU MUST FIX CLIPPY ERRORS.

## Finishing Up
When instructed to "finish up", follow this process:

1. Run `cargo +nightly fmt --all` to format all code
2. Run `cargo clippy --workspace --all-features -- -D warnings` and fix all errors
3. Fix any small issues found. For big issues, confirm with the user first
4. Amend changes into the most recent commit: `git add -A && git commit --amend --no-edit`
5. Push: `git push --force-with-lease`
6. Monitor CI on GitHub to ensure it passes. If it fails:
- Analyze why the issue was missed
- Update the pre-CI checks to catch similar issues
- Fix the problem and repeat from step 1

Note: For a full local CI check matching what runs on GitHub, use `scripts/ci-local.py`

Helpful commands for monitoring CI:
- Check PR status: `gh pr checks <branch-name>`
- Watch until completion: `gh pr checks <branch-name> --watch` (refreshes every 10s, exits when done)
- View with details: `gh pr view <branch-name> --json statusCheckRollup --jq '.statusCheckRollup[] | "\(.name): \(.status) - \(.conclusion)"'`

2 changes: 1 addition & 1 deletion decoder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ fn poll_event_from_user_event(
Some(PollEventKey {
tid: thread_id as u32,
clock_start: (start_time_ticks as u64).saturating_sub(duration),
duration: duration as u64,
duration,
})
} else {
None
Expand Down
55 changes: 55 additions & 0 deletions scripts/ci-local.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/python3

import os
import subprocess
import yaml
import shlex
import shutil

def runcmd(cmd, cwd='.', extra_env=None, shell=False):
if extra_env:
env = os.environ.copy()
env.update(extra_env)
else:
env = None
print(f'cd {cwd} && {cmd}')
subprocess.check_call(cmd, cwd=cwd, env=env, shell=shell)

def run_integration_tests(y):
print('Running integration tests')
runcmd(shlex.split('cargo +stable build --all-features --verbose --example simple --example pollcatch-without-agent'),
extra_env=y['jobs']['build-for-testing']['env'])
shutil.copy('./target/debug/examples/simple', './tests/simple')
shutil.copy('./target/debug/examples/pollcatch-without-agent', './tests/pollcatch-without-agent')
shutil.copy('./decoder/target/debug/pollcatch-decoder', './tests/pollcatch-decoder')
for action in y['jobs']['test']['steps']:
if action.get('shell') == 'bash':
runcmd(action['run'], shell=True, cwd=action.get('working-directory', '.'))

def main():
y = yaml.safe_load(open('.github/workflows/build.yml'))
build = y['jobs']['build']
for ek,ev in build['env'].items():
os.environ[ek] = str(ev)

# Decoder
runcmd(['cargo', f'+nightly', 'fmt', '--all'], cwd='./decoder')
runcmd(['cargo', f'+nightly', 'clippy', '--workspace', '--all-features', '--', '-D', 'warnings'], cwd='./decoder')
runcmd(['cargo', '+nightly', 'test'], cwd='./decoder')
runcmd(['cargo', '+nightly', 'build'], cwd='./decoder')

# Main
runcmd(['cargo', f'+nightly', 'fmt', '--all'])
runcmd(['cargo', f'+nightly', 'clippy', '--workspace', '--all-features', '--', '-D', 'warnings'])
for toolchain in build['strategy']['matrix']['toolchain']:
for flags in build['strategy']['matrix']['flags']:
runcmd(['cargo', f'+{toolchain}', 'build', '--verbose'] + shlex.split(flags))
runcmd(['cargo', f'+{toolchain}', 'test', '--verbose'] + shlex.split(flags))
runcmd(['cargo', '+nightly', 'doc', '--verbose', '--no-deps'], extra_env={'RUSTDOCFLAGS': '-D warnings --cfg docsrs'})

run_integration_tests(y)

print('All tests successful!')

if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion tests/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ found_good=0
for profile in $dir/*.jfr; do
duration=$(./pollcatch-decoder duration "$profile")
# Ignore "partial" profiles of less than 8s
if [[ $duration > 8 ]]; then
if ! (( $(echo "${duration}<8" | bc) )); then
found_good=1
else
echo "Profile $profile is too short"
Expand Down
2 changes: 1 addition & 1 deletion tests/separate_runtime_integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ found_good=0
for profile in $dir/*.jfr; do
duration=$(./pollcatch-decoder duration "$profile")
# Ignore "partial" profiles of less than 2s
if [[ $duration > 2 ]]; then
if ! (( $(echo "${duration}<2" | bc) )); then
found_good=1
else
echo "Profile $profile is too short"
Expand Down
Loading