Skip to content

Commit 522d185

Browse files
authored
Merge pull request #4 from grove-platform/refactor/cursor-recs
Refactor: upgrade deps, improve reliability, update docs and tooling
2 parents f7bd4ad + 814be1e commit 522d185

109 files changed

Lines changed: 10152 additions & 5097 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.copier/main-test.yaml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Main Configuration File for the Dev Docs Copier App
2+
# This is the central config file that references individual workflow configs
3+
# Specified in app's env.yaml as MAIN_CONFIG_FILE
4+
5+
# ============================================================================
6+
# GLOBAL DEFAULTS
7+
# ============================================================================
8+
# These defaults apply to all workflows across all workflow config files
9+
# unless overridden at the workflow config level or individual workflow level
10+
11+
defaults:
12+
commit_strategy:
13+
type: "pull_request"
14+
auto_merge: false
15+
deprecation_check:
16+
enabled: true
17+
file: "deprecated_examples.json"
18+
19+
# ============================================================================
20+
# WORKFLOW CONFIG REFERENCES
21+
# ============================================================================
22+
# App will auto-discover installation ID for source repo, then fetch the workflow config
23+
24+
workflow_configs:
25+
26+
# --------------------------------------------------------------------------
27+
# SAMPLE APPS
28+
# --------------------------------------------------------------------------
29+
- source: "repo"
30+
repo: "mongodb/docs-sample-apps"
31+
branch: "main" # optional, defaults to main
32+
path: ".copier/config.yaml"
33+
enabled: true
34+
35+
# --------------------------------------------------------------------------
36+
# MONOREPO
37+
# --------------------------------------------------------------------------
38+
- source: "repo"
39+
repo: "10gen/docs-mongodb-internal"
40+
branch: "main"
41+
path: ".copier/config.yaml"
42+
enabled: true
43+
44+
# --------------------------------------------------------------------------
45+
# DOCS CODE EXAMPLES (DISABLED)
46+
# --------------------------------------------------------------------------
47+
- source: "repo"
48+
repo: "mongodb/docs-code-examples"
49+
branch: "main"
50+
path: ".copier/config.yaml"
51+
enabled: false
52+
53+
# --------------------------------------------------------------------------
54+
# ** TESTING **
55+
# --------------------------------------------------------------------------
56+
- source: "repo"
57+
repo: "cbullinger/aggregation-tasks"
58+
branch: "main"
59+
path: "copier-config.yaml"
60+
enabled: true
61+
62+
- source: "repo"
63+
repo: "cbullinger/copier-app-source-test"
64+
branch: "main"
65+
path: ".copier/test-main.yaml"
66+
enabled: true

