Merge pull request 'feat: add caching for NuGet packages and build output in CI workflow' (#158) from ci-cd/cache into dev
Reviewed-on: https://10.4.0.131/gitea/DI1-P4-E1/Webzine/pulls/158
This commit is contained in:
@@ -13,19 +13,29 @@ jobs:
|
|||||||
|
|
||||||
- name: Configure appsettings for CI
|
- name: Configure appsettings for CI
|
||||||
run: |
|
run: |
|
||||||
# Find the appsettings.json file
|
|
||||||
APPSETTINGS_PATH="Webzine.WebApplication/appsettings.json"
|
APPSETTINGS_PATH="Webzine.WebApplication/appsettings.json"
|
||||||
|
|
||||||
# Backup original file
|
|
||||||
cp $APPSETTINGS_PATH $APPSETTINGS_PATH.bak
|
cp $APPSETTINGS_PATH $APPSETTINGS_PATH.bak
|
||||||
|
|
||||||
# Use jq to modify the JSON
|
|
||||||
jq '.UseDatabase = true | .IsSQLite = true' $APPSETTINGS_PATH > $APPSETTINGS_PATH.tmp
|
jq '.UseDatabase = true | .IsSQLite = true' $APPSETTINGS_PATH > $APPSETTINGS_PATH.tmp
|
||||||
mv $APPSETTINGS_PATH.tmp $APPSETTINGS_PATH
|
mv $APPSETTINGS_PATH.tmp $APPSETTINGS_PATH
|
||||||
|
|
||||||
echo "Updated appsettings.json:"
|
echo "Updated appsettings.json:"
|
||||||
cat $APPSETTINGS_PATH
|
cat $APPSETTINGS_PATH
|
||||||
|
|
||||||
|
- name: Cache .NET SDK
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.dotnet
|
||||||
|
/usr/share/dotnet
|
||||||
|
key: ${{ runner.os }}-dotnet-10.0.x
|
||||||
|
|
||||||
|
- name: Cache NuGet packages
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: ~/.nuget/packages
|
||||||
|
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/*.sln') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-nuget-
|
||||||
|
|
||||||
- name: Setup .NET 10
|
- name: Setup .NET 10
|
||||||
uses: actions/setup-dotnet@v4
|
uses: actions/setup-dotnet@v4
|
||||||
with:
|
with:
|
||||||
@@ -65,24 +75,22 @@ jobs:
|
|||||||
chmod +x scripts/test-endpoints.sh
|
chmod +x scripts/test-endpoints.sh
|
||||||
bash scripts/test-endpoints.sh http://localhost:5038 1000 2>&1 | tee /tmp/webzine_endpoint_output.txt
|
bash scripts/test-endpoints.sh http://localhost:5038 1000 2>&1 | tee /tmp/webzine_endpoint_output.txt
|
||||||
EXIT_CODE=${PIPESTATUS[0]}
|
EXIT_CODE=${PIPESTATUS[0]}
|
||||||
|
|
||||||
# Count failures
|
|
||||||
FAIL_COUNT=$(grep -cE "^\[ÉCHEC\]" /tmp/webzine_endpoint_output.txt 2>/dev/null || echo 0)
|
FAIL_COUNT=$(grep -cE "^\[ÉCHEC\]" /tmp/webzine_endpoint_output.txt 2>/dev/null || echo 0)
|
||||||
SLOW_COUNT=$(grep -cE "^\[LENT\]" /tmp/webzine_endpoint_output.txt 2>/dev/null || echo 0)
|
SLOW_COUNT=$(grep -cE "^\[LENT\]" /tmp/webzine_endpoint_output.txt 2>/dev/null || echo 0)
|
||||||
|
|
||||||
echo "failed=$FAIL_COUNT" >> "$GITHUB_OUTPUT"
|
echo "failed=$FAIL_COUNT" >> "$GITHUB_OUTPUT"
|
||||||
echo "slow=$SLOW_COUNT" >> "$GITHUB_OUTPUT"
|
echo "slow=$SLOW_COUNT" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
# Échoue s’il y a DES problèmes (échecs OU lents)
|
|
||||||
if [ $FAIL_COUNT -gt 0 ] || [ $SLOW_COUNT -gt 0 ]; then
|
if [ $FAIL_COUNT -gt 0 ] || [ $SLOW_COUNT -gt 0 ]; then
|
||||||
echo "❌ Performance check failed: $FAIL_COUNT endpoint(s) failed, $SLOW_COUNT endpoint(s) exceeded threshold (1000ms)"
|
echo "❌ Performance check failed: $FAIL_COUNT endpoint(s) failed, $SLOW_COUNT endpoint(s) exceeded threshold (1000ms)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "✅ All endpoints passed performance check (< 1000ms)"
|
echo "✅ All endpoints passed performance check (< 1000ms)"
|
||||||
|
|
||||||
- name: Post performance report as PR comment
|
- name: Post performance report as PR comment
|
||||||
if: always() # Always post comment, even on failure
|
if: always()
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
GITEA_SERVER_URL: ${{ gitea.server_url }}
|
||||||
@@ -92,20 +100,15 @@ jobs:
|
|||||||
RAW_REPORT=$(cat /tmp/webzine_endpoint_output.txt 2>/dev/null || echo "Aucune sortie capturée.")
|
RAW_REPORT=$(cat /tmp/webzine_endpoint_output.txt 2>/dev/null || echo "Aucune sortie capturée.")
|
||||||
FAILED_COUNT="${{ steps.perf_test.outputs.failed }}"
|
FAILED_COUNT="${{ steps.perf_test.outputs.failed }}"
|
||||||
SLOW_COUNT="${{ steps.perf_test.outputs.slow }}"
|
SLOW_COUNT="${{ steps.perf_test.outputs.slow }}"
|
||||||
|
|
||||||
# Determine if the check passed or failed
|
|
||||||
if [ "$FAILED_COUNT" -gt 0 ] || [ "$SLOW_COUNT" -gt 0 ]; then
|
if [ "$FAILED_COUNT" -gt 0 ] || [ "$SLOW_COUNT" -gt 0 ]; then
|
||||||
STATUS_HEADER="❌ **PERFORMANCE CHECK FAILED**"
|
STATUS_HEADER="❌ **PERFORMANCE CHECK FAILED**"
|
||||||
STATUS_ICON="❌"
|
|
||||||
else
|
else
|
||||||
STATUS_HEADER="✅ **PERFORMANCE CHECK PASSED**"
|
STATUS_HEADER="✅ **PERFORMANCE CHECK PASSED**"
|
||||||
STATUS_ICON="✅"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Convert report to Markdown with colors
|
|
||||||
CLEAN_REPORT=$(echo "$RAW_REPORT" | sed 's/\x1b\[[0-9;]*m//g')
|
CLEAN_REPORT=$(echo "$RAW_REPORT" | sed 's/\x1b\[[0-9;]*m//g')
|
||||||
|
|
||||||
# Generate formatted report
|
|
||||||
FORMATTED_REPORT=$(echo "$CLEAN_REPORT" | sed \
|
FORMATTED_REPORT=$(echo "$CLEAN_REPORT" | sed \
|
||||||
-e 's/^\[OK\] /✅ /' \
|
-e 's/^\[OK\] /✅ /' \
|
||||||
-e 's/^\[LENT\] /⚠️ /' \
|
-e 's/^\[LENT\] /⚠️ /' \
|
||||||
@@ -120,23 +123,16 @@ jobs:
|
|||||||
-e 's/^\(⚠️ ENDPOINTS LENTS.*\)$/\n### \1/' \
|
-e 's/^\(⚠️ ENDPOINTS LENTS.*\)$/\n### \1/' \
|
||||||
-e 's/^\(❌ ENDPOINTS EN ÉCHEC.*\)$/\n### \1/' \
|
-e 's/^\(❌ ENDPOINTS EN ÉCHEC.*\)$/\n### \1/' \
|
||||||
-e 's/^\(La PR doit.*\)$/\n**❌ \1**/')
|
-e 's/^\(La PR doit.*\)$/\n**❌ \1**/')
|
||||||
|
|
||||||
BODY=$(cat <<EOF
|
BODY=$(cat <<EOF
|
||||||
$STATUS_HEADER
|
$STATUS_HEADER
|
||||||
|
|
||||||
$FORMATTED_REPORT
|
$FORMATTED_REPORT
|
||||||
|
|
||||||
---
|
|
||||||
**Seuil**: 1000ms
|
|
||||||
**Statistiques**:
|
|
||||||
- ✅ Endpoints rapides: \$(grep -c "^\[OK\]" /tmp/webzine_endpoint_output.txt 2>/dev/null || echo 0)
|
|
||||||
- ⚠️ Endpoints lents (>1000ms): $SLOW_COUNT
|
|
||||||
- ❌ Endpoints en échec: $FAILED_COUNT
|
|
||||||
|
|
||||||
**Vérifié par**: Workflow PR Endpoint Performance
|
**Vérifié par**: Workflow PR Endpoint Performance
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
|
|
||||||
curl -s -X POST \
|
curl -s -X POST \
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
|
|||||||
Reference in New Issue
Block a user