Skip to content

Conversation

aaguiarz
Copy link
Member

@aaguiarz aaguiarz commented Jun 10, 2025

Summary

  • allow providing glob patterns to model test
  • document new test globbing capability
  • document this change in CHANGELOG

Testing

  • go test ./... -run=^$
  • make test (fails: Interrupt)

Fixes #423


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

Sample Output

/gh/sample-stores/stores % ~/gh/cli/dist/fga model test --tests "**/*.fga.yaml"
# file: abac-with-rebac/store.fga.yaml
Tests 2/2 passing
Checks 12/12 passing
# file: advanced-entitlements/store.fga.yaml
Tests 2/2 passing
Checks 16/16 passing
ListObjects 3/3 passing
# file: banking/store.fga.yaml
Tests 2/2 passing
Checks 5/5 passing
# file: condition-data-types/store.fga.yaml
Tests 2/2 passing
Checks 18/18 passing
# file: custom-roles/store.fga.yaml
Tests 3/3 passing
Checks 9/9 passing
ListObjects 1/1 passing
ListUsers 1/1 passing
# file: developer-portal/store.fga.yaml
Tests 3/3 passing
Checks 10/10 passing
ListObjects 1/1 passing
ListUsers 1/1 passing
# file: entitlements/store.fga.yaml
Tests 3/3 passing
Checks 9/9 passing
ListObjects 1/1 passing
ListUsers 1/1 passing
# file: expenses/store.fga.yaml
Tests 3/3 passing
Checks 3/3 passing
ListObjects 1/1 passing
ListUsers 1/1 passing
# file: gdrive/store.fga.yaml
Tests 4/4 passing
Checks 3/3 passing
ListObjects 1/1 passing
ListUsers 5/5 passing
# file: github/store.fga.yaml
Tests 4/4 passing
Checks 6/6 passing
ListObjects 1/1 passing
ListUsers 3/3 passing
# file: groups-resource-attributes/store.fga.yaml
Tests 1/1 passing
Checks 5/5 passing
# file: iot/store.fga.yaml
Tests 3/3 passing
Checks 4/4 passing
ListObjects 1/1 passing
ListUsers 1/1 passing
# file: ip-based-access/store.fga.yaml
Tests 2/2 passing
Checks 2/2 passing
ListObjects 2/2 passing
# file: modeling-guide/step-1-basic.fga.yaml
Tests 1/1 passing
Checks 4/4 passing
# file: modeling-guide/step-10-fine-grained-api-access.fga.yaml
Tests 8/8 passing
Checks 30/30 passing
# file: modeling-guide/step-2-multi-tenancy.fga.yaml
Tests 2/2 passing
Checks 8/8 passing
# file: modeling-guide/step-3-groups.fga.yaml
Tests 3/3 passing
Checks 12/12 passing
# file: modeling-guide/step-4-public-access.fga.yaml
Tests 4/4 passing
Checks 14/14 passing
# file: modeling-guide/step-5-relation-based-abac.fga.yaml
Tests 5/5 passing
Checks 18/18 passing
# file: modeling-guide/step-6-super-admin.fga.yaml
Tests 6/6 passing
Checks 18/18 passing
# file: modeling-guide/step-7-conditional-relationships-abac.fga.yaml
Tests 6/6 passing
Checks 20/20 passing
# file: modeling-guide/step-8-custom-roles.fga.yaml
Tests 7/7 passing
Checks 24/24 passing
# file: modeling-guide/step-9-application-access.fga.yaml
Tests 8/8 passing
Checks 28/28 passing
# file: modular/core.fga.yaml
Tests 1/1 passing
Checks 2/2 passing
# file: modular/issue-tracker.fga.yaml
Tests 1/1 passing
Checks 2/2 passing
# file: modular/store.fga.yaml
Tests 1/1 passing
Checks 5/5 passing
# file: modular/wiki.fga.yaml
Tests 1/1 passing
Checks 2/2 passing
# file: multitenant-rbac/store.fga.yaml
Tests 3/3 passing
Checks 12/12 passing
ListUsers 1/1 passing
# file: role-assignments/store.fga.yaml
Tests 1/1 passing
Checks 7/7 passing
# file: slack/store.fga.yaml
Tests 3/3 passing
Checks 6/6 passing
ListObjects 1/1 passing
ListUsers 1/1 passing
# file: superadmin/store.fga.yaml
Tests 3/3 passing
Checks 8/8 passing
ListObjects 3/3 passing
ListUsers 2/2 passing
# file: temporal-access/store.fga.yaml
Tests 4/4 passing
Checks 4/4 passing
ListObjects 1/1 passing
ListUsers 2/2 passing
# Test Summary #
Tests 102/102 passing
Checks 326/326 passing
ListObjects 17/17 passing
ListUsers 19/19 passing

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added support for running the fga model test command with multiple test files using glob patterns.
  • Documentation

    • Clarified that the --tests parameter accepts glob patterns to specify multiple YAML test files.
    • Updated example usages to demonstrate the glob pattern capability for test files.

