test(fixtures): add include-path multi-value handling tests#1456
test(fixtures): add include-path multi-value handling tests#1456niklasmarderx wants to merge 8 commits intoorhun:mainfrom
Conversation
Add two fixture tests that verify --include-path works correctly with multiple glob patterns: - test-include-path-repeated-flag: uses separate --include-path flags - test-include-path-space-separated: uses a single flag with space-separated globs Both should produce identical output, filtering commits to only those that touch files matching the given patterns. Closes orhun#1455
|
Hey, thanks for the PR!
Is that a new limitation that GitHub has? I think you should be able to change those files in your fork and push them to this PR, no? |
|
You're right, I was mistaken — just pushed the workflow entries in e03d189. Should be good now. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1456 +/- ##
==========================================
- Coverage 47.45% 47.35% -0.09%
==========================================
Files 24 24
Lines 2131 2131
==========================================
- Hits 1011 1009 -2
- Misses 1120 1122 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ognis1205
left a comment
There was a problem hiding this comment.
A couple of points regarding the fixture tests:
- Newly added fixture tests should all pass in CI.
- The following case seems to be missing, could you add it?
- Environment variable with space-separated globs:
export GIT_CLIFF_INCLUDE_PATH="website/**/* .github/**/*" git cliff
- Ideally, each fixture test should correspond to a single expected output. However, given the current CI setup, this is not straightforward. As a workaround, please add a comment in
workflow/test-fixtures.ymlindicating that the three fixture test entries should use identicalexpected.mdcontent.
|
I'll fix it |
Fixes: - Fix expected.md for repeated-flag and space-separated tests: bug fixes were in wrong order (alphabetical instead of chronological). git-cliff outputs commits by timestamp, so 'Update installation guide' (01:25:11) comes before 'Fix website styles' (01:25:12). New test: - Add test-include-path-env-var fixture: verifies that setting GIT_CLIFF_INCLUDE_PATH='website/**/* docs/**/*' as an environment variable produces the same output as the CLI flag variants. Workflow: - Add explanatory comment that all three include-path fixture tests use identical expected.md content. - Pass GIT_CLIFF_INCLUDE_PATH env var from matrix to the test action. Addresses review feedback from @ognis1205.
The GIT_CLIFF_INCLUDE_PATH env var approach broke all other fixture tests because GitHub Actions sets the env globally for the entire job. An empty string was interpreted as 'set but empty' by clap, which caused include_path filtering on every test. Replace with a cliff.toml config-based test instead: - test-include-path-repeated-flag: repeated --include-path flags - test-include-path-space-separated: single space-separated value - test-include-path-config: include_paths in cliff.toml This tests three different input methods for the same feature, which is more practical than the env var approach. Update workflow comment to document the three-test relationship.
The cliff.toml template ends with \n which produces a trailing empty line in the output. The expected.md files were missing this trailing newline, causing diff mismatches in CI.
Adds a new fixture test that verifies GIT_CLIFF_INCLUDE_PATH with a space-separated list of glob patterns produces the same output as repeated --include-path flags and the config-based include_paths setting. Extends the run-fixtures-test action with an include-path-env input so fixture tests can set GIT_CLIFF_INCLUDE_PATH without modifying commit.sh.
|
Added the env-var fixture in 63ee5ff. Since the run-fixtures-test action controls the git-cliff invocation, I extended it with an include-path-env input that sets GIT_CLIFF_INCLUDE_PATH before running git-cliff. The new test-include-path-env-var fixture uses the same commit history and expected output as the other three include-path tests. |
Add test-include-path-env-var-github fixture that sets GIT_CLIFF_INCLUDE_PATH="website/**/* .github/**/*" to verify that space-separated globs work correctly even when one of the globs (i.e. .github/**/*) does not match any commits in the history. Only website/**/* commits are included in the expected output. Addresses review request from ognis1205.
|
Thanks for the review, @ognis1205! I've addressed both points in commit 04bad02:
|
ognis1205
left a comment
There was a problem hiding this comment.
Overall looks great!
- It seems the CI for the newly added fixture tests is currently failing, so could you take a look?
- We may also want to add similar tests for
--exclude-path, but that could be done in a separate PR.
Thanks!
| @@ -46,6 +50,9 @@ runs: | |||
| shell: bash | |||
| run: | | |||
| set +e | |||
| if [ -n '${{ inputs.include-path-env }}' ]; then | |||
| export GIT_CLIFF_INCLUDE_PATH='${{ inputs.include-path-env }}' | |||
| fi | |||
There was a problem hiding this comment.
We could introduce an optional env.sh per fixture and load it in a dedicated initialization step like this:
- name: Loading environmental variables
working-directory: ${{ inputs.fixtures-dir }}
shell: bash
run: |
if [ -f "./env.sh" ]; then
set -a
source ./env.sh
set +a
env | grep -E '^(GIT_CLIFF_)' >> "$GITHUB_ENV"
fiThis makes it explicit that fixture-specific environment variables are defined and then propagated across steps via GITHUB_ENV, rather than being passed through action inputs. It would also allow us to remove inputs like include-path-env and keep each fixture self-contained.
We should still ensure that only a limited set of variables, e.g. GIT_CLIFF_*, are propagated to avoid leaking unintended environment variables. cc: @orhun
| # NOTE: This test verifies that GIT_CLIFF_INCLUDE_PATH correctly | ||
| # handles space-separated globs where one glob matches no commits | ||
| # (i.e. .github/**/* does not exist in the fixture's git history). | ||
| # Only website/**/* commits are expected in the output. | ||
| - fixtures-name: test-include-path-env-var-github | ||
| include-path-env: "website/**/* .github/**/*" |
There was a problem hiding this comment.
We could consider removing this test, as this behavior should already be covered by unit tests.
|
Fixed the trailing newline in |
|
CI is green now. The trailing newline fix in |
Add two fixture tests that verify
--include-pathhandles multiple glob patterns correctly (#1455):--include-path 'website/**/*' --include-path 'docs/**/*'--include-path 'website/**/* docs/**/*'Both use the same commit history (files in
website/,src/, anddocs/) and expect the same filtered output — only commits touchingwebsite/ordocs/paths.Closes #1455