Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #1042 and also test openfecli for API breaks #1054

Merged
merged 14 commits into from
Dec 13, 2024
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 ✅`
});
}
Loading