Skip to content

Commit 7bab6d1

Browse files
Merge pull request #5585 from atlanhq/maven-optimize
feat: optimize maven workflow
2 parents dd18b52 + edc43a7 commit 7bab6d1

File tree

1 file changed

+66
-8
lines changed

1 file changed

+66
-8
lines changed

.github/workflows/maven.yml

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,54 @@ on:
3030
- staging
3131

3232
jobs:
33+
# Detect what changed to optimize workflow execution
34+
# This dramatically speeds up helm-only changes by skipping the 20+ minute build job
35+
changes:
36+
runs-on: ubuntu-latest
37+
outputs:
38+
code: ${{ steps.filter.outputs.code }}
39+
helm: ${{ steps.filter.outputs.helm }}
40+
steps:
41+
- uses: actions/checkout@v3
42+
with:
43+
fetch-depth: 0 # Fetch all history for accurate comparisons
44+
45+
- uses: dorny/paths-filter@v2
46+
id: filter
47+
with:
48+
# Compare against the previous commit on this branch (not master)
49+
# This way we only detect changes in the current push
50+
base: ${{ github.event.before }}
51+
filters: |
52+
code:
53+
- '**/*.java'
54+
- '**/*.xml'
55+
- '**/*.properties'
56+
- 'webapp/**'
57+
- 'repository/**'
58+
- 'intg/**'
59+
- 'graphdb/**'
60+
- 'pom.xml'
61+
- '**/pom.xml'
62+
helm:
63+
- 'helm/**'
64+
65+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
66+
# WORKFLOW EXECUTION PATHS:
67+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
68+
#
69+
# 📦 HELM-ONLY CHANGES (exclusively helm/** files):
70+
# changes ✅ → helm-lint ✅ → build ⏭️ → smoke-test ⏭️ → helm-publish ✅
71+
# ⏱️ Time: ~5 minutes (80% faster!)
72+
#
73+
# 💻 ANYTHING ELSE (code, maven.yml, Dockerfile, scripts, etc.):
74+
# changes ✅ → helm-lint ✅ → build ✅ → smoke-test ✅/⏭️ → helm-publish ✅
75+
# ⏱️ Time: ~25 minutes (full pipeline)
76+
#
77+
# Logic: Skip build ONLY if changes are exclusively in helm/**
78+
#
79+
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
80+
3381
helm-lint:
3482
runs-on: ubuntu-latest
3583
strategy:
@@ -105,7 +153,10 @@ jobs:
105153
echo "✅ Chart.yaml validation passed for ${{ matrix.chart }}!"
106154
107155
build:
108-
needs: helm-lint
156+
needs: [helm-lint, changes]
157+
# Skip build ONLY if changes are exclusively in helm/**
158+
# Run build for: code changes, workflow changes, Dockerfile, scripts, or anything else
159+
if: needs.changes.outputs.helm != 'true' || needs.changes.outputs.code == 'true'
109160
runs-on: ubuntu-latest
110161

111162
steps:
@@ -365,11 +416,12 @@ jobs:
365416

366417
smoke-test:
367418
name: Multi-Cloud Smoke Test
368-
needs: build
419+
needs: [build, changes]
369420
runs-on: ubuntu-latest
370-
# Only run smoke tests on protected branches (beta, staging, master)
371-
# Feature branches skip smoke tests but can still publish OCI charts for manual testing
372-
if: github.ref_name == 'beta' || github.ref_name == 'staging' || github.ref_name == 'master'
421+
# Run smoke tests on protected branches if build ran (i.e., not helm-only changes)
422+
if: |
423+
needs.build.result == 'success' &&
424+
(github.ref_name == 'beta' || github.ref_name == 'staging' || github.ref_name == 'master')
373425
374426
# Concurrency control: Only one smoke test at a time across all branches
375427
# Shared vClusters cannot handle concurrent deployments
@@ -513,10 +565,16 @@ jobs:
513565
path: smoke-test-logs/
514566

515567
helm-publish:
516-
needs: [build, smoke-test]
568+
needs: [build, smoke-test, changes]
517569
runs-on: ubuntu-latest
518-
# Run if smoke-test passed (protected branches) OR was skipped (feature branches)
519-
if: always() && needs.build.result == 'success' && (needs.smoke-test.result == 'success' || needs.smoke-test.result == 'skipped')
570+
# Run helm-publish if:
571+
# 1. Build succeeded AND smoke-test passed/skipped: publish (code/workflow changes)
572+
# 2. Build skipped AND helm changed: publish (helm-only changes)
573+
if: |
574+
always() && (
575+
(needs.build.result == 'success' && (needs.smoke-test.result == 'success' || needs.smoke-test.result == 'skipped')) ||
576+
(needs.build.result == 'skipped' && needs.changes.outputs.helm == 'true')
577+
)
520578
strategy:
521579
matrix:
522580
include:

0 commit comments

Comments
 (0)