Skip to content

Commit fe0d4fd

Browse files
bugerjeffy-mathew
andauthored
Merging to release-5.10: [TT-16055] remove redundant codegen:smart (#7495) (#7497)
### **User description** [TT-16055] remove redundant codegen:smart (#7495) <!-- Provide a general summary of your changes in the Title above --> ## Description Remove redundant `task codgen:smart` from CI, as `task tidy` is already invoking it. ## Related Issue https://tyktech.atlassian.net/browse/TT-16055 ## Motivation and Context <!-- Why is this change required? What problem does it solve? --> ## How This Has Been Tested <!-- Please describe in detail how you tested your changes --> <!-- Include details of your testing environment, and the tests --> <!-- you ran to see how your change affects other areas of the code, etc. --> <!-- This information is helpful for reviewers and QA. --> ## Screenshots (if appropriate) ## Types of changes <!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Refactoring or add test (improvements in base code or adds test coverage to functionality) ## Checklist <!-- Go over all the following points, and put an `x` in all the boxes that apply --> <!-- If there are no documentation updates required, mark the item as checked. --> <!-- Raise up any additional concerns not covered by the checklist. --> - [ ] I ensured that the documentation is up to date - [ ] I explained why this PR updates go.mod in detail with reasoning why it's required - [ ] I would like a code coverage CI quality gate exception and have explained why <!---TykTechnologies/jira-linter starts here--> ### Ticket Details <details> <summary> <a href="https://tyktech.atlassian.net/browse/TT-16055" title="TT-16055" target="_blank">TT-16055</a> </summary> | | | |---------|----| | Status | In Code Review | | Summary | Upgrade golangcilint to v2 on tyk gateway | Generated at: 2025-10-31 11:23:08 </details> <!---TykTechnologies/jira-linter ends here--> [TT-16055]: https://tyktech.atlassian.net/browse/TT-16055?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ ___ ### **PR Type** Enhancement, Documentation ___ ### **Description** - Centralize BASE_BRANCH logic in Taskfile - Remove duplicate BASE_BRANCH vars from includes - Document automatic base-branch detection - Improve CI/lint/codegen branch targeting ___ ### Diagram Walkthrough ```mermaid flowchart LR Taskfile["Taskfile.yml (root)"] Hooks[".taskfiles/hooks.yml"] Lint[".taskfiles/lint.yml"] Docs["CONTRIBUTING.md"] Taskfile -- "defines auto BASE_BRANCH" --> Hooks Taskfile -- "inherited var" --> Lint Taskfile -- "documented behavior" --> Docs ``` <details> <summary><h3> File Walkthrough</h3></summary> <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table> <tr> <td> <details> <summary><strong>hooks.yml</strong><dd><code>Drop redundant BASE_BRANCH in hooks taskfile</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> .taskfiles/hooks.yml - Remove local BASE_BRANCH var - Rely on inherited root Taskfile var </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7497/files#diff-4c8ab53446d9cfd97f77a7242f379e0951db3fcd68b2e5d0d78ed5b3960cd574">+0/-4</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>lint.yml</strong><dd><code>Clean up BASE_BRANCH in lint taskfile</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> .taskfiles/lint.yml - Remove local BASE_BRANCH var - Keep root var inheritance clean </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7497/files#diff-363848321486b220d237efdc32336314ea3369c113f64fdfbec6a38ea62faf66">+0/-2</a>&nbsp; &nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>Taskfile.yml</strong><dd><code>Implement BASE_BRANCH auto-detection in root Taskfile</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> Taskfile.yml <ul><li>Add robust BASE_BRANCH auto-detection<br> <li> Handle merge/release-*/* branch pattern<br> <li> Default to master if unmatched<br> <li> Provide inline documentation comments</ul> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7497/files#diff-cd2d359855d0301ce190f1ec3b4c572ea690c83747f6df61c9340720e3d2425e">+24/-1</a>&nbsp; &nbsp; </td> </tr> </table></td></tr><tr><td><strong>Documentation</strong></td><td><table> <tr> <td> <details> <summary><strong>CONTRIBUTING.md</strong><dd><code>Document base branch detection and overrides</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> CONTRIBUTING.md <ul><li>Add BASE_BRANCH configuration section<br> <li> Explain auto-detection and override<br> <li> Provide usage examples</ul> </details> </td> <td><a href="https://github.com/TykTechnologies/tyk/pull/7497/files#diff-eca12c0a30e25b4b46522ebf89465a03ba72a03f540796c979137931d8f92055">+18/-0</a>&nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> </details> ___ Co-authored-by: Jeffy Mathew <jeffy.mathew100@gmail.com>
1 parent d94179c commit fe0d4fd

4 files changed

Lines changed: 42 additions & 7 deletions

File tree

.taskfiles/hooks.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
---
22
version: "3"
33

4-
vars:
5-
BASE_BRANCH:
6-
sh: echo "${BASE_BRANCH:-master}"
7-
84
tasks:
95
# pre-commit: run formatting linters on each commit
106
# golangci-lint with --fix handles: go fmt (via gofmt formatter), go vet (via govet linter)

.taskfiles/lint.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ version: "3"
44
vars:
55
root:
66
sh: git rev-parse --show-toplevel
7-
BASE_BRANCH:
8-
sh: echo "${BASE_BRANCH:-master}"
97

108
tasks:
119
tidy:

CONTRIBUTING.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,23 @@ task test:integration # Runs the tests
8484
task lint # Runs linting checks
8585
```
8686

87+
#### BASE_BRANCH Configuration
88+
89+
The linting and code generation tasks automatically detect the appropriate base branch for comparison:
90+
91+
- **Default behavior**: Compares against `master` branch
92+
- **Merge/release branches**: If your branch name follows the pattern `merge/release-X.X/*` (e.g., `merge/release-5.8/feature-name`), tasks will automatically compare against `release-X.X`
93+
- **Manual override**: Set the `BASE_BRANCH` environment variable to specify a custom base branch
94+
95+
```shell
96+
# Automatic detection (default)
97+
task lint # Uses master for regular branches, release-X.X for merge/release-* branches
98+
99+
# Manual override
100+
BASE_BRANCH=release-5.8 task lint # Explicitly compare against release-5.8
101+
```
102+
103+
This automatic base branch detection ensures that linting and code generation only run on files that have changed compared to the appropriate base branch, and git hooks (pre-commit, pre-push) validate changes against the correct baseline.
104+
87105
### Geo IP features
88106
This product utilises GeoLite2 data created by MaxMind, available from [http://www.maxmind.com](http://www.maxmind.com).

Taskfile.yml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,31 @@ includes:
2424

2525
vars:
2626
path: ./...
27+
# BASE_BRANCH: Determines the base branch for diff-based operations (linting, codegen)
28+
# This variable is inherited by all included taskfiles.
29+
#
30+
# Detection logic:
31+
# 1. If BASE_BRANCH env var is set, use it
32+
# 2. If current branch follows release bot naming convention (merge/release-X.X/*),
33+
# extract and use the release branch (e.g., merge/release-5.8/foo -> release-5.8)
34+
# 3. Otherwise, default to master
35+
#
36+
# This ensures git hooks and linting compare against the correct baseline branch.
2737
BASE_BRANCH:
28-
sh: echo "${BASE_BRANCH:-master}"
38+
sh: |
39+
if [ -n "${BASE_BRANCH}" ]; then
40+
echo "${BASE_BRANCH}"
41+
else
42+
current_branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "")
43+
case "$current_branch" in
44+
merge/release-*/*)
45+
echo "$current_branch" | sed -n 's|^merge/\(release-[^/]*\)/.*|\1|p'
46+
;;
47+
*)
48+
echo "master"
49+
;;
50+
esac
51+
fi
2952
3053
tasks:
3154
build:

0 commit comments

Comments
 (0)