@aaguiarz aaguiarz requested review from a team as code owners June 10, 2025 16:22
@aaguiarz aaguiarz marked this pull request as draft June 10, 2025 16:22
@aaguiarz aaguiarz requested a review from Copilot June 12, 2025 15:29
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds glob pattern support for the test command, allowing users to specify multiple test files using wildcard patterns. Key changes include:

  • Replacing a single file read with glob expansion to accept patterns.
  • Updating error messages to include the file name when a test file fails.
  • Documenting the new globbing support in the README and CHANGELOG.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
cmd/model/test.go Uses filepath.Glob to expand test file patterns and aggregates test results.
README.md Updates test command documentation to reflect support for glob patterns.
CHANGELOG.md Documents the addition of glob support for test files.

@aaguiarz
Copy link
Member Author

aaguiarz commented Jun 20, 2025

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jun 20, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

coderabbitai bot commented Jun 20, 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.

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

## Walkthrough

The changes introduce support for running the `fga model test` command with multiple test files using glob patterns. Documentation in the README and changelog was updated to reflect this enhancement. The command implementation now resolves glob patterns, executes tests across all matched files, and aggregates the results for reporting.

## Changes

| File(s)                | Change Summary                                                                                       |
|------------------------|-----------------------------------------------------------------------------------------------------|
| CHANGELOG.md           | Updated to note the new feature supporting glob patterns for test files in the "Unreleased" section.|
| README.md              | Documentation revised to clarify and exemplify glob pattern support for the `--tests` parameter.    |
| cmd/model/test.go      | Logic updated to accept glob patterns, resolve multiple files, run tests for each, and aggregate results. |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant CLI
    participant FileSystem

    User->>CLI: fga model test --tests "tests/*.fga.yaml"
    CLI->>FileSystem: Resolve glob pattern "tests/*.fga.yaml"
    FileSystem-->>CLI: List of matching test files
    loop For each test file
        CLI->>FileSystem: Read test file
        CLI->>CLI: Run tests from file
        CLI->>CLI: Accumulate results
    end
    CLI->>User: Output aggregate test results and summary

