ci: Future proof golangci-lint workflow by using dynamic base branch#3805
Merged
jpayne3506 merged 2 commits intomasterfrom Jul 15, 2025
Merged
ci: Future proof golangci-lint workflow by using dynamic base branch#3805jpayne3506 merged 2 commits intomasterfrom
jpayne3506 merged 2 commits intomasterfrom
Conversation
Co-authored-by: jpayne3506 <89417863+jpayne3506@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] ci: Future proof golangci-lint workflow
ci: Future proof golangci-lint workflow by using dynamic base branch
Jul 11, 2025
jpayne3506
approved these changes
Jul 11, 2025
Contributor
jpayne3506
left a comment
There was a problem hiding this comment.
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.```
isaac-dasan
approved these changes
Jul 11, 2025
Contributor
|
/azp run Azure Container Networking PR |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
Author
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:
|
QxBytes
approved these changes
Jul 11, 2025
rbtr
approved these changes
Jul 11, 2025
NihaNallappagari
pushed a commit
to NihaNallappagari/azure-container-networking
that referenced
this pull request
Sep 4, 2025
…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>
sivakami-projects
pushed a commit
that referenced
this pull request
Oct 23, 2025
…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>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.