Skip to content

Commit a88d2eb

Browse files
committed
test: add 6 regression tests from real-world diffctx bug reports
1 parent 2a81a3e commit a88d2eb

19 files changed

Lines changed: 1354 additions & 0 deletions
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
argocd/apps/myapp/values.yaml: |
2+
replicaCount: 3
3+
image:
4+
repository: ghcr.io/myorg/myapp
5+
tag: main-def5678
6+
service:
7+
type: ClusterIP
8+
port: 8080
9+
ingress:
10+
enabled: true
11+
host: myapp.example.com
12+
annotations:
13+
nginx.ingress.kubernetes.io/proxy-body-size: "50m"
14+
resources:
15+
limits:
16+
cpu: "1"
17+
memory: 512Mi
18+
requests:
19+
cpu: 250m
20+
memory: 256Mi
21+
autoscaling:
22+
enabled: true
23+
minReplicas: 2
24+
maxReplicas: 5
25+
targetCPUUtilization: 80
26+
27+
argocd/apps/myapp/Chart.yaml: |
28+
apiVersion: v2
29+
name: myapp
30+
version: 0.2.0
31+
appVersion: "1.1.0"
32+
description: My application Helm chart
33+
dependencies:
34+
- name: postgresql
35+
version: "12.x.x"
36+
repository: "https://charts.bitnami.com/bitnami"
37+
condition: postgresql.enabled
38+
39+
ansible/scripts/music_consistency_checker.py: |
40+
import os
41+
from pathlib import Path
42+
from typing import List, Dict, Optional
43+
44+
def scan_library(root_path: str) -> List[Dict]:
45+
results = []
46+
for entry in Path(root_path).rglob("*.flac"):
47+
results.append({"path": str(entry), "format": "flac"})
48+
for entry in Path(root_path).rglob("*.mp3"):
49+
results.append({"path": str(entry), "format": "mp3"})
50+
return results
51+
52+
def check_metadata(file_path: str) -> Dict[str, Optional[str]]:
53+
return {
54+
"title": None,
55+
"artist": None,
56+
"album": None,
57+
"track_number": None,
58+
"genre": None,
59+
}
60+
61+
def validate_naming_convention(file_path: str) -> bool:
62+
name = Path(file_path).stem
63+
parts = name.split(" - ")
64+
return len(parts) >= 2
65+
66+
def find_duplicates(library: List[Dict]) -> List[List[Dict]]:
67+
seen = {}
68+
duplicates = []
69+
for item in library:
70+
key = Path(item["path"]).stem
71+
if key in seen:
72+
duplicates.append([seen[key], item])
73+
else:
74+
seen[key] = item
75+
return duplicates
76+
77+
def generate_report(library: List[Dict], duplicates: List[List[Dict]]) -> str:
78+
lines = [f"Total files: {len(library)}", f"Duplicates: {len(duplicates)}"]
79+
return "\n".join(lines)
80+
81+
scripts/sops-new.sh: |
82+
#!/bin/bash
83+
set -euo pipefail
84+
85+
encrypt_file() {
86+
local input_file="$1"
87+
local output_file="$2"
88+
sops --encrypt --age "$(cat ~/.sops/age-key.pub)" \
89+
--input-type yaml --output-type yaml \
90+
"$input_file" > "$output_file"
91+
}
92+
93+
decrypt_file() {
94+
local input_file="$1"
95+
sops --decrypt --input-type yaml --output-type yaml "$input_file"
96+
}
97+
98+
rotate_keys() {
99+
local file="$1"
100+
sops updatekeys -y "$file"
101+
}
102+
103+
if [[ "${1:-}" == "encrypt" ]]; then
104+
encrypt_file "${2:-}" "${3:-}"
105+
elif [[ "${1:-}" == "decrypt" ]]; then
106+
decrypt_file "${2:-}"
107+
elif [[ "${1:-}" == "rotate" ]]; then
108+
rotate_keys "${2:-}"
109+
else
110+
echo "Usage: $0 {encrypt|decrypt|rotate} [args...]"
111+
exit 1
112+
fi
113+
114+
garbage_notifier.py: |
115+
GARBAGE_ALG022_NOTIFIER_MARKER_A = "notifier"
116+
GARBAGE_ALG022_CHANNEL_MARKER_B = True
117+
118+
class SlackNotifier:
119+
GARBAGE_ALG022_SLACK_MARKER_C = "slack"
120+
121+
def send(self, channel: str, message: str) -> bool:
122+
GARBAGE_ALG022_SEND_MARKER_D = "sent"
123+
return True
124+
125+
def format_block(self, text: str) -> dict:
126+
GARBAGE_ALG022_BLOCK_MARKER_E = "block"
127+
return {"text": text}
128+
129+
garbage_health.py: |
130+
GARBAGE_ALG022_HEALTH_MARKER_F = "health"
131+
GARBAGE_ALG022_PROBE_MARKER_G = 30
132+
133+
class HealthChecker:
134+
GARBAGE_ALG022_CHECKER_MARKER_H = "checker"
135+
136+
def check_db(self) -> bool:
137+
GARBAGE_ALG022_DB_MARKER_I = "ok"
138+
return True
139+
140+
def check_redis(self) -> bool:
141+
GARBAGE_ALG022_REDIS_MARKER_J = "ok"
142+
return True
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
argocd/apps/myapp/values.yaml: |
2+
replicaCount: 2
3+
image:
4+
repository: ghcr.io/myorg/myapp
5+
tag: main-abc1234
6+
service:
7+
type: ClusterIP
8+
port: 8080
9+
ingress:
10+
enabled: true
11+
host: myapp.example.com
12+
resources:
13+
limits:
14+
cpu: 500m
15+
memory: 256Mi
16+
requests:
17+
cpu: 100m
18+
memory: 128Mi
19+
20+
argocd/apps/myapp/Chart.yaml: |
21+
apiVersion: v2
22+
name: myapp
23+
version: 0.1.0
24+
appVersion: "1.0.0"
25+
description: My application Helm chart
26+
27+
ansible/scripts/music_consistency_checker.py: |
28+
import os
29+
from pathlib import Path
30+
from typing import List, Dict, Optional
31+
32+
def scan_library(root_path: str) -> List[Dict]:
33+
results = []
34+
for entry in Path(root_path).rglob("*.flac"):
35+
results.append({"path": str(entry), "format": "flac"})
36+
for entry in Path(root_path).rglob("*.mp3"):
37+
results.append({"path": str(entry), "format": "mp3"})
38+
return results
39+
40+
def check_metadata(file_path: str) -> Dict[str, Optional[str]]:
41+
return {
42+
"title": None,
43+
"artist": None,
44+
"album": None,
45+
"track_number": None,
46+
"genre": None,
47+
}
48+
49+
def validate_naming_convention(file_path: str) -> bool:
50+
name = Path(file_path).stem
51+
parts = name.split(" - ")
52+
return len(parts) >= 2
53+
54+
def find_duplicates(library: List[Dict]) -> List[List[Dict]]:
55+
seen = {}
56+
duplicates = []
57+
for item in library:
58+
key = Path(item["path"]).stem
59+
if key in seen:
60+
duplicates.append([seen[key], item])
61+
else:
62+
seen[key] = item
63+
return duplicates
64+
65+
def generate_report(library: List[Dict], duplicates: List[List[Dict]]) -> str:
66+
lines = [f"Total files: {len(library)}", f"Duplicates: {len(duplicates)}"]
67+
return "\n".join(lines)
68+
69+
scripts/sops-new.sh: |
70+
#!/bin/bash
71+
set -euo pipefail
72+
73+
encrypt_file() {
74+
local input_file="$1"
75+
local output_file="$2"
76+
sops --encrypt --age "$(cat ~/.sops/age-key.pub)" \
77+
--input-type yaml --output-type yaml \
78+
"$input_file" > "$output_file"
79+
}
80+
81+
decrypt_file() {
82+
local input_file="$1"
83+
sops --decrypt --input-type yaml --output-type yaml "$input_file"
84+
}
85+
86+
rotate_keys() {
87+
local file="$1"
88+
sops updatekeys -y "$file"
89+
}
90+
91+
if [[ "${1:-}" == "encrypt" ]]; then
92+
encrypt_file "${2:-}" "${3:-}"
93+
elif [[ "${1:-}" == "decrypt" ]]; then
94+
decrypt_file "${2:-}"
95+
elif [[ "${1:-}" == "rotate" ]]; then
96+
rotate_keys "${2:-}"
97+
else
98+
echo "Usage: $0 {encrypt|decrypt|rotate} [args...]"
99+
exit 1
100+
fi
101+
102+
garbage_notifier.py: |
103+
GARBAGE_ALG022_NOTIFIER_MARKER_A = "notifier"
104+
GARBAGE_ALG022_CHANNEL_MARKER_B = True
105+
106+
class SlackNotifier:
107+
GARBAGE_ALG022_SLACK_MARKER_C = "slack"
108+
109+
def send(self, channel: str, message: str) -> bool:
110+
GARBAGE_ALG022_SEND_MARKER_D = "sent"
111+
return True
112+
113+
def format_block(self, text: str) -> dict:
114+
GARBAGE_ALG022_BLOCK_MARKER_E = "block"
115+
return {"text": text}
116+
117+
garbage_health.py: |
118+
GARBAGE_ALG022_HEALTH_MARKER_F = "health"
119+
GARBAGE_ALG022_PROBE_MARKER_G = 30
120+
121+
class HealthChecker:
122+
GARBAGE_ALG022_CHECKER_MARKER_H = "checker"
123+
124+
def check_db(self) -> bool:
125+
GARBAGE_ALG022_DB_MARKER_I = "ok"
126+
return True
127+
128+
def check_redis(self) -> bool:
129+
GARBAGE_ALG022_REDIS_MARKER_J = "ok"
130+
return True
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
must_include_files:
2+
- argocd/apps/myapp/values.yaml
3+
- argocd/apps/myapp/Chart.yaml
4+
must_not_include:
5+
- music_consistency_checker.py
6+
- scan_library
7+
- check_metadata
8+
- validate_naming_convention
9+
- find_duplicates
10+
- generate_report
11+
- sops-new.sh
12+
- encrypt_file
13+
- decrypt_file
14+
- rotate_keys
15+
- GARBAGE_ALG022_NOTIFIER_MARKER_A
16+
- GARBAGE_ALG022_CHANNEL_MARKER_B
17+
- GARBAGE_ALG022_SLACK_MARKER_C
18+
- GARBAGE_ALG022_SEND_MARKER_D
19+
- GARBAGE_ALG022_BLOCK_MARKER_E
20+
- GARBAGE_ALG022_HEALTH_MARKER_F
21+
- GARBAGE_ALG022_PROBE_MARKER_G
22+
- GARBAGE_ALG022_CHECKER_MARKER_H
23+
- GARBAGE_ALG022_DB_MARKER_I
24+
- GARBAGE_ALG022_REDIS_MARKER_J
25+
- garbage_notifier.py
26+
- garbage_health.py
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
.github/workflows/cd.yml: |
2+
name: CD
3+
on:
4+
push:
5+
branches: [main]
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
packages: write
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Login to GHCR
21+
uses: docker/login-action@v3
22+
with:
23+
registry: ghcr.io
24+
username: ${{ github.actor }}
25+
password: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Generate image tags
28+
id: tags
29+
run: |
30+
PRIMARY_TAG="main-$(git rev-parse --short HEAD)"
31+
echo "primary_tag=${PRIMARY_TAG}" >> "$GITHUB_OUTPUT"
32+
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v3
35+
36+
- name: Build and push
37+
uses: docker/build-push-action@v6
38+
with:
39+
context: .
40+
push: true
41+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tags.outputs.primary_tag }}
42+
build-args: |
43+
GIT_SHA=${{ steps.tags.outputs.primary_tag }}
44+
45+
pyproject.toml: |
46+
[project]
47+
name = "myapp"
48+
version = "1.0.0"
49+
requires-python = ">=3.11"
50+
51+
[project.scripts]
52+
myapp = "myapp.cli:main"
53+
54+
garbage_lint.py: |
55+
GARBAGE_CICD016_LINT_MARKER_A = "lint module"
56+
GARBAGE_CICD016_CHECK_MARKER_B = True
57+
58+
class LintRunner:
59+
GARBAGE_CICD016_RUNNER_MARKER_C = "runner"
60+
61+
def run_checks(self, path: str) -> bool:
62+
GARBAGE_CICD016_RESULT_MARKER_D = "passed"
63+
return True
64+
65+
def format_report(self, results: list) -> str:
66+
GARBAGE_CICD016_REPORT_MARKER_E = "report"
67+
return ""
68+
69+
garbage_migrate.py: |
70+
GARBAGE_CICD016_MIGRATE_MARKER_F = "migrate module"
71+
GARBAGE_CICD016_SCHEMA_MARKER_G = 42
72+
73+
class MigrationRunner:
74+
GARBAGE_CICD016_MIGRATION_MARKER_H = "migration"
75+
76+
def apply(self, version: int) -> None:
77+
GARBAGE_CICD016_APPLY_MARKER_I = "applied"
78+
pass
79+
80+
def rollback(self, version: int) -> None:
81+
GARBAGE_CICD016_ROLLBACK_MARKER_J = "rolled back"
82+
pass

0 commit comments

Comments
 (0)