Skip to content

test(fixtures): add include-path multi-value handling tests#1456

Open
niklasmarderx wants to merge 8 commits intoorhun:mainfrom
niklasmarderx:test/include-path-fixtures-1455
Open

test(fixtures): add include-path multi-value handling tests#1456
niklasmarderx wants to merge 8 commits intoorhun:mainfrom
niklasmarderx:test/include-path-fixtures-1455

Conversation

@niklasmarderx
Copy link
Copy Markdown

@niklasmarderx niklasmarderx commented Mar 31, 2026

Add two fixture tests that verify --include-path handles multiple glob patterns correctly (#1455):

  • test-include-path-repeated-flag: --include-path 'website/**/*' --include-path 'docs/**/*'
  • test-include-path-space-separated: --include-path 'website/**/* docs/**/*'

Both use the same commit history (files in website/, src/, and docs/) and expect the same filtered output — only commits touching website/ or docs/ paths.

Closes #1455

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
@niklasmarderx niklasmarderx requested a review from orhun as a code owner March 31, 2026 13:46
@orhun
Copy link
Copy Markdown
Owner

orhun commented Apr 3, 2026

Hey, thanks for the PR!

The workflow entries for test-fixtures.yml need to be added separately since fork pushes can't modify workflow files. Here's what to add to the matrix:

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?

@niklasmarderx
Copy link
Copy Markdown
Author

You're right, I was mistaken — just pushed the workflow entries in e03d189. Should be good now.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.35%. Comparing base (0a69719) to head (7fa13a5).
⚠️ Report is 14 commits behind head on main.

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     
Flag Coverage Δ
unit-tests 47.35% <ø> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@orhun orhun requested a review from ognis1205 April 4, 2026 09:25
@orhun orhun added this to the 2.13.0 milestone Apr 4, 2026
Copy link
Copy Markdown
Contributor

@ognis1205 ognis1205 left a comment

Choose a reason for hiding this comment

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

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?
  1. 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.yml indicating that the three fixture test entries should use identical expected.md content.

@niklasmarderx
Copy link
Copy Markdown
Author

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.
@niklasmarderx niklasmarderx requested a review from ognis1205 April 4, 2026 19:29
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.
@niklasmarderx
Copy link
Copy Markdown
Author

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.
@niklasmarderx
Copy link
Copy Markdown
Author

Thanks for the review, @ognis1205!

I've addressed both points in commit 04bad02:

  1. New fixture test with website/**/* .github/**/*: Added test-include-path-env-var-github which sets GIT_CLIFF_INCLUDE_PATH="website/**/* .github/**/*". Since .github/**/* doesn't match any commits in the fixture history, only website/**/* commits appear in the output — this verifies that space-separated globs work correctly even when one glob matches nothing.

  2. Workflow comment: The test-fixtures.yml already contains a # NOTE comment clarifying that the four existing include-path tests share identical expected.md content. I also added a separate comment above the new test-include-path-env-var-github entry explaining its distinct expected output.

Copy link
Copy Markdown
Contributor

@ognis1205 ognis1205 left a comment

Choose a reason for hiding this comment

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

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!

Comment on lines 20 to +55
@@ -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
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.

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"
    fi

This 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

Comment on lines +158 to +163
# 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/**/*"
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.

We could consider removing this test, as this behavior should already be covered by unit tests.

@niklasmarderx
Copy link
Copy Markdown
Author

Fixed the trailing newline in test-include-path-env-var-github/expected.md — it was missing the extra \n that all other fixtures have, which caused the diff to fail.

@niklasmarderx
Copy link
Copy Markdown
Author

CI is green now. The trailing newline fix in test-include-path-env-var-github/expected.md resolved the last failure — all fixture tests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test fixtures for GIT_CLIFF_INCLUDE_PATH multiple-value handling

4 participants