Skip to content

Commit 823f607

Browse files
authored
Merge pull request #144 from IBM/linting-all
Updating go build and pre-commit, linting
2 parents c4eeae6 + 0437786 commit 823f607

File tree

17 files changed

+926
-62
lines changed

17 files changed

+926
-62
lines changed

.github/workflows/docker-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ jobs:
7676
# ----------------------------------------------------------------
7777
- name: ✅ Verify commit checks passed
7878
env:
79-
SHA: ${{ steps.meta.outputs.sha }}
80-
REPO: ${{ github.repository }}
79+
SHA: ${{ steps.meta.outputs.sha }}
80+
REPO: ${{ github.repository }}
8181
run: |
8282
set -euo pipefail
8383
STATUS=$(curl -sSL \

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
tmp
12
*.tgz
23
*.gz
34
*.bz

.pre-commit-config.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
# pip install --user --upgrade pre-commit
99
# pre-commit install
1010
# pre-commit run --all-files
11+
# Update:
12+
# pre-commit autoupdate
1113
#
1214
# To skip pre-commit checks:
1315
# git commit -m "Your message" --no-verify
@@ -16,12 +18,14 @@
1618
# report issues (linters). Modified files will need to be staged again.
1719
# -----------------------------------------------------------------------------
1820

21+
exclude: '(^|/)\.pre-commit-config\.yaml$' # ← ignore this file wherever it is
22+
1923
repos:
2024
# -----------------------------------------------------------------------------
2125
# 🔐 Security and Secret Detection Hooks
2226
# -----------------------------------------------------------------------------
2327
- repo: https://github.com/gitleaks/gitleaks
24-
rev: v8.27.0
28+
rev: v8.27.2
2529
hooks:
2630
- id: gitleaks
2731
name: 🔐 Gitleaks - Detect hardcoded secrets
@@ -89,7 +93,7 @@ repos:
8993
- id: forbid-ai-stock-phrases
9094
name: ❌ Forbid AI Stock Phrases
9195
description: Prevents common AI-generated phrases from being committed.
92-
entry: '(?i)(source=chatgpt.com|turn0search0|filecite|unchanged|as an ai language model|i am an ai developed by|this response was generated by|i don''t have real-time information|i don''t have access to real-time|i can''t browse the internet|i cannot browse the internet|my knowledge cutoff|my training data|i''m not able to access|i don''t have the ability to)'
96+
entry: '(?i)(brevity|source=chatgpt.com|turn0search0|filecite|unchanged|as an ai language model|i am an ai developed by|this response was generated by|i don''t have real-time information|i don''t have access to real-time|i can''t browse the internet|i cannot browse the internet|my knowledge cutoff|my training data|i''m not able to access|i don''t have the ability to)'
9397
language: pygrep
9498
types: [text]
9599
exclude: ^\.pre-commit-config\.yaml$
@@ -125,7 +129,7 @@ repos:
125129
- id: warn-ai-transitions
126130
name: ⚠️ Warn AI Transition Phrases
127131
description: Warns about common AI transition phrases (non-blocking).
128-
entry: '(?i)(in conclusion,|to summarize,|it is important to note that|remember that|keep in mind that|it''s worth noting that|please note that)'
132+
entry: '(?i)(brevity|in conclusion,|to summarize,|it is important to note that|remember that|keep in mind that|it''s worth noting that|please note that)'
129133
language: pygrep
130134
types: [text]
131135
verbose: true

.yamllint

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ rules:
77
# Ignore every YAML (and *.tpl) file under the Helm chart directory.
88
ignore: |
99
charts/mcp-stack/**/*.yaml
10-
charts/mcp-stack/**/*.tpl # if you template using .tpl files
10+
charts/mcp-stack/**/*.tpl # templates using .tpl files
1111
charts/mcp-stack/**/values.yaml
1212
charts/mcp-stack/**/Chart.yaml
13+
charts/mcpgateway/templates/*.yaml
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# IBM Cloud
2-
region: eu-gb
3-
prefix: mcpgw
4-
k8s_workers: 1
5-
cluster_flavor: bx2.4x16
6-
kube_version: "1.29"
2+
region: eu-gb
3+
prefix: mcpgw
4+
k8s_workers: 1
5+
cluster_flavor: bx2.4x16
6+
kube_version: "1.29"
77

88
# Databases
99
postgres_version: "14"
10-
redis_version: "7"
10+
redis_version: "7"
1111

1212
# Application
13-
gateway_image: "ghcr.io/ibm/mcp-context-forge:v0.1.1"
13+
gateway_image: "ghcr.io/ibm/mcp-context-forge:v0.1.1"
1414
gateway_replicas: 2
15-
ingress_class: public-iks-k8s-nginx
15+
ingress_class: public-iks-k8s-nginx

deployment/ansible/ibm-cloud/roles/ibm_cloud/tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
# 5️⃣ Convenience facts for later templates
5959
- name: Extract DB connection strings
6060
set_fact:
61-
pg_conn: "{{ pg_key.resource.connection[0].postgres.composed[0] }}"
61+
pg_conn: "{{ pg_key.resource.connection[0].postgres.composed[0] }}"
6262
redis_conn: "{{ redis_key.resource.connection[0].rediss.composed[0] }}"
6363

6464
# 6️⃣ Fetch kubeconfig (CLI) — simplest universal path
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,33 @@
11
fast-time-server
2+
dist
3+
dist/
4+
5+
# Binaries for programs and plugins
6+
*.exe
7+
*.exe~
8+
*.dll
9+
*.so
10+
*.dylib
11+
12+
# Test binary, built with `go test -c`
13+
*.test
14+
15+
# Code coverage profiles and other test artifacts
16+
*.out
17+
coverage.*
18+
*.coverprofile
19+
profile.cov
20+
21+
# Dependency directories (remove the comment below to include it)
22+
# vendor/
23+
24+
# Go workspace file
25+
go.work
26+
go.work.sum
27+
28+
# env file
29+
.env
30+
31+
# Editor/IDE
32+
# .idea/
33+
# .vscode/
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
run:
2+
timeout: 3m
3+
4+
linters:
5+
enable:
6+
- govet
7+
- staticcheck
8+
- revive
9+
- ineffassign
10+
- gofmt
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
# =============================================================================
2+
# 🛠️ PRE-COMMIT CONFIG - FAST-TIME-SERVER (Go project)
3+
# =============================================================================
4+
# Install / run:
5+
# pip install --user pre-commit
6+
# pre-commit install
7+
# pre-commit run --all-files
8+
#
9+
# To skip checks:
10+
# git commit -m "msg" --no-verify
11+
#
12+
# To update:
13+
# pre-commit autoupdate # optional: bumps other hooks to latest pinned tags
14+
# pre-commit install # (re-installs the git hook if needed)
15+
# pre-commit run --all-files
16+
# =============================================================================
17+
18+
repos:
19+
# ---------------------------------------------------------------------------
20+
# 🔐 Security / secret detection
21+
# ---------------------------------------------------------------------------
22+
- repo: https://github.com/gitleaks/gitleaks
23+
rev: v8.27.2
24+
hooks:
25+
- id: gitleaks
26+
name: 🔐 Gitleaks - Detect hard-coded secrets
27+
28+
- repo: https://github.com/pre-commit/pre-commit-hooks
29+
rev: v5.0.0
30+
hooks:
31+
- id: detect-private-key
32+
name: 🔐 Detect Private Key
33+
types: [text]
34+
35+
# ---------------------------------------------------------------------------
36+
# ❌ AI artefact & placeholder blockers
37+
# ---------------------------------------------------------------------------
38+
- repo: local
39+
hooks:
40+
- id: forbid-content-reference
41+
name: ❌ Forbid :contentReference
42+
entry: ":contentReference"
43+
language: pygrep
44+
types: [text]
45+
exclude: ^\.pre-commit-config\.yaml$
46+
47+
- id: forbid-oai-citations
48+
name: ❌ Forbid OpenAI Citations
49+
entry: '\[oaicite:\?\?\d+\]'
50+
language: pygrep
51+
types: [text]
52+
exclude: ^\.pre-commit-config\.yaml$
53+
54+
- id: forbid-ai-stock-phrases
55+
name: ❌ Forbid AI Stock Phrases
56+
entry: "(?i)(source=chatgpt.com|turn0search0|brevity| filecite|unchanged|as an ai language model|i am an ai developed by|this response was generated by|i don't have real-time information|i don't have access to real-time|i can't browse the internet|i cannot browse the internet|my knowledge cutoff|my training data|i'm not able to access|i don't have the ability to)"
57+
language: pygrep
58+
types: [text]
59+
exclude: ^\.pre-commit-config\.yaml$
60+
61+
- id: forbid-placeholder-citations
62+
name: ❌ Forbid Placeholder Citations
63+
entry: '\([A-Z][a-z]+,?\s+\d{4}\)'
64+
language: pygrep
65+
types: [text]
66+
exclude: ^\.pre-commit-config\.yaml$
67+
68+
- id: forbid-source-placeholders
69+
name: ❌ Forbid Source Placeholders
70+
entry: '(?i)\(source:'
71+
language: pygrep
72+
types: [text]
73+
exclude: ^\.pre-commit-config\.yaml$
74+
75+
- id: forbid-malformed-code-fences
76+
name: ❌ Forbid Malformed Code Fences
77+
entry: "````+"
78+
language: pygrep
79+
types: [text]
80+
exclude: ^\.pre-commit-config\.yaml$
81+
82+
- id: warn-ai-transitions
83+
name: ⚠️ Warn AI Transition Phrases
84+
entry: "(?i)(brevity|in conclusion,|to summarize,|it is important to note that|remember that|keep in mind that|it's worth noting that|please note that)"
85+
language: pygrep
86+
types: [text]
87+
verbose: true
88+
exclude: ^\.pre-commit-config\.yaml$
89+
90+
# ---------------------------------------------------------------------------
91+
# 🔤 Unicode text normalisation (smart-quotes, ligatures, exotic spaces)
92+
# ---------------------------------------------------------------------------
93+
- repo: https://github.com/sirosen/texthooks
94+
rev: 0.6.8
95+
hooks:
96+
- id: fix-smartquotes
97+
name: 📝 Normalize Smart Quotes
98+
- id: fix-ligatures
99+
name: 🔡 Normalize Ligatures
100+
- id: fix-spaces
101+
name: ␣ Normalize Unicode Spaces
102+
- id: forbid-bidi-controls
103+
name: 🚫 Forbid BiDi Unicode Controls
104+
105+
# ---------------------------------------------------------------------------
106+
# 🧹 Generic formatting & whitespace
107+
# ---------------------------------------------------------------------------
108+
- repo: https://github.com/pre-commit/pre-commit-hooks
109+
rev: v5.0.0
110+
hooks:
111+
- id: end-of-file-fixer
112+
name: 🧹 Fix End of Files
113+
stages: [pre-commit, pre-push, manual]
114+
115+
- id: trailing-whitespace
116+
name: 🧹 Trim Trailing Whitespace
117+
stages: [pre-commit, pre-push, manual]
118+
119+
- id: fix-byte-order-marker
120+
name: 🧹 Fix UTF-8 BOM
121+
122+
- id: mixed-line-ending
123+
name: 🧹 Mixed Line Ending
124+
args: [--fix=lf]
125+
126+
# size / merge / symlink checks
127+
- id: check-added-large-files
128+
- id: check-case-conflict
129+
- id: check-merge-conflict
130+
- id: check-symlinks
131+
- id: destroyed-symlinks
132+
- id: check-executables-have-shebangs
133+
- id: check-shebang-scripts-are-executable
134+
- id: forbid-new-submodules
135+
- id: check-json
136+
- id: check-yaml
137+
- id: check-toml
138+
- id: check-xml
139+
- id: check-byte-order-marker
140+
141+
# YAML linter
142+
- repo: https://github.com/adrienverge/yamllint
143+
rev: v1.37.1
144+
hooks:
145+
- id: yamllint
146+
name: ✅ yamllint
147+
args: [-c, .yamllint]
148+
files: ^.*\.(yml|yaml)$
149+
exclude: ^charts/
150+
151+
# CRLF / tab remover
152+
- repo: https://github.com/Lucas-C/pre-commit-hooks
153+
rev: v1.5.5
154+
hooks:
155+
- id: remove-crlf
156+
name: 🚀 Remove CRLF
157+
- id: remove-tabs
158+
name: 🚀 Remove Tabs
159+
exclude: '(^|/)Makefile$|\.mk$'
160+
161+
# ---------------------------------------------------------------------------
162+
# 🐹 Go tool-chain (formatters + linters)
163+
# ---------------------------------------------------------------------------
164+
- repo: https://github.com/dnephin/pre-commit-golang
165+
rev: v0.5.1
166+
hooks:
167+
# Formatters
168+
- id: go-fmt
169+
- id: go-imports
170+
# Vet / lints
171+
- id: go-vet
172+
- id: golangci-lint
173+
- id: go-lint # deprecated but kept here intentionally
174+
- id: go-critic
175+
# Complexity / metrics
176+
- id: go-cyclo
177+
args: ['-over=15']
178+
# Build & test
179+
- id: go-build
180+
- id: go-unit-tests
181+
# Module hygiene
182+
- id: go-mod-tidy
183+
# Misc checks
184+
- id: validate-toml
185+
- id: no-go-testing
186+
187+
- repo: https://github.com/segmentio/golines
188+
rev: v0.12.2
189+
hooks:
190+
- id: golines
191+
name: 🧹 golines - wrap long lines
192+
args: ["--max-len=120", "--base-formatter=gofumpt"]
193+
194+
# ---------------------------------------------------------------------------
195+
# 📝 OPTIONAL / web / extras (commented-out, keep for future)
196+
# ---------------------------------------------------------------------------
197+
#
198+
# - repo: https://github.com/pre-commit/mirrors-prettier
199+
# rev: v3.0.3
200+
# hooks:
201+
# - id: prettier
202+
#
203+
# - repo: https://github.com/igorshubovych/markdownlint-cli
204+
# rev: v0.45.0
205+
# hooks:
206+
# - id: markdownlint
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# =============================================================================
2+
# 🦫 FAST-TIME-SERVER – Multi-stage Containerfile
3+
# =============================================================================
4+
#
5+
# Default runtime = DUAL transport → SSE (/sse, /messages)
6+
# → HTTP (/http) on port 8080
7+
#
8+
# Build: docker build -t fast-time-server:latest --build-arg VERSION=$(git rev-parse --short HEAD) .
9+
# Run : docker run --rm -p 8080:8080 fast-time-server:latest
10+
# # now visit http://localhost:8080/sse or http://localhost:8080/http
11+
# =============================================================================
12+
13+
# =============================================================================
14+
# 🏗️ STAGE 1 – BUILD STATIC BINARY (Go 1.23, CGO disabled)
15+
# =============================================================================
16+
FROM --platform=$TARGETPLATFORM golang:1.23 AS builder
17+
18+
WORKDIR /src
19+
COPY go.mod go.sum ./
20+
RUN go mod download
21+
COPY . .
22+
23+
ARG VERSION=dev
24+
25+
RUN CGO_ENABLED=0 GOOS=linux go build \
26+
-trimpath \
27+
-ldflags "-s -w -X 'main.appVersion=${VERSION}'" \
28+
-o /usr/local/bin/fast-time-server .
29+
30+
# =============================================================================
31+
# 📦 STAGE 2 – MINIMAL RUNTIME (scratch + tzdata + binary)
32+
# =============================================================================
33+
FROM scratch
34+
35+
# copy tzdata so time.LoadLocation works
36+
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
37+
38+
# copy binary
39+
COPY --from=builder /usr/local/bin/fast-time-server /fast-time-server
40+
41+
# --- default: SSE + HTTP on 8080 ---
42+
ENTRYPOINT ["/fast-time-server"]
43+
CMD ["-transport=dual", "-port=8080", "-listen=0.0.0.0"]

0 commit comments

Comments
 (0)