-
Notifications
You must be signed in to change notification settings - Fork 13
Add required CI job for branch protection #165
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
Draft
Copilot
wants to merge
3
commits into
main
Choose a base branch
from
copilot/make-ci-jobs-required
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+75
−0
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # Required CI Checks Configuration | ||
|
|
||
| This document explains how to configure required status checks for this repository to prevent merging broken PRs. | ||
|
|
||
| ## Overview | ||
|
|
||
| The CI workflow includes a special `required` job that depends on all critical CI jobs: | ||
| - `svlint` - Linting checks | ||
| - `build_and_test` - Build and test the core | ||
| - `riscof` - RISCOF compliance tests | ||
| - `de1-soc` - DE1-SoC environment build and test | ||
|
|
||
| The `required` job will only pass if all these jobs succeed, providing a single status check to mark as required. | ||
|
|
||
| ## Configuring Branch Protection | ||
|
|
||
| To enable required status checks: | ||
|
|
||
| 1. Go to your repository on GitHub | ||
| 2. Navigate to **Settings** → **Branches** | ||
| 3. Under "Branch protection rules", click **Add rule** or edit an existing rule | ||
| 4. For "Branch name pattern", enter `main` (or your default branch) | ||
| 5. Check **Require status checks to pass before merging** | ||
| 6. Search for and select the `required` status check | ||
| 7. Optionally, also check **Require branches to be up to date before merging** | ||
| 8. Click **Create** or **Save changes** | ||
|
|
||
| ## How It Works | ||
|
|
||
| The `required` job: | ||
| - Uses `if: always()` to ensure it runs even if some jobs fail | ||
| - Declares all critical jobs in its `needs` list | ||
| - Checks the result of each job and fails if any job didn't succeed | ||
| - Provides clear output showing which jobs failed | ||
|
|
||
| This pattern ensures: | ||
| - A consistent status check name (`required`) that can be marked as required in branch protection | ||
| - All critical CI jobs must pass before the PR can be merged | ||
| - Clear feedback when jobs fail | ||
|
|
||
| ## Testing | ||
|
|
||
| When you open a PR, you should see the `required` check in the status checks list. It will only pass if all dependent jobs succeed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i thought that there was some sort a flag i can attach to a job that will mark it as required and not let me merge a PR if its not passing; i remember that such jobs has a "required" tag on them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot ^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right that jobs marked as required in branch protection settings show a "Required" badge in the PR checks UI. However, there's no workflow-level attribute (like
required: true) that automatically makes a job required - you still need to configure it in Settings → Branches → Branch protection rules.The
requiredjob I added provides a single, stable status check name that you can mark as required in branch protection. This is the standard pattern because:To enable it: Go to Settings → Branches → Add/edit rule for
main→ Check "Require status checks to pass" → Select therequiredcheck.