<!-- walkthrough_end -->
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIAQVp6Ii9Be2xubnwKUIAzTLCQhScMWgAaaNSBZnUaejlIbERKdDQibHhnAC9IAApbSDMAVgBGAYBKEpQMXApFbAZpMNgPBjRuFXgvdXkCHhmJeCVIJJS13BoKDGQd3CXIAANmRRJfGkRcO8LmTFoNGARkMiwTDzNhTdA+fAAd2QDUoV3w9m4ong2W2BWyGwWeVo8H8Yky8AWDXgGCIR2SqhJZMQsimaAAHhN4MxePh9qTINlIvT4GpNrh5CT8m97M9ROJ8Bhfu5rHYSQwvNglMhaPgGI52NR4JL6txaNQFjtlQwKLyPDcPORIeTBGoOdkSNRsP50MU/KJMrQrv9GEDSR4hRbdvgRGIAOTIADCAAlYgA5ADiAFEADIAeQT0pCVMgkLQyCRFFyFDY9GJHKDTCKXvuRARr1CGgA9BpW7oKNgMABeAB6ABIPt97l8ANbmkJ3CaQ9SwRYeLzUc6Tc4d7g1SC0Z05kj00R4bVSv4ePpoBL+RCNZBIBweMwAFgATABmV30eWK5Xod0O/wYeZhBFMEgHdzgwNAXnzEdIAAVRsFNOTyU8cQlMDfCYKYQI0cxLEjFh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avZAYBdtAfWBAMDm9wkg2W93zFoOVprSWhglYWzlmrAxuEHcOxAILuBQtegiyQaqdBgvgw60AA== -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details>
<summary>✨ Finishing Touches</summary>

<details>
<summary>🧪 Generate unit tests</summary>

- [ ] <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} -->   Create PR with unit tests
- [ ] <!-- {"checkboxId": "07f1e7d6-8a8e-4e23-9900-8731c2c87f58", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} -->   Post copyable unit tests in a comment
- [ ] <!-- {"checkboxId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} -->   Commit unit tests in branch `codex/implement-feature-from-issue-#423`

</details>

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=openfga/cli&utm_content=515):

