Skip to content

feat(testing): add e2e test for release init workflow#2033

Merged
jinseopkim0 merged 10 commits intomainfrom
release-init-e2e
Sep 12, 2025
Merged

feat(testing): add e2e test for release init workflow#2033
jinseopkim0 merged 10 commits intomainfrom
release-init-e2e

Conversation

@jinseopkim0
Copy link
Copy Markdown
Contributor

@jinseopkim0 jinseopkim0 commented Sep 10, 2025

Sub-task for #1013.

This PR adds E2E test for the release init workflow.

The tests verify that the command updates the state.yaml file and generates CHANGELOG.md correctly by comparing them with golden files.

Importantly, this PR enhances the tests to validate the structure and content of the release-init-request.json file that is generated by the librarian tool based on mock Git commits. This validation ensures the generated JSON conforms to the container contract as defined in doc/language-onboarding.md.

This enhanced test coverage will prevent regressions of the following issues:

  • Prevents issues such as #2035: By asserting that correct, lowercase field names (e.g., type, subject, body) are used in the changes array, preventing contract mismatches.
  • Prevents issues such as #2066: By verifying that piper_cl_number and source_commit_hash fields are present, ensuring commit trailers are parsed and included correctly.

Note: The test fails until internal/conventionalcommits/conventional_commits.go is updated to handle the parsing correctly.

time=2025-09-12T17:52:25.285Z level=ERROR msg="readReleaseInitRequest: Validation failed" error="validation error: library go-google-cloud-pubsub-v1, change 0 missing 'source_commit_hash'"

This issue is being tracked in #2066.

@jinseopkim0 jinseopkim0 force-pushed the release-init-e2e branch 7 times, most recently from c967a54 to 38c777d Compare September 10, 2025 16:13
This commit introduces an end-to-end test for the 'librarian release init'
command. The test verifies that the command correctly updates the state.yaml
file and generates a CHANGELOG.md based on a mock repository and a
simulated feature commit.

The test utilizes a mock container behavior defined in testdata/e2e_func.go,
which processes a release-init-request.json file as per the
Librarian container contract.
This refactors the TestReleaseInit end-to-end test to use a table-driven
structure. This improves the readability and maintainability of the test,
and makes it easier to add new test cases in the future.
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.23%. Comparing base (9bef458) to head (bde0dde).
⚠️ Report is 22 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2033      +/-   ##
==========================================
+ Coverage   82.16%   83.23%   +1.07%     
==========================================
  Files          83       84       +1     
  Lines        8848     9198     +350     
==========================================
+ Hits         7270     7656     +386     
+ Misses       1230     1197      -33     
+ Partials      348      345       -3     

☔ 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.

@jinseopkim0 jinseopkim0 marked this pull request as ready for review September 11, 2025 03:09
@jinseopkim0 jinseopkim0 requested a review from a team as a code owner September 11, 2025 03:09
@jinseopkim0 jinseopkim0 requested a review from ldetmer September 11, 2025 03:09
@jinseopkim0 jinseopkim0 enabled auto-merge (squash) September 11, 2025 03:09
Updates the mock commit message in TestReleaseInit to use the
footer keys ('git-commit-hash', 'PiperOrigin-RevId') expected by the
conventional commits parser to populate source_commit_hash and
piper_cl_number in release-init-request.json.

Also ensures that the validation within the e2e_func mock checks
for the presence of these fields, hardening the test against regressions
like issue #2066 and issue #2035.
Copy link
Copy Markdown
Contributor

@ldetmer ldetmer left a comment

Choose a reason for hiding this comment

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

I think there still may be a missing check somewhere as #2066 isn't fixed yet. So shouldn't this test fail?

- Change log level from Debug to Info in e2e_func.go

- Remove redundant debug log statement

- Use constant for release init response filename

- Remove unused 'release' field from updated-state.yaml to align with schema
Updates the e2e test for 'release init' to use a more realistic,
complex commit message that includes nested commits.

Updates the golden CHANGELOG.md to match the expected output from
the new commit message.

Note: The test is expected to fail until the commit parser is fixed
to correctly handle nested commits. This is part of an active effort
being worked on separately.
@jinseopkim0
Copy link
Copy Markdown
Contributor Author

jinseopkim0 commented Sep 12, 2025

I think there still may be a missing check somewhere as #2066 isn't fixed yet. So shouldn't this test fail?

Thanks for pointing that out. I was using the parameter "git-commit-hash" instead of "Source-Link" footer in the commit message. I've fixed this (by using a real commit message googleapis/google-cloud-java@cea98dc as the input for the test), and the test fails as expected.

I've updated the description of this PR to include:
Note: The test fails until internal/conventionalcommits/conventional_commits.go is updated to handle the parsing correctly.

time=2025-09-12T17:52:25.285Z level=ERROR msg="readReleaseInitRequest: Validation failed" error="validation error: library go-google-cloud-pubsub-v1, change 0 missing 'source_commit_hash'"

This issue is being tracked in #2066.

@jinseopkim0 jinseopkim0 merged commit ef51031 into main Sep 12, 2025
11 of 14 checks passed
@jinseopkim0 jinseopkim0 deleted the release-init-e2e branch September 12, 2025 20:14
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.

4 participants