Skip to content

Commit 5cc3ea3

Browse files
Gen-AI Module -> main
Gen-AI Module -> main. ## Overall new features - Search bar with debounced queries and cascader filters - Automated PR summarization via AI agent - Hardened testing around data fetching and pagination - Additional coverage for modal open/submit flows - repo workflows for CI/CD
2 parents eeb542a + f1bb32c commit 5cc3ea3

File tree

78 files changed

+6172
-21137
lines changed

Some content is hidden

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

78 files changed

+6172
-21137
lines changed
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
name: PR AI Summary
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
11+
jobs:
12+
summarize:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Get PR diff
19+
id: diff
20+
run: |
21+
BASE="${{ github.event.pull_request.base.sha }}"
22+
HEAD="${{ github.event.pull_request.head.sha }}"
23+
# Trae exactamente esos commits (evita problemas de merge-base y shallow clones)
24+
git fetch --no-tags --prune --depth=1 origin $BASE $HEAD
25+
git diff $BASE $HEAD > pr.diff
26+
echo "path=pr.diff" >> $GITHUB_OUTPUT
27+
28+
- name: Set up Python
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: '3.11'
32+
33+
- name: Install deps
34+
run: |
35+
python -m pip install --upgrade pip
36+
pip install openai==1.* # SDK oficial
37+
38+
- name: Generate AI summary (OpenAI)
39+
id: ai
40+
continue-on-error: true
41+
env:
42+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
43+
MODEL: gpt-4o-mini
44+
run: |
45+
python - << 'PY'
46+
import os
47+
from openai import OpenAI
48+
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
49+
50+
with open("pr.diff","r",encoding="utf-8") as f:
51+
diff = f.read()[:200000] # tope por costos/ruido
52+
53+
prompt = (
54+
"You are a code reviewer. Summarize this PR in 2-20 bullets. "
55+
"Include WHAT changed, WHY it matters, RISKS, TESTS to add, and any BREAKING CHANGES. "
56+
"Highlight key features or changes. Consider markdown as the default output format."
57+
"Keep in mind the following points:"
58+
"1) If DIFF shows only documentation files (e.g., .md/.mdx/.txt/README), state 'Docs-only change', "
59+
" make clear that the change is included only in documentation files, if that is the case, "
60+
" otherwise explain normally, considering the DIFF changes like normal. "
61+
"2) Include a short list of changed file paths as extracted from DIFF. "
62+
"Keep it concise and actionable.\n\nDIFF:\n" + diff
63+
)
64+
65+
resp = client.chat.completions.create(
66+
model=os.getenv("MODEL","gpt-4o-mini"),
67+
temperature=0.2,
68+
messages=[{"role":"user","content":prompt}],
69+
)
70+
text = resp.choices[0].message.content.strip()
71+
with open("summary.txt","w",encoding="utf-8") as f:
72+
f.write(text)
73+
PY
74+
75+
- name: Heuristic fallback if AI failed
76+
if: ${{ steps.ai.outcome == 'failure' }}
77+
run: |
78+
python - << 'PY'
79+
import re, pathlib
80+
diff = pathlib.Path("pr.diff").read_text(encoding="utf-8")
81+
82+
added = len(re.findall(r"^\\+[^+].*$", diff, flags=re.M))
83+
removed = len(re.findall(r"^\\-[^-].*$", diff, flags=re.M))
84+
files = re.findall(r"^\\+\\+\\+ b/(.+)$", diff, flags=re.M)
85+
86+
lower_paths = [f.lower() for f in files]
87+
DOC_EXT = (".md", ".mdx", ".txt", ".rst", ".adoc")
88+
is_doc = lambda p: p.endswith(DOC_EXT) or "/docs/" in p or "/doc/" in p
89+
docs_only = len(files) > 0 and all(is_doc(p) for p in lower_paths)
90+
91+
# ---------- Doc-only summary ----------
92+
if docs_only:
93+
bullets_changed = []
94+
for f in files[:20]: # evita listas enormes
95+
bullets_changed.append(f"- `{f}`")
96+
doc_summary = [
97+
"## PR Summary",
98+
"",
99+
"### WHAT Changed",
100+
"- **Docs-only change** detected from DIFF.",
101+
f"- Files changed ({len(files)}):",
102+
*bullets_changed,
103+
"",
104+
"### WHY It Matters",
105+
"- Improves documentation/README clarity and onboarding experience.",
106+
"",
107+
"### RISKS",
108+
"- None to runtime behavior (documentation only).",
109+
"",
110+
"### TESTS to Add",
111+
"- N/A (no code changes).",
112+
"",
113+
"### BREAKING CHANGES",
114+
"- None.",
115+
]
116+
pathlib.Path("summary.txt").write_text("\n".join(doc_summary), encoding="utf-8")
117+
raise SystemExit(0)
118+
119+
scopes = set()
120+
for f in files:
121+
fl = f.lower()
122+
if "/controller" in fl: scopes.add("controller")
123+
elif "/service" in fl: scopes.add("service")
124+
elif "/repository" in fl or "jparepository" in diff.lower(): scopes.add("repository")
125+
elif "/entity" in fl or "/model" in fl: scopes.add("entity")
126+
elif "application" in fl and (fl.endswith(".yml") or fl.endswith(".yaml") or fl.endswith(".properties")):
127+
scopes.add("config")
128+
elif fl.endswith("test.java"): scopes.add("test")
129+
130+
scope = ",".join(sorted(scopes)) if scopes else "core"
131+
kind = "refactor"
132+
if added and not removed: kind = "feat"
133+
if removed and not added: kind = "chore"
134+
if re.search(r"@Test", diff): kind = "test"
135+
if re.search(r"fix|bug|exception|stacktrace", diff, re.I): kind = "fix"
136+
137+
subject = f"[Fallback] {kind}({scope}): {len(files)} file(s), +{added}/-{removed}"
138+
139+
bullets = []
140+
bullets.append(f"- Files changed: {len(files)}")
141+
bullets.append(f"- Lines: +{added} / -{removed}")
142+
if scopes:
143+
bullets.append(f"- Layers: {', '.join(sorted(scopes))}")
144+
if re.search(r"@Transactional", diff): bullets.append("- Touches transactional boundaries")
145+
if re.search(r"@RestController|@Controller", diff): bullets.append("- Controller changes present")
146+
if re.search(r"@Service", diff): bullets.append("- Service-layer changes present")
147+
if re.search(r"@Repository|JpaRepository", diff): bullets.append("- Repository-layer changes present")
148+
if re.search(r"todo|fixme", diff, re.I): bullets.append("- Contains TODO/FIXME markers")
149+
150+
text = subject + "\\n\\n" + "\\n".join(bullets)
151+
pathlib.Path("summary.txt").write_text(text, encoding="utf-8")
152+
PY
153+
154+
- name: Comment on PR
155+
uses: marocchino/sticky-pull-request-comment@v2
156+
with:
157+
header: ai-pr-summary
158+
recreate: true
159+
path: summary.txt

