Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
910 views
in Technique[技术] by (71.8m points)

continuous integration - How to make Github status-checks on a commit immutable?

I have 2 tests running in CodeBuild which reports back status to the commit history.

  • Test 1: triggered by PR Update event. Failed because of not following my PR code standard
  • Test 2: triggered by PUSH event on git branch. Succeeded, dev are free to work on their branch.

After Test 1 fails, the PR supposes to show failed status until a new commit. But the problem is Test 2 succeeded and overwrite status check on the Github pull request page. I want to let PR having green status only when both tests passed.

I checked Github official document for Commit Status:

Statuses cannot be changed once added to a commit (they’re completely immutable), but any number of statuses may be attached to a single commit. We only display the most recent status for any given commit in our UI.

But I don't know how to enable it in my case. How to make Github status check on commit immutable?

question from:https://stackoverflow.com/questions/65921158/how-to-make-github-status-checks-on-a-commit-immutable

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

A better piece of documentation to look at is the REST API documentation for statuses. The problem here is likely that you're using the same context field for both statuses, but you're doing different checks. The statuses are both technically immutable, but when you create a new status with the same context, it overrides the old status with that status.

Your PR checks are more stringent than your push checks, but they use the same context. As a result, when your push checks update the status with success, that overrides the PR update event. If you're really running two separate sets of tests, then use two different contexts, and they will appear as two separate checks.

I think what you were asking for is how to never allow a status to be overridden by a new status with the same context, and that's not possible. You wouldn't want that anyway, because if the CI server had a temporary problem and you needed to re-run the check, you'd never be able to replace the old failure with that commit, and you'd have to make a no-op change and push a new commit in order to merge.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...