-
Couldn't load subscription status.
- Fork 259
ci: Future proof golangci-lint workflow by using dynamic base branch #3805
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
Conversation
Co-authored-by: jpayne3506 <89417863+jpayne3506@users.noreply.github.com>
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.
Changes in both files are required.
Expected result as GITHUB_BASE_REF is intended to solve this problem.
The name of the base ref or target branch of the pull request in a workflow run. This is only set when the event that triggers a workflow run is either pull_request or pull_request_target. For example, main.``` | /azp run Azure Container Networking PR |
| Azure Pipelines successfully started running 1 pipeline(s). |
Confirmed. The implementation uses
The solution now works for PRs against any branch (commit be5416e). Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…zure#3805) * Initial plan * ci: Future proof golangci-lint workflow by using dynamic base branch Co-authored-by: jpayne3506 <89417863+jpayne3506@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jpayne3506 <89417863+jpayne3506@users.noreply.github.com>
…3805) * Initial plan * ci: Future proof golangci-lint workflow by using dynamic base branch Co-authored-by: jpayne3506 <89417863+jpayne3506@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jpayne3506 <89417863+jpayne3506@users.noreply.github.com>
The golangci-lint workflow was hardcoded to use
--new-from-rev=origin/masterwhich caused failures when:Changes Made
1. Removed hardcoded base branch from
.golangci.ymlBefore:
After:
2. Updated GitHub workflow to use dynamic base branch
Before:
After:
How It Works
The solution uses GitHub Actions context variables and conditional expressions:
github.base_refto get the target branch dynamically--new-from-revparameter (runs full linting)Test Scenarios
pull_requestmaster--new-from-rev=origin/masterpull_requestfeature/awesome-feature--new-from-rev=origin/feature/awesome-featureworkflow_dispatchmerge_groupBenefits
✅ Future-proof: Works with any base branch without manual changes
✅ Automatic: No need to update workflow when creating feature branches
✅ Robust: Handles different event types gracefully
✅ Minimal: Only 2 lines changed across 2 files
✅ Backward compatible: Still works for existing workflows
The workflow now automatically adapts to any base branch without requiring manual changes when creating feature branches or opening PRs against them.
Fixes #3804.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
golangci-lint.rungolangci-lint config verify --config=.golangci.yml(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.