.github/workflows/build.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
working-directory: inventory-manager
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: 20
21+
cache: npm
22+
cache-dependency-path: inventory-manager/package-lock.json
23+
- run: npm ci
24+
- run: npm run build
25+
- uses: actions/upload-artifact@v4
26+
with:
27+
name: dist
28+
path: dist

.github/workflows/pre-release.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: pre-release
2+
3+
on:
4+
push:
5+
branches: [ stage ]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
nightly:
12+
runs-on: ubuntu-latest
13+
defaults:
14+
run:
15+
working-directory: inventory-manager
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-node@v4
19+
with:
20+
node-version: 20
21+
cache: npm
22+
cache-dependency-path: inventory-manager/package-lock.json
23+
- run: npm ci
24+
- run: npm run build
25+
- run: zip -r dist-nightly.zip dist
26+
- uses: ncipollo/release-action@v1
27+
with:
28+
tag: nightly
29+
name: Nightly
30+
prerelease: true
31+
allowUpdates: true
32+
replacesArtifacts: true
33+
artifacts: dist-nightly.zip

README.md

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
The system allows creating, updating, filtering, and sorting products,
55
as well as tracking key metrics like total stock, inventory value, and average price.
66

7-
The project was built with a focus on usability, clear data visualization,
8-
responsiveness and its supposed to be bug free. It supports pagination,
9-
search filters, product availability toggling, and sorting by multiple columns.
7+
The project was built with a focus of usability, clear data visualization and
8+
responsiveness, for an easy convenience store inventory management (and It's supposed to be bug free).
9+
It supports pagination, search filters, product availability toggling, and sorting by multiple columns.
1010

1111
## Tech Stack
1212

@@ -16,21 +16,7 @@ search filters, product availability toggling, and sorting by multiple columns.
1616
- **Backend:** REST API with CRUD and stock control endpoints
1717
[InventoryManagerBS](https://github.com/technologic-technologic/InventoryManagerBS.git)
1818

19-
## Features
20-
21-
- **Product CRUD**
22-
23-
- **Filtering & Searching**
24-
25-
- **Sorting**
26-
27-
- **Stock Management**
28-
29-
- **Inventory Metrics**
30-
31-
- **Pagination**
32-
33-
## Backend API (Expected)
19+
## Backend API (Expected communications)
3420

3521
Business service git URL: https://github.com/technologic-technologic/InventoryManagerBS.git
3622

@@ -49,16 +35,20 @@ The frontend expects the following API endpoints:
4935

5036
To run the frontend locally:
5137

38+
```bash
39+
# go to directory from repo location
40+
cd inventory-manager
41+
```
5242
```bash
5343
# Install dependencies
5444
npm install
5545
```
5646
```bash
5747
# Run the app on port 8080
58-
npm start
48+
npm run dev
5949
```
6050

6151
```bash
62-
# Run all tests
63-
npm test
52+
# Run tests manually
53+
npm run test
6454
```

documentation/documentation.docx

-43.8 KB
Binary file not shown.

inventory-manager/.gitignore

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1-
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2-
3-
# dependencies
4-
/node_modules
5-
/.pnp
6-
.pnp.js
7-
8-
# testing
9-
/coverage
10-
11-
# production
12-
/build
13-
14-
# misc
15-
.DS_Store
16-
.env.local
17-
.env.development.local
18-
.env.test.local
19-
.env.production.local
20-
1+
# Logs
2+
logs
3+
*.log
214
npm-debug.log*
225
yarn-debug.log*
236
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.idea/*
20+
.idea/
21+
.idea/**
22+
.DS_Store
23+
*.suo
24+
*.ntvs*
25+
*.njsproj
26+
*.sln
27+
*.sw?

0 commit comments

Comments
 (0)