- 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](https://www.coderabbit.ai/contact-us/support) 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](https://docs.coderabbit.ai/finishing-touches/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](https://docs.coderabbit.ai/guides/configure-coderabbit) 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](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

Copy link
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: 0

♻️ Duplicate comments (1)
cmd/model/test.go (1)

51-57: Well-implemented glob pattern handling with good fallback behavior.

The implementation correctly uses filepath.Glob() and provides a sensible fallback when no files match the pattern, maintaining backward compatibility.

Consider adding a user-friendly message when falling back to single file mode to help users understand the behavior:

 		if len(fileNames) == 0 {
+			fmt.Fprintf(os.Stderr, "No files matched the pattern '%s'. Treating as single file name.\n", testsFileName)
 			fileNames = []string{testsFileName}
 		}
🧹 Nitpick comments (1)
cmd/model/test.go (1)

113-113: Consider updating the flag description to mention glob pattern support.

The flag description should reflect the new glob pattern capability.

-	testCmd.Flags().String("tests", "", "Tests file Name. The file should have the OpenFGA tests in a valid YAML or JSON format") //nolint:lll
+	testCmd.Flags().String("tests", "", "Tests file name or glob pattern. Files should have OpenFGA tests in a valid YAML or JSON format") //nolint:lll
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8dc6c9a and c6a6d46.

📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • README.md (3 hunks)
  • cmd/model/test.go (3 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md

[uncategorized] ~528-~528: Loose punctuation mark.
Context: ...test ###### Parameters * --tests: Name of the tests file, or a glob patte...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~528-~528: Possible missing comma found.
Context: ...r a glob pattern to multiple files (for example tests/*.fga.yaml). Each file must be ...

(AI_HYDRA_LEO_MISSING_COMMA)

🪛 markdownlint-cli2 (0.17.2)
README.md

528-528: Unordered list style
Expected: dash; Actual: asterisk

(MD004, ul-style)

🔇 Additional comments (6)
CHANGELOG.md (1)

9-9: Verify the correct PR number reference.

The changelog references PR #423, but the PR objectives indicate this is PR #515. Please ensure the correct PR number is referenced.

README.md (1)

381-381: Documentation accurately reflects the new glob support feature.

The updates clearly document that the --tests parameter now accepts both single YAML test files and glob patterns. The examples are consistently updated throughout the documentation.

Also applies to: 528-528, 607-607

cmd/model/test.go (4)

23-23: Good addition of filepath import for glob functionality.

The import is necessary for the new glob pattern support.


59-59: Good initialization of aggregate results structure.

Proper setup for collecting results from multiple test files.


71-87: Excellent implementation of multi-file test execution and aggregation.

The loop correctly processes each file, runs tests, and aggregates results. Error handling includes file-specific context which is helpful for debugging failures.


89-99: Proper use of aggregated results for final output and status determination.

The implementation correctly uses the aggregated results for both verbose output and summary display, ensuring all test results are considered in the final pass/fail determination.

@aaguiarz aaguiarz marked this pull request as ready for review June 20, 2025 14:36
Copy link
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: 0

♻️ Duplicate comments (1)
cmd/model/test.go (1)

52-58: Consider adding user feedback for fallback behavior.

The glob resolution logic is correct, but users might be confused when no files match their pattern and the command silently falls back to treating the pattern as a single filename.

Consider adding a warning message to clarify the fallback behavior:

 	if len(fileNames) == 0 {
+		fmt.Fprintf(os.Stderr, "No files matched the pattern '%s'. Treating it as a single file name.\n", testsFileName)
 		fileNames = []string{testsFileName}
 	}
🧹 Nitpick comments (1)
cmd/model/test.go (1)

93-94: Consider a more robust approach for header removal.

The string replacement to remove the test summary header is fragile and could break if the format of FriendlyDisplay() changes.

Consider using a more robust approach:

-			summaryText := strings.Replace(test.FriendlyDisplay(), "# Test Summary #\n", "", 1)
-			summary := fmt.Sprintf("# file: %s\n%s", file, summaryText)
+			summaryText := test.FriendlyDisplay()
+			if strings.HasPrefix(summaryText, "# Test Summary #\n") {
+				summaryText = summaryText[len("# Test Summary #\n"):]
+			}
+			summary := fmt.Sprintf("# file: %s\n%s", file, summaryText)

Or better yet, consider adding a method to TestResults that returns the summary without the header, making the intent more explicit.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between dea9839 and 21e1b9f.

📒 Files selected for processing (1)
  • cmd/model/test.go (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Tests
  • GitHub Check: Test Release Process
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (actions)
🔇 Additional comments (4)
cmd/model/test.go (4)

23-24: LGTM - Appropriate imports for the new functionality.

The addition of path/filepath for glob support and strings for string manipulation are correctly imported and necessary for the new features.


60-63: LGTM - Clean setup for multi-file processing.

The variables are well-named and appropriately initialized for tracking multiple files and aggregating results.


75-97: LGTM - Robust multi-file processing with good error handling.

The loop correctly processes each file individually while maintaining proper error context. The conditional summary collection for multiple files is well-implemented.


99-115: LGTM - Excellent user experience for multi-file results.

The aggregate results handling is well-designed:

  • Uses aggregate results for final pass/fail determination
  • Shows individual file summaries followed by aggregate summary for multiple files
  • Maintains backward compatibility for single file usage

@JarrodJ83
Copy link

JarrodJ83 commented Jul 31, 2025

Looking forward to this! It's really a pain to have to run all your tests files individually. It's easy enough to write a loop in your build pipelines but making sure you catch all tests when doing local development becomes a pain in the current state. This will simplify things on both ends tremendously!

Copy link
Contributor

@sergiught sergiught left a comment

Choose a reason for hiding this comment

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

👍 From my side, I'm fine with getting this in, given we're on v0 and it helps improve the DX for our users. We can keep iterating and perfecting this as n+1s (tests too in follow up PRs).

@aaguiarz aaguiarz added this pull request to the merge queue Aug 5, 2025
Merged via the queue into main with commit 51087d7 Aug 5, 2025
22 checks passed
@aaguiarz aaguiarz deleted the codex/implement-feature-from-issue-#423 branch August 5, 2025 15:01
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.

Improvement: Running multiple test files at once
3 participants