|
| 1 | +name: Self-Hosted CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + build-and-test: |
| 12 | + # Exécute le workflow sur ton runner auto-hébergé (Windows) |
| 13 | + runs-on: self-hosted |
| 14 | + |
| 15 | + steps: |
| 16 | + # 1️⃣ Récupération du dépôt |
| 17 | + - name: Checkout repository |
| 18 | + uses: actions/checkout@v3 |
| 19 | + |
| 20 | + # 2️⃣ Vérification de la version de Node.js |
| 21 | + - name: Log Node.js version |
| 22 | + run: node --version |
| 23 | + |
| 24 | + # 3️⃣ Vérification de l'espace disque disponible |
| 25 | + - name: Log available disk space |
| 26 | + shell: powershell |
| 27 | + run: | |
| 28 | + Write-Output "Checking available disk space:" |
| 29 | + Get-PSDrive -PSProvider 'FileSystem' | ForEach-Object { |
| 30 | + "{0}: {1:N2} GB free / {2:N2} GB total" -f $_.Name, ($_.Free/1GB), ($_.Used/1GB + $_.Free/1GB) |
| 31 | + } |
| 32 | +
|
| 33 | + # 4️⃣ Installation des dépendances |
| 34 | + - name: Install dependencies |
| 35 | + run: npm ci |
| 36 | + |
| 37 | + # 5️⃣ Exécution des tests unitaires |
| 38 | + - name: Run tests |
| 39 | + run: npm test -- --watch=false --browsers=ChromeHeadless --no-progress |
| 40 | + |
| 41 | + # 6️⃣ Nettoyage (cache npm, logs temporaires, etc.) |
| 42 | + - name: Cleanup |
| 43 | + shell: powershell |
| 44 | + run: | |
| 45 | + Write-Output "Cleaning up temporary files and npm cache..." |
| 46 | + try { |
| 47 | + npm cache clean --force |
| 48 | + if (Test-Path "C:\Users\delta\AppData\Local\Temp") { |
| 49 | + Remove-Item -Path "C:\Users\delta\AppData\Local\Temp\*" -Recurse -Force -ErrorAction SilentlyContinue |
| 50 | + } |
| 51 | + Write-Output "Cleanup completed successfully." |
| 52 | + } catch { |
| 53 | + Write-Output "Cleanup failed: $($_.Exception.Message)" |
| 54 | + } |
| 55 | +
|
| 56 | + # 7️⃣ Vérification de l'espace disque après le nettoyage |
| 57 | + - name: Post-cleanup disk check |
| 58 | + shell: powershell |
| 59 | + run: | |
| 60 | + Write-Output "Disk space after cleanup:" |
| 61 | + Get-PSDrive -PSProvider 'FileSystem' | ForEach-Object { |
| 62 | + "{0}: {1:N2} GB free / {2:N2} GB total" -f $_.Name, ($_.Free/1GB), ($_.Used/1GB + $_.Free/1GB) |
| 63 | + } |
0 commit comments