Skip to content

Emit Ninja manifest for Netsukefile test assertions#64

Merged
leynos merged 2 commits intomainfrom
codex/add-emit-parameter-to-netsukefile-tests
Aug 6, 2025
Merged

Emit Ninja manifest for Netsukefile test assertions#64
leynos merged 2 commits intomainfrom
codex/add-emit-parameter-to-netsukefile-tests

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Aug 6, 2025

Summary

  • persist Ninja manifests during Netsukefile workflow tests using --emit
  • dump Ninja manifest when an artefact assertion fails
  • extract unused artefact assertion into script

Testing

  • make fmt
  • make lint
  • make test

https://chatgpt.com/codex/tasks/task_e_68929bba61548322b4639fd00b23c911

Summary by Sourcery

Enhance the Netsukefile test workflows to emit and persist Ninja manifests, improve assertion scripts to dump manifests on failure, and introduce a dedicated script for absent artefact checks.

Enhancements:

  • Persist and emit Ninja manifests during Netsukefile test builds for improved debugging

CI:

  • Update GitHub Actions test workflow to emit Ninja manifests for build steps and set NINJA_MANIFEST for assertion steps

Tests:

  • Augment assert-file-exists.sh to dump the Ninja manifest on artefact check failures
  • Add assert-file-absent.sh script for verifying unexpected artefacts and integrate it into the CI workflow

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Aug 6, 2025

Reviewer's Guide

This PR updates the test workflow to emit Ninja manifests for all Netsukefile build steps and propagate the manifest path via NINJA_MANIFEST, enhances the existing assertion script to dump the manifest on failure, and introduces a reusable assert-file-absent.sh for absent artifact checks.

Flow diagram for artifact assertion with Ninja manifest debugging

flowchart TD
    A[Start assertion script] --> B{Does file exist?}
    B -- Yes --> C[Success]
    B -- No --> D{Is NINJA_MANIFEST set and file exists?}
    D -- Yes --> E[Dump Ninja manifest to stderr]
    D -- No --> F[Exit with error]
    E --> F
    F --> G[End]
    C --> G
Loading

Flow diagram for assert-file-absent.sh script

flowchart TD
    A[Start assert-file-absent.sh] --> B{Does file exist?}
    B -- No --> C[Success]
    B -- Yes --> D{Is NINJA_MANIFEST set and file exists?}
    D -- Yes --> E[Dump Ninja manifest to stderr]
    D -- No --> F[Exit with error]
    E --> F
    F --> G[End]
    C --> G
Loading

File-Level Changes

Change Details Files
CI workflow now emits Ninja manifests and sets NINJA_MANIFEST
  • Added --emit <manifest> to netsuke build commands
  • Injected NINJA_MANIFEST env var in assertion steps
  • Replaced inline absence test with assert-file-absent.sh invocation
.github/workflows/netsukefile-test.yml
Enhanced assert-file-exists.sh to dump manifest on failure
  • Added conditional check for NINJA_MANIFEST and its file existence
  • Output manifest boundaries and content to stderr when assertion fails
scripts/assert-file-exists.sh
Introduced assert-file-absent.sh for absent artifact assertions
  • Created new script with inverted logic of exists script
  • Included manifest dumping logic on unexpected file presence
scripts/assert-file-absent.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 6, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Warning

Rate limit exceeded

@leynos has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 31 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 5c89db7 and 44d6576.

📒 Files selected for processing (3)
  • .github/workflows/netsukefile-test.yml (1 hunks)
  • scripts/assert-file-absent.sh (1 hunks)
  • scripts/assert-file-exists.sh (2 hunks)

Summary by CodeRabbit

  • New Features

    • Introduced a new script to verify that certain files are not present after the build process, aiding in detecting unexpected artefacts.
  • Bug Fixes

    • Improved error reporting in file existence checks by displaying relevant manifest details when expected files are missing, making debugging easier in build workflows.

Walkthrough

Update the GitHub workflow to emit Ninja manifest files during netsuke build and action steps, setting the NINJA_MANIFEST environment variable accordingly. Introduce a new script to assert file absence, and enhance the existing file existence assertion script to display Ninja manifest contents for debugging when artefacts are missing.

Changes