.cursorignore

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Git
2+
.git/
3+
4+
# Binaries
5+
github-copier
6+
code-copier
7+
copier
8+
config-validator
9+
test-webhook
10+
test-pem
11+
*.exe
12+
*.dll
13+
*.so
14+
*.dylib
15+
*.test
16+
17+
# Dependencies
18+
vendor/
19+
go.sum
20+
21+
# Build/Coverage output
22+
*.out
23+
24+
# Environment files (secrets)
25+
.env
26+
.env.*
27+
!.env.test
28+
29+
# Private keys
30+
*.pem
31+
*.key
32+
33+
# IDE
34+
.idea/
35+
.vscode/
36+
*.swp
37+
*.swo
38+
*~
39+
40+
# OS files
41+
.DS_Store
42+
Thumbs.db
43+
44+
# Logs and temp
45+
*.log
46+
tmp/
47+
temp/
48+
49+
# Large test fixtures (JSON payloads)
50+
testdata/*.json

.github/workflows/ci.yml

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: CI
33
on:
44
push:
55
branches: [main]
6+
tags: ['v*']
67
pull_request:
78
branches: [main]
89

@@ -14,15 +15,13 @@ jobs:
1415

1516
- uses: actions/setup-go@v5
1617
with:
17-
go-version: '1.24'
18+
go-version: '1.26'
1819

1920
- name: Download dependencies
2021
run: go mod download
2122

2223
- name: Run tests
23-
# Note: -race disabled due to pre-existing race conditions in tests that spawn
24-
# background goroutines. These should be fixed by adding proper synchronization.
25-
run: go test -v ./...
24+
run: go test -race -v ./...
2625

2726
lint:
2827
runs-on: ubuntu-latest
@@ -31,12 +30,12 @@ jobs:
3130

3231
- uses: actions/setup-go@v5
3332
with:
34-
go-version: '1.24'
33+
go-version: '1.26'
3534

3635
- name: golangci-lint
37-
uses: golangci/golangci-lint-action@v6
36+
uses: golangci/golangci-lint-action@v7
3837
with:
39-
version: latest
38+
version: v2.9.0
4039

4140
security:
4241
runs-on: ubuntu-latest
@@ -45,16 +44,15 @@ jobs:
4544

4645
- uses: actions/setup-go@v5
4746
with:
48-
go-version: '1.24'
47+
go-version: '1.26'
48+
49+
- name: Install gosec
50+
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
4951

5052
- name: Run gosec
51-
uses: securego/gosec@master
52-
with:
53-
# Exclude G101 (hardcoded credentials - false positive on env var names)
54-
# Exclude G115 (integer overflow - false positive for PR numbers)
55-
# Exclude G304 (file inclusion - intentional for CLI tools)
56-
# Exclude G306 (file permissions - config files don't need 0600)
57-
args: -exclude=G101,G115,G304,G306 ./...
53+
# All false positives are suppressed with inline #nosec comments.
54+
# No global exclusions — every suppression is documented at the call site.
55+
run: gosec ./...
5856

5957
build:
6058
runs-on: ubuntu-latest
@@ -64,16 +62,34 @@ jobs:
6462

6563
- uses: actions/setup-go@v5
6664
with:
67-
go-version: '1.24'
65+
go-version: '1.26'
6866

6967
- name: Build
7068
run: go build -v ./...
7169

70+
scan:
71+
runs-on: ubuntu-latest
72+
needs: [build]
73+
steps:
74+
- uses: actions/checkout@v4
75+
76+
- name: Run Trivy vulnerability scanner
77+
uses: aquasecurity/trivy-action@master
78+
with:
79+
scan-type: 'fs'
80+
scan-ref: '.'
81+
severity: 'CRITICAL,HIGH'
82+
exit-code: '1'
83+
7284
deploy:
7385
runs-on: ubuntu-latest
74-
needs: [build, security]
75-
# Only deploy on push to main (not on PRs)
76-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
86+
needs: [build, security, scan]
87+
# Only deploy on version tag pushes (e.g. v1.0.0)
88+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
89+
90+
environment:
91+
name: production
92+
url: ${{ steps.show-url.outputs.url }}
7793

7894
permissions:
7995
contents: read
@@ -87,6 +103,10 @@ jobs:
87103
steps:
88104
- uses: actions/checkout@v4
89105

106+
- name: Extract version from tag
107+
id: version
108+
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
109+
90110
- name: Authenticate to Google Cloud
91111
uses: google-github-actions/auth@v2
92112
with:
@@ -104,6 +124,9 @@ jobs:
104124
--project $PROJECT_ID \
105125
--allow-unauthenticated \
106126
--env-vars-file=env-cloudrun.yaml \
127+
--set-env-vars="GITHUB_APP_ID=${{ secrets.GITHUB_APP_ID }},INSTALLATION_ID=${{ secrets.INSTALLATION_ID }}" \
128+
--build-arg="VERSION=${{ steps.version.outputs.tag }}" \
129+
--tag="${{ steps.version.outputs.tag }}" \
107130
--max-instances=10 \
108131
--cpu=1 \
109132
--memory=512Mi \
@@ -113,10 +136,11 @@ jobs:
113136
--platform=managed
114137
115138
- name: Show deployment URL
139+
id: show-url
116140
run: |
117141
URL=$(gcloud run services describe $SERVICE_NAME \
118142
--region $REGION \
119143
--project $PROJECT_ID \
120144
--format='value(status.url)')
121-
echo "🚀 Deployed to: $URL"
122-
145+
echo "url=$URL" >> $GITHUB_OUTPUT
146+
echo "Deployed ${{ steps.version.outputs.tag }} to: $URL"

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
github-copier
33
code-copier
44
copier
5+
config-validator
6+
test-webhook
7+
test-pem
58
*.exe
69
*.exe~
710
*.dll
@@ -60,4 +63,3 @@ Thumbs.db
6063
# Temporary files
6164
tmp/
6265
temp/
63-
RECOMMENDATIONS.md

.gitleaksignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Example placeholder string in .env.local.example (not a real key)
2+
configs/.env.local.example:private-key:77
3+
4+
# Purpose-generated test-only PEM key in .env.test (never associated with a real GitHub App)
5+
.env.test:private-key:30

.golangci.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# golangci-lint v2 configuration
2+
# Matches CI (golangci-lint v2.9.0) and local pre-commit.
3+
# Docs: https://golangci-lint.run/usage/configuration/
4+
version: "2"
5+
6+
linters:
7+
default: none
8+
enable:
9+
# Bug detection (default set)
10+
- errcheck # unchecked errors
11+
- govet # suspicious constructs
12+
- ineffassign # unused assignments
13+
- staticcheck # advanced static analysis (includes gosimple)
14+
- unused # unused code
15+
16+
# Style & quality
17+
- misspell # common typos in comments/strings
18+
- revive # extensible linter (replaces golint)
19+
20+
settings:
21+
errcheck:
22+
# Ignore intentionally discarded errors in defer cleanup.
23+
# All such cases use the _ = expr pattern for explicitness.
24+
exclude-functions:
25+
- (io.Closer).Close
26+
27+
revive:
28+
rules:
29+
- name: exported
30+
disabled: true # too noisy for internal-only code
31+
32+
staticcheck:
33+
checks:
34+
- "all"
35+
- "-SA1029" # context.WithValue key type — acceptable for request-scoped data
36+
- "-ST1000" # package comments — not enforced for this project
37+
- "-ST1003" # naming conventions — existing codebase uses mixed styles
38+
39+
# In golangci-lint v2, exclusion rules live under linters.exclusions (not issues).
40+
exclusions:
41+
rules:
42+
# Test files: allow dot-imports and unused parameters.
43+
- path: _test\.go
44+
linters:
45+
- revive
46+
text: "dot-imports|unused-parameter"
47+
48+
formatters:
49+
enable:
50+
- gofmt
51+
- goimports
52+
53+
issues:
54+
# Don't limit the number of reported issues per linter.
55+
max-issues-per-linter: 0
56+
max-same-issues: 0

.pre-commit-config.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@ repos:
55
hooks:
66
- id: gitleaks
77

8-
# Go linting
9-
- repo: https://github.com/golangci/golangci-lint
10-
rev: v1.62.2
8+
# Go linting - requires golangci-lint v2 installed locally:
9+
# go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.9.0
10+
- repo: local
1111
hooks:
1212
- id: golangci-lint
13+
name: golangci-lint
14+
entry: golangci-lint run --fix
15+
language: system
16+
pass_filenames: false
17+
types: [go]
1318

1419
# Local Go hooks
1520
- repo: local

0 commit comments

Comments
 (0)