Skip to content

Commit

Permalink
fix issue #1042 and also test openfecli for API breaks (#1054)
Browse files Browse the repository at this point in the history
* fix issue #1042 and also test openfecli for API breaks

* just check against main instead of last tag

* change to run on PR so I can test the changes

* test cli api change

* undo change that didn't break api

* change default that will trigger API change

* undo api change

* remove comments if api change check passes

* fix reference error

* break api

* add a message if there is no API break

* fix api break

* Switch back to pull request target now that testing is done
  • Loading branch information
mikemhenry authored Dec 13, 2024
1 parent 8374172 commit d2f4719
Showing 1 changed file with 42 additions and 5 deletions.
47 changes: 42 additions & 5 deletions .github/workflows/change.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
with:
fetch-depth: 0

- run: git fetch --depth=1 --tags

- uses: actions/setup-python@v5
with:
python-version: "3.12"
Expand All @@ -25,17 +27,52 @@ jobs:
id: check
run: |
pip install griffe
griffe check "openfe" --verbose
griffe check "openfe" --verbose -a origin/main
griffe check "openfecli" --verbose -a origin/main
- name: Post Comment on Failure
if: steps.check.outcome == 'failure'
- name: Manage PR Comments
uses: actions/github-script@v7
with:
script: |
const prNumber = context.payload.pull_request.number;
github.rest.issues.createComment({
const identifier = '<!-- api-break-check -->';
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
const stepUrl = `${runUrl}#step:check`;
// Determine the outcome of the check step
const checkStepOutcome = '${{ steps.check.outcome }}';
// List existing comments
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: '🚨 API breaking changes detected! 🚨'
});
// Delete previous comments from this action
for (const comment of comments) {
if (comment.body.includes(identifier)) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id,
});
}
}
// Post a new comment only if the check step failed
if (checkStepOutcome === 'failure') {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: `${identifier}\n🚨 API breaking changes detected! 🚨\n[View logs for this step](${stepUrl})`
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: `${identifier}\nNo API break detected ✅`
});
}

0 comments on commit d2f4719

Please sign in to comment.