Skip to content

Commit 40a071a

Browse files
committed
Merge branch 'dev' into product2
# Conflicts: # .github/workflows/ci.yml # backend/src/test/java/com/smalltrend/controller/products/BrandControllerTest.java # backend/src/test/java/com/smalltrend/controller/products/CategoryControllerTest.java # backend/src/test/java/com/smalltrend/controller/products/FileUploadControllerTest.java # backend/src/test/java/com/smalltrend/controller/products/ProductComboControllerTest.java # backend/src/test/java/com/smalltrend/controller/products/TaxRateControllerTest.java # backend/src/test/java/com/smalltrend/service/products/BrandServiceTest.java # backend/src/test/java/com/smalltrend/service/products/CategoriesServiceTest.java # backend/src/test/java/com/smalltrend/service/products/ProductVariantServiceTest.java # backend/src/test/java/com/smalltrend/service/products/UnitConversionServiceTest.java # backend/src/test/java/com/smalltrend/service/products/UnitServiceTest.java
2 parents 7e7ce63 + 8426348 commit 40a071a

File tree

1 file changed

+87
-115
lines changed

1 file changed

+87
-115
lines changed

.github/workflows/ci.yml

Lines changed: 87 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,148 +1,120 @@
11
name: CI
22

33
on:
4-
pull_request:
5-
branches:
6-
- dev
7-
- main
84
push:
9-
branches:
10-
- dev
11-
workflow_dispatch:
5+
branches: [main, dev, shift]
6+
pull_request:
7+
branches: [main, dev]
128

13-
permissions:
14-
contents: write
15-
pull-requests: write
9+
env:
10+
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
1611

12+
# Cancel redundant runs when a new push is made to the same branch
1713
concurrency:
18-
group: ci-${{ github.workflow }}-${{ github.ref }}
14+
group: ${{ github.workflow }}-${{ github.ref }}
1915
cancel-in-progress: true
2016

2117
jobs:
22-
pr-policy-check:
23-
name: PR Policy Check
24-
if: github.event_name == 'pull_request'
25-
runs-on: ubuntu-latest
26-
steps:
27-
- name: Checkout PR head commit
28-
uses: actions/checkout@v4
29-
with:
30-
ref: ${{ github.event.pull_request.head.sha }}
31-
fetch-depth: 0
32-
33-
- name: Fetch base branch
34-
run: |
35-
git fetch origin ${{ github.base_ref }} --depth=1
36-
37-
- name: Ensure PR branch contains latest base
38-
run: |
39-
if git merge-base --is-ancestor origin/${{ github.base_ref }} HEAD; then
40-
echo "Branch is up to date with base branch."
41-
else
42-
echo "PR branch is behind origin/${{ github.base_ref }}."
43-
echo "Please sync with base branch and resolve conflicts before merge."
44-
exit 1
45-
fi
46-
47-
- name: Allow only dev to merge into main
48-
run: |
49-
if [ "${{ github.base_ref }}" = "main" ] && [ "${{ github.head_ref }}" != "dev" ]; then
50-
echo "Only branch 'dev' is allowed to open PRs into 'main'."
51-
echo "This keeps manual review in dev and prevents accidental overwrite from other branches."
52-
exit 1
53-
fi
54-
55-
backend-test:
56-
name: Backend Test
57-
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/dev')
18+
frontend:
19+
name: Frontend (Lint & Build)
5820
runs-on: ubuntu-latest
59-
defaults:
60-
run:
61-
working-directory: backend
62-
steps:
63-
- name: Checkout
64-
uses: actions/checkout@v4
65-
66-
- name: Set up Java 17
67-
uses: actions/setup-java@v4
68-
with:
69-
distribution: temurin
70-
java-version: "17"
71-
cache: maven
7221

73-
- name: Run backend tests
74-
run: ./mvnw -B test
75-
76-
frontend-lint-build:
77-
name: Frontend Lint & Build
78-
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/dev')
79-
runs-on: ubuntu-latest
8022
defaults:
8123
run:
8224
working-directory: frontend
25+
8326
steps:
84-
- name: Checkout
27+
- name: Checkout code
8528
uses: actions/checkout@v4
8629

87-
- name: Set up Node.js 20
30+
- name: Setup Node.js 20
8831
uses: actions/setup-node@v4
8932
with:
9033
node-version: "20"
91-
cache: npm
34+
cache: "npm"
9235
cache-dependency-path: frontend/package-lock.json
9336

9437
- name: Install dependencies
9538
run: npm ci
9639

