Skip to content

fix: fix the OpenAPI change detection in release job#1079

Open
ShradhaGupta31 wants to merge 1 commit into
mainfrom
fix-openapi-workflowaction
Open

fix: fix the OpenAPI change detection in release job#1079
ShradhaGupta31 wants to merge 1 commit into
mainfrom
fix-openapi-workflowaction

Conversation

@ShradhaGupta31

@ShradhaGupta31 ShradhaGupta31 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Addresses: #1080

Issue Root cause: The "Check if OpenAPI files changed" step ran after Semantic Release, which had already pushed a new release commit to origin/main. At that point git diff origin/main HEAD compared in the wrong direction showing the changelog/version bump files, not the OpenAPI changes from the merged PR so the grep never matched and changed=false detected and hence further steps were skipped.

Fix:

  • Changed diff to HEAD~1 HEAD which compares what actually changed in the triggering merge commit, independent of origin/main's state
  • Added fetch-depth: 2 to the checkout so HEAD~1 is available in the shallow clone
  • Removed the unnecessary git fetch origin main

@ShradhaGupta31 ShradhaGupta31 requested a review from a team as a code owner June 16, 2026 05:12
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 43.39%. Comparing base (fe3c5f0) to head (ec3723a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1079   +/-   ##
=======================================
  Coverage   43.39%   43.39%           
=======================================
  Files         141      141           
  Lines       13397    13397           
=======================================
  Hits         5814     5814           
  Misses       7022     7022           
  Partials      561      561           

☔ View full report in Codecov by Harness.
📢 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.

@graikhel-intel graikhel-intel requested a review from Copilot June 16, 2026 05:31

Copilot AI left a comment

Copy link
Copy Markdown

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 fixes OpenAPI change detection in the release GitHub Actions workflow so the SwaggerHub publish steps run when OpenAPI-related source files actually changed in the triggering push/merge.

Changes:

  • Adjusts actions/checkout to fetch an additional commit (fetch-depth: 2) so a parent commit is available.
  • Updates the OpenAPI change detection from git diff origin/main HEAD to git diff HEAD~1 HEAD and removes the git fetch origin main dependency.
Comments suppressed due to low confidence (1)

.github/workflows/release.yml:244

  • git diff --name-only HEAD~1 HEAD only inspects the last commit. Since this workflow runs on push to main/beta, a push that contains multiple commits (or a merge + follow-up fix commit) could include OpenAPI changes that aren’t in HEAD itself, causing a false changed=false. Using the push range ${{ github.event.before }}${{ github.sha }} makes the check cover the entire push and avoids depending on HEAD~1 being the correct base.
          if git diff --name-only HEAD~1 HEAD | grep -q '^internal/controller/openapi/'; then
            echo "changed=true" >> $GITHUB_OUTPUT
          else
            echo "changed=false" >> $GITHUB_OUTPUT
          fi

- Use github.event.before..github.sha instead of origin/main..HEAD to
detect OpenAPI changes across the full push range.

Signed-off-by: ShradhaGupta31 <[email protected]>
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.

Fix github action to generate openapi.json & publish to swagger hub

3 participants