Cohort / File(s) Change Summary
Workflow: Ninja Manifest Emission & Assertion Integration
.github/workflows/netsukefile-test.yml
Modify build and action steps to emit Ninja manifest files using --emit. Set NINJA_MANIFEST for assertion scripts. Update assertion steps to use new script for absent files and pass manifest context.
New Script: Assert File Absence
scripts/assert-file-absent.sh
Add script to check that a specified file does not exist. Print error and manifest contents if unexpected artefact is found. Strict argument and error handling.
Script Enhancement: Assert File Exists
scripts/assert-file-exists.sh
Enhance error handling: if expected file is missing, print error and, if available, output Ninja manifest contents for debugging. No change to argument validation.

Sequence Diagram(s)

sequenceDiagram
    participant Workflow
    participant Netsuke
    participant AssertExists
    participant AssertAbsent

    Workflow->>Netsuke: Build/Action with --emit build.ninja/action.ninja
    Netsuke-->>Workflow: Emit Ninja manifest file
    Workflow->>AssertExists: Check for expected artefact (NINJA_MANIFEST set)
    AssertExists-->>Workflow: Success or error (with manifest output on error)
    Workflow->>AssertAbsent: Check for absent artefact (NINJA_MANIFEST set)
    AssertAbsent-->>Workflow: Success or error (with manifest output on error)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

Emit the Ninja manifest, let debugging be your guide,
With scripts to check what’s present—and what’s not inside.
If artefacts are missing, the manifest will tell,
Where things went awry, and what didn’t go well.
So build with confidence, and test with cheer,
For your workflow’s now sharper, and your artefacts clear!
🥷📄✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/add-emit-parameter-to-netsukefile-tests

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @leynos - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Add both behavioural and unit tests for the new assert-file-absent.sh script. (link)
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments

