Skip to content

Commit 894b5ba

Browse files
Merge pull request #32 from pierrick-fonquerne/FRO-62-Optimisation-du-workflow-CI-GitHub-Actions
ci: optimize GitHub Actions workflow (FRO-62)
2 parents 1e9b844 + e31afd7 commit 894b5ba

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
pull_request:
77
branches: [main, develop]
88

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
913
jobs:
1014
changes:
1115
name: Detect changes
@@ -16,8 +20,6 @@ jobs:
1620
steps:
1721
- name: Checkout
1822
uses: actions/checkout@v4
19-
with:
20-
fetch-depth: 0
2123

2224
- name: Detect file changes
2325
uses: dorny/paths-filter@v3
@@ -49,6 +51,13 @@ jobs:
4951
with:
5052
dotnet-version: '8.0.x'
5153

54+
- name: Cache NuGet packages
55+
uses: actions/cache@v4
56+
with:
57+
path: ~/.nuget/packages
58+
key: ${{ runner.os }}-nuget-${{ hashFiles('src/backend/**/*.csproj') }}
59+
restore-keys: ${{ runner.os }}-nuget-
60+
5261
- name: Restore dependencies
5362
run: dotnet restore
5463

@@ -58,15 +67,6 @@ jobs:
5867
- name: Test
5968
run: dotnet test --no-build --configuration Release --verbosity normal --filter "Category!=Email"
6069

61-
backend-skip:
62-
name: Backend (.NET) (pull_request)
63-
needs: changes
64-
if: ${{ needs.changes.outputs.backend == 'false' }}
65-
runs-on: ubuntu-latest
66-
steps:
67-
- name: Skip
68-
run: echo "No backend changes detected - skipping build"
69-
7070
frontend:
7171
name: Frontend (React)
7272
needs: changes
@@ -102,11 +102,16 @@ jobs:
102102
- name: Test
103103
run: npm run test -- --passWithNoTests
104104

105-
frontend-skip:
106-
name: Frontend (React) (pull_request)
107-
needs: changes
108-
if: ${{ needs.changes.outputs.frontend == 'false' }}
105+
ci-success:
106+
name: CI Success
107+
needs: [changes, backend, frontend]
108+
if: always()
109109
runs-on: ubuntu-latest
110110
steps:
111-
- name: Skip
112-
run: echo "No frontend changes detected - skipping build"
111+
- name: Check results
112+
run: |
113+
if [[ "${{ needs.backend.result }}" == "failure" || "${{ needs.frontend.result }}" == "failure" ]]; then
114+
echo "One or more jobs failed"
115+
exit 1
116+
fi
117+
echo "CI passed successfully"

0 commit comments

Comments
 (0)