97-
- name: Run lint
98-
run: |
99-
if [ -f eslint.config.js ] || [ -f eslint.config.mjs ] || [ -f eslint.config.cjs ] || [ -f .eslintrc ] || [ -f .eslintrc.js ] || [ -f .eslintrc.cjs ] || [ -f .eslintrc.json ]; then
100-
if npm run | grep -q "lint:ci"; then
101-
npm run lint:ci
102-
else
103-
npm run lint
104-
fi
105-
else
106-
echo "No ESLint configuration file found. Skipping lint step for this branch."
107-
fi
108-
109-
- name: Build frontend
40+
- name: Lint
41+
run: npm run lint:ci
42+
43+
- name: Build
11044
run: npm run build
11145

112-
auto-pr-dev-to-main:
113-
name: Auto PR dev -> main
114-
if: github.event_name == 'push' && github.ref == 'refs/heads/dev'
115-
needs:
116-
- backend-test
117-
- frontend-lint-build
46+
- name: Upload build artifact
47+
uses: actions/upload-artifact@v4
48+
with:
49+
name: frontend-dist
50+
path: frontend/dist
51+
retention-days: 7
52+
53+
backend:
54+
name: Backend (Build & Test)
11855
runs-on: ubuntu-latest
56+
57+
defaults:
58+
run:
59+
working-directory: backend
60+
61+
services:
62+
mysql:
63+
image: mysql:8.0
64+
env:
65+
MYSQL_ROOT_PASSWORD: test1234
66+
MYSQL_DATABASE: smalltrend_test
67+
ports:
68+
- 3306:3306
69+
options: >-
70+
--health-cmd="mysqladmin ping -h localhost"
71+
--health-interval=10s
72+
--health-timeout=5s
73+
--health-retries=5
74+
75+
env:
76+
DB_URL: jdbc:mysql://localhost:3306/smalltrend_test?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC&createDatabaseIfNotExist=true
77+
DB_USERNAME: root
78+
DB_PASSWORD: test1234
79+
JWT_SECRET: 5367566B59703373367639792F423F4528482B4D6251655468576D5A71347437
80+
CLOUDINARY_CLOUD_NAME: ci_dummy
81+
CLOUDINARY_API_KEY: "000000000000000"
82+
CLOUDINARY_API_SECRET: ci_dummy_secret
83+
SPRING_SQL_INIT_MODE: never
84+
SPRING_JPA_DDL_AUTO: create-drop
85+
11986
steps:
120-
- name: Checkout
87+
- name: Checkout code
12188
uses: actions/checkout@v4
89+
90+
- name: Setup Java 17
91+
uses: actions/setup-java@v4
12292
with:
123-
fetch-depth: 0
93+
java-version: "17"
94+
distribution: "temurin"
95+
cache: "maven"
12496

125-
- name: Create or reuse PR from dev to main
126-
id: pr
127-
env:
128-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
129-
run: |
130-
pr_number=$(gh pr list --base main --head dev --state open --json number --jq '.[0].number')
131-
132-
if [ -z "$pr_number" ]; then
133-
gh pr create \
134-
--base main \
135-
--head dev \
136-
--title "chore: sync dev into main" \
137-
--body "Auto-generated PR to sync tested changes from dev into main."
138-
pr_number=$(gh pr list --base main --head dev --state open --json number --jq '.[0].number')
139-
fi
140-
141-
echo "number=$pr_number" >> "$GITHUB_OUTPUT"
142-
143-
- name: Enable auto-merge for dev -> main PR
144-
if: steps.pr.outputs.number != ''
145-
env:
146-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
147-
run: |
148-
gh pr merge "${{ steps.pr.outputs.number }}" --auto --merge
97+
- name: Make Maven wrapper executable
98+
run: chmod +x mvnw
99+
100+
- name: Compile (skip tests)
101+
run: ./mvnw -B compile -DskipTests
102+
103+
- name: Run tests + JaCoCo coverage
104+
run: ./mvnw -B verify
105+
106+
- name: Upload JaCoCo coverage report
107+
if: always()
108+
uses: actions/upload-artifact@v4
109+
with:
110+
name: jacoco-report
111+
path: target/site/jacoco
112+
retention-days: 7
113+
114+
- name: Upload JUnit test results
115+
if: always()
116+
uses: actions/upload-artifact@v4
117+
with:
118+
name: junit-test-results
119+
path: target/surefire-reports
120+
retention-days: 7

0 commit comments

Comments
 (0)