### Comment 1
<location> `scripts/assert-file-absent.sh:9` </location>
<code_context>
+
+if [[ $# -ne 1 ]]; then
+  echo "Usage: $(basename "$0") <file>" >&2
+  exit 64   # EX_USAGE
+fi
+
</code_context>

<issue_to_address>
Using exit code 64 is non-standard for shell scripts.

If portability is important, use a more widely recognized exit code such as 2 for usage errors.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
  exit 64   # EX_USAGE
=======
  exit 2   # usage error
>>>>>>> REPLACE

</suggested_fix>

### Comment 2
<location> `scripts/assert-file-absent.sh:1` </location>
<code_context>
 #!/usr/bin/env bash
 # Ensures the Netsuke build produced the expected artefact.
-# Fails fast if the given file is missing.
</code_context>

<issue_to_address>
Add both behavioural and unit tests for the new assert-file-absent.sh script.

This new script introduces functionality to check for the absence of a file, but there are no accompanying behavioural or unit tests to verify its correct operation. Add tests to demonstrate and validate its behaviour.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread scripts/assert-file-absent.sh Outdated
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (review_instructions): Add both behavioural and unit tests for the new assert-file-absent.sh script.

This new script introduces functionality to check for the absence of a file, but there are no accompanying behavioural or unit tests to verify its correct operation. Add tests to demonstrate and validate its behaviour.

Review instructions:

Path patterns: **/*

Instructions:
For any new feature or change to an existing feature, both behavioural and unit tests are required.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9aae022 and 5c89db7.

📒 Files selected for processing (3)
  • .github/workflows/netsukefile-test.yml (1 hunks)
  • scripts/assert-file-absent.sh (1 hunks)
  • scripts/assert-file-exists.sh (2 hunks)

Comment on lines +56 to +78
env:
NINJA_MANIFEST: build.ninja
run: |
scripts/assert-file-exists.sh base.txt
scripts/assert-file-exists.sh dependent.txt
- name: Assert inline command artefact exists
env:
NINJA_MANIFEST: build.ninja
run: scripts/assert-file-exists.sh inline-command.txt
- name: Assert inline script artefact exists
env:
NINJA_MANIFEST: build.ninja
run: scripts/assert-file-exists.sh inline-script.txt
- name: Run action target
run: ./target/debug/netsuke --verbose build say-hello
run: ./target/debug/netsuke --verbose build --emit action.ninja say-hello
- name: Assert action artefact exists
env:
NINJA_MANIFEST: action.ninja
run: scripts/assert-file-exists.sh action-called.txt
- name: Assert unused action artefact absent
run: test ! -f unused.txt
env:
NINJA_MANIFEST: action.ninja
run: scripts/assert-file-absent.sh unused.txt
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Remove repetitive env: NINJA_MANIFEST blocks with YAML anchors or composite action
Four consecutive steps repeat identical env declarations. Use a YAML anchor/alias or wrap the assertions in a single composite step to shrink the workflow file and keep the manifest filename in one place.

Example with anchor:

env: &with-build-manifest
  NINJA_MANIFEST: build.ninja

- name: Assert dependent artefacts exist
  env: *with-build-manifest
  run: |
    scripts/assert-file-exists.sh base.txt
    scripts/assert-file-exists.sh dependent.txt
🤖 Prompt for AI Agents
In .github/workflows/netsukefile-test.yml between lines 56 and 78, multiple
steps redundantly declare the same env variable NINJA_MANIFEST with the value
build.ninja. Refactor by defining a YAML anchor for the env block with
NINJA_MANIFEST: build.ninja and then reference this anchor in each step that
requires it. This reduces repetition and centralizes the manifest filename
declaration.

Comment on lines +16 to +21
if [[ -n "${NINJA_MANIFEST:-}" && -f "$NINJA_MANIFEST" ]]; then
echo "Ninja manifest '$NINJA_MANIFEST' for debugging:" >&2
echo "-----BEGIN NINJA MANIFEST-----" >&2
cat "$NINJA_MANIFEST" >&2
echo "-----END NINJA MANIFEST-----" >&2
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Reuse the manifest-dump helper instead of duplicating logic
This block duplicates the one in assert-file-exists.sh. Source a common helper or declare a shared function to avoid future divergence and reduce surface area for bugs.

🤖 Prompt for AI Agents
In scripts/assert-file-absent.sh around lines 16 to 21, the code block that
prints the Ninja manifest duplicates logic found in assert-file-exists.sh.
Refactor by extracting this manifest-dump logic into a shared helper script or
function, then source or call that helper here to avoid duplication and ensure
consistency.

Comment on lines +16 to +21
if [[ -n "${NINJA_MANIFEST:-}" && -f "$NINJA_MANIFEST" ]]; then
echo "Ninja manifest '$NINJA_MANIFEST' for debugging:" >&2
echo "-----BEGIN NINJA MANIFEST-----" >&2
cat "$NINJA_MANIFEST" >&2
echo "-----END NINJA MANIFEST-----" >&2
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Extract duplicated Ninja-manifest dump into a helper to remove repetition
The manifest-dump block appears verbatim in assert-file-exists.sh and assert-file-absent.sh. Factor it into a small function or shared script to DRY the codebase and simplify maintenance.

-  if [[ -n "${NINJA_MANIFEST:-}" && -f "$NINJA_MANIFEST" ]]; then
-    echo "Ninja manifest '$NINJA_MANIFEST' for debugging:" >&2
-    echo "-----BEGIN NINJA MANIFEST-----" >&2
-    cat "$NINJA_MANIFEST" >&2
-    echo "-----END NINJA MANIFEST-----" >&2
-  fi
+  dump_ninja_manifest() {
+    echo "Ninja manifest '$NINJA_MANIFEST' for debugging:" >&2
+    echo "-----BEGIN NINJA MANIFEST-----" >&2
+    cat "$NINJA_MANIFEST" >&2
+    echo "-----END NINJA MANIFEST-----" >&2
+  }
+  [[ -n "${NINJA_MANIFEST:-}" && -f "$NINJA_MANIFEST" ]] && dump_ninja_manifest
🤖 Prompt for AI Agents
In scripts/assert-file-exists.sh around lines 16 to 21, the code block that
dumps the Ninja manifest is duplicated in assert-file-absent.sh. Extract this
block into a helper function within a shared script or source it from a common
file. Replace the duplicated code in both scripts with calls to this helper
function to adhere to DRY principles and simplify maintenance.

leynos and others added 2 commits August 6, 2025 08:00
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
@leynos leynos force-pushed the codex/add-emit-parameter-to-netsukefile-tests branch from 457abcc to 44d6576 Compare August 6, 2025 07:00
@leynos leynos merged commit c3ec2aa into main Aug 6, 2025
3 of 4 checks passed
@leynos leynos deleted the codex/add-emit-parameter-to-netsukefile-tests branch August 6, 2025 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant