Skip to content

Commit 7e0bc8e

Browse files
authored
Merge pull request #52 from RustyRory/hotfix/8-conception
Hotfix/8 conception
2 parents 740f341 + c41de52 commit 7e0bc8e

1,796 files changed

Lines changed: 677 additions & 314261 deletions

File tree

Some content is hidden

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

.github/ISSUE_TEMPLATE/standard.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/audit.yml

Lines changed: 40 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,55 @@
1-
name: Audit des dépendances
1+
name: 'Audit des dépendances npm Backend et Frontend'
22

33
on:
44
pull_request:
5-
types: [opened, reopened, synchronize]
5+
types: [opened, edited, synchronize]
6+
push:
7+
branches:
8+
- main
9+
- dev
610

711
jobs:
8-
audit:
12+
npm-audit:
913
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
node-version: [18]
1017

1118
steps:
12-
- name: Checkout du code
13-
uses: actions/checkout@v4
19+
- name: 'Checkout code'
20+
uses: actions/checkout@v3
1421

15-
- name: Setup Node.js
22+
- name: 'Setup Node.js'
1623
uses: actions/setup-node@v3
1724
with:
18-
node-version: "18"
25+
node-version: ${{ matrix.node-version }}
1926

20-
- name: Audit backend
27+
# ----------------------
28+
# Backend audit
29+
# ----------------------
30+
- name: 'Installation des dépendances backend'
2131
run: |
22-
if [ -d "app/backend" ]; then
23-
cd app/backend
24-
npm install
25-
echo "Audit des dépendances backend..."
26-
npm audit --audit-level=high
27-
cd ..
28-
cd ..
29-
else
30-
echo "⚠️ Dossier backend introuvable"
31-
exit 1
32-
fi
33-
34-
- name: Audit frontend
32+
echo "Installation des dépendances backend"
33+
cd app/backend
34+
npm install
35+
36+
- name: "Lancement de l'audit npm backend"
37+
run: |
38+
echo "Audit des dépendances backend"
39+
cd app/backend
40+
npm audit --audit-level=high
41+
42+
# ----------------------
43+
# Frontend audit
44+
# ----------------------
45+
- name: 'Installation des dépendances frontend'
3546
run: |
36-
if [ -d "app/frontend" ]; then
37-
cd app/frontend
38-
npm install
39-
echo "Audit des dépendances frontend (non bloquant)..."
40-
npm audit --audit-level=high || echo "⚠️ Vulnérabilités connues de react-scripts ignorées"
41-
cd ..
42-
cd ..
43-
else
44-
echo "⚠️ Dossier frontend introuvable"
45-
exit 1
46-
fi
47+
echo "Installation des dépendances frontend"
48+
cd app/frontend
49+
npm install
4750
51+
- name: "Lancement de l'audit npm frontend"
52+
run: |
53+
echo "Audit des dépendances frontend"
54+
cd app/frontend
55+
npm audit --audit-level=high

.github/workflows/branch-name.yml

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,45 @@
1-
name: Vérification du nom de branche
1+
name: 'Vérification du nom de la branche'
22

33
on:
44
pull_request:
5-
types: [opened, reopened, synchronize]
5+
types: [opened, edited, synchronize]
66

77
jobs:
8-
check-branch-name:
8+
branch-name-check:
99
runs-on: ubuntu-latest
1010
steps:
11-
- name: Vérifier le nom de la branche
12-
shell: bash
11+
- name: 'Vérification du nom de la branche'
12+
id: check_branch
1313
run: |
14-
BRANCHE="${{ github.head_ref }}"
15-
echo "Nom de branche détecté : $BRANCHE"
14+
echo "PR branch: ${{ github.head_ref }}"
1615
17-
# Regex pour valider le format des branches
18-
if [[ "$BRANCHE" =~ ^(feature|feat|fix|hotfix)/[0-9]+-[a-z0-9-]+$ ]] || [[ "$BRANCHE" =~ ^release/[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
19-
echo "✅ Nom de branche valide : $BRANCHE"
16+
BRANCH="${{ github.head_ref }}"
17+
18+
# Regex pour les conventions
19+
FEATURE_REGEX="^(feat|feature)/[0-9]+-[a-z0-9-]+$"
20+
FIX_REGEX="^fix/[0-9]+-[a-z0-9-]+$"
21+
HOTFIX_REGEX="^hotfix/[0-9]+-[a-z0-9-]+$"
22+
RELEASE_REGEX="^release/[0-9]+\.[0-9]+\.[0-9]+$"
23+
24+
if [[ $BRANCH =~ $FEATURE_REGEX ]]; then
25+
echo "✅ Nom de la branche valide (feature)"
26+
exit 0
27+
elif [[ $BRANCH =~ $FIX_REGEX ]]; then
28+
echo "✅ Nom de la branche valide (fix)"
29+
exit 0
30+
elif [[ $BRANCH =~ $HOTFIX_REGEX ]]; then
31+
echo "✅ Nom de la branche valide (hotfix)"
32+
exit 0
33+
elif [[ $BRANCH =~ $RELEASE_REGEX ]]; then
34+
echo "✅ Nom de la branche valide (release)"
35+
exit 0
2036
else
21-
echo "❌ Nom de branche invalide : $BRANCHE"
22-
echo "💡 Format attendu :"
23-
echo " - feature/<issue-id>-short-description"
24-
echo " - fix/<issue-id>-short-description"
25-
echo " - hotfix/<issue-id>-short-description"
26-
echo " - release/x.y.z"
27-
echo "Exemple : feature/123-login-page"
37+
echo "❌ Nom de la branche invalide: $BRANCH"
38+
echo ""
39+
echo "Le nom de la branche doit suivre la convention :"
40+
echo " feature/<issue-id>-description"
41+
echo " fix/<issue-id>-description"
42+
echo " hotfix/<issue-id>-description"
43+
echo " release/<x.y.z>"
2844
exit 1
2945
fi
Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,55 @@
1-
name: Vérification des messages de commit
1+
name: 'Vérification des messages de commit'
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
- dev
8-
- "feature/*"
9-
- "fix/*"
10-
- "hotfix/*"
11-
- "release/*"
4+
pull_request:
5+
types: [opened, edited, synchronize]
126

137
jobs:
14-
commit-message:
8+
commit-message-check:
159
runs-on: ubuntu-latest
10+
1611
steps:
17-
- uses: actions/checkout@v4
12+
- name: 'Checkout'
13+
uses: actions/checkout@v3
14+
with:
15+
fetch-depth: 0
1816

19-
- name: Vérifier le format des messages de commit
17+
- name: 'Valider les messages de commit'
2018
run: |
21-
echo "Récupération des commits du dernier push..."
22-
# Récupère les commits du dernier push
23-
COMMITS=$(git log origin/${GITHUB_REF_NAME}..HEAD --pretty=format:"%s")
19+
echo "🔍 Vérification des messages de commit pour la PR"
20+
21+
BASE_REF="${{ github.event.pull_request.base.ref }}"
22+
echo "Branche de base : $BASE_REF"
23+
24+
git fetch origin $BASE_REF
25+
26+
REGEX="^(feat|fix|docs|chore|refactor|test|hotfix)\([a-z0-9_-]+\): Fixes #[0-9]+ - .+"
2427
25-
echo "Commits détectés :"
26-
echo "$COMMITS"
28+
COMMITS=$(git log origin/$BASE_REF..HEAD --pretty=format:"%H")
2729
2830
INVALID=false
2931
3032
for COMMIT in $COMMITS; do
31-
# Regex pour le format attendu : type(nom): Fixes #<num> - message
32-
if ! [[ "$COMMIT" =~ ^(feat|fix|docs|chore|refactor|test|hotfix)\([a-zA-Z0-9_-]+\):\ Fixes\ #[0-9]+\ -\ .+ ]]; then
33-
echo "❌ Commit invalide : $COMMIT"
34-
echo "💡 Format attendu : type(nom): Fixes #<issue> - message"
33+
MESSAGE=$(git log -1 --pretty=format:"%s" $COMMIT)
34+
35+
# Ignorer les commits de merge
36+
if [[ "$MESSAGE" =~ ^Merge\ ]]; then
37+
echo "⏭️ Commit de merge ignoré: $MESSAGE"
38+
continue
39+
fi
40+
41+
if ! [[ "$MESSAGE" =~ $REGEX ]]; then
42+
echo "❌ Commit invalide: $MESSAGE"
3543
INVALID=true
3644
else
37-
echo "✅ Commit valide : $COMMIT"
45+
echo "✅ Commit valide: $MESSAGE"
3846
fi
3947
done
4048
4149
if [ "$INVALID" = true ]; then
42-
echo "❌ Au moins un commit ne respecte pas le format attendu."
50+
echo ""
51+
echo "⚠️ Un ou plusieurs commits ne respectent pas le format attendu !"
52+
echo "Format attendu : type(nom): Fixes #<issue> - message"
53+
echo "Types autorisés : feat, fix, docs, chore, refactor, test, hotfix"
4354
exit 1
4455
fi

.github/workflows/hotfix.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: 'Workflow Hotfix'
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
push:
8+
branches:
9+
- 'hotfix/*'
10+
11+
jobs:
12+
hotfix:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: 'Checkout code'
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: 0
20+
21+
- name: 'Configurer Git'
22+
run: |
23+
git config user.name "github-actions[bot]"
24+
git config user.email "github-actions[bot]@users.noreply.github.com"
25+
26+
- name: 'Déterminer la version hotfix'
27+
id: semver
28+
run: |
29+
set -e
30+
31+
# Dernier tag vX.Y.Z
32+
LATEST_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
33+
34+
if [[ -z "$LATEST_TAG" ]]; then
35+
echo "Aucun tag trouvé, initialisation à v0.0.1"
36+
VERSION="0.0.1"
37+
else
38+
VERSION="${LATEST_TAG#v}"
39+
MAJOR=$(echo "$VERSION" | cut -d. -f1)
40+
MINOR=$(echo "$VERSION" | cut -d. -f2)
41+
PATCH=$(echo "$VERSION" | cut -d. -f3)
42+
PATCH=$((PATCH + 1))
43+
VERSION="$MAJOR.$MINOR.$PATCH"
44+
fi
45+
46+
TAG="v$VERSION"
47+
echo "Nouvelle version candidate : $TAG"
48+
49+
# Vérifie si le tag existe déjà
50+
if git rev-parse "$TAG" >/dev/null 2>&1; then
51+
echo "⚠️ Le tag $TAG existe déjà, skip."
52+
echo "skip=true" >> $GITHUB_OUTPUT
53+
else
54+
echo "skip=false" >> $GITHUB_OUTPUT
55+
fi
56+
57+
echo "version=$VERSION" >> $GITHUB_OUTPUT
58+
echo "tag=$TAG" >> $GITHUB_OUTPUT
59+
60+
- name: 'Créer le tag git'
61+
if: steps.semver.outputs.skip != 'true'
62+
run: |
63+
git tag "${{ steps.semver.outputs.tag }}"
64+
git push origin "${{ steps.semver.outputs.tag }}"
65+
66+
- name: 'Extraire la section du changelog'
67+
if: steps.semver.outputs.skip != 'true'
68+
id: changelog
69+
run: |
70+
VERSION="${{ steps.semver.outputs.version }}"
71+
if [[ -f CHANGELOG.md ]]; then
72+
sed -n "/## \[$VERSION\]/,/^## /p" CHANGELOG.md > release_notes.txt
73+
else
74+
echo "No CHANGELOG.md found" > release_notes.txt
75+
fi
76+
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
77+
cat release_notes.txt >> $GITHUB_OUTPUT
78+
echo "EOF" >> $GITHUB_OUTPUT
79+
80+
- name: 'Créer une release GitHub'
81+
if: steps.semver.outputs.skip != 'true'
82+
uses: ncipollo/release-action@v1
83+
with:
84+
tag: '${{ steps.semver.outputs.tag }}'
85+
name: 'Hotfix ${{ steps.semver.outputs.tag }}'
86+
body: '${{ steps.changelog.outputs.release_notes }}'

0 commit comments

Comments
 (0)