-
Notifications
You must be signed in to change notification settings - Fork 172
84 lines (71 loc) · 2.81 KB
/
link-lang-check.yml
File metadata and controls
84 lines (71 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: Link Language Check
on:
workflow_call:
inputs:
soft-fail:
description: 'Whether to continue on language path violations'
required: false
type: boolean
default: false
permissions:
contents: read
jobs:
link-lang-check:
name: Check for Language Paths in URLs
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Create logs directory
shell: pwsh
run: |
New-Item -ItemType Directory -Force -Path logs | Out-Null
- name: Run Link Language Check
shell: pwsh
run: |
& scripts/linting/Invoke-LinkLanguageCheck.ps1 -ExcludePaths 'scripts/tests/**'
continue-on-error: true
- name: Upload results
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: link-lang-check-results
path: logs/link-lang-check-results.json
retention-days: 30
- name: Check results and fail if needed
if: ${{ !inputs.soft-fail }}
shell: pwsh
run: |
if ($env:LINK_LANG_FAILED -eq 'true') {
$resultsPath = 'logs/link-lang-check-results.json'
if (Test-Path -LiteralPath $resultsPath) {
try {
$results = Get-Content -LiteralPath $resultsPath -Raw | ConvertFrom-Json
$totalIssues = [int]($results.summary.total_issues)
$filesAffected = [int]($results.summary.files_affected)
if ($results.issues -and $results.issues.Count -gt 0) {
if ($totalIssues -le 0) {
$totalIssues = [int]$results.issues.Count
}
if ($filesAffected -le 0) {
$filesAffected = [int](($results.issues | Select-Object -ExpandProperty file -Unique).Count)
}
Write-Host "❌ Link language check failed with $totalIssues issue(s) in $filesAffected file(s)."
foreach ($issue in $results.issues) {
Write-Host " ⚠️ $($issue.file):$($issue.line_number) - $($issue.original_url)"
}
} else {
Write-Host 'Link language check failed and no issue entries were found in logs/link-lang-check-results.json.'
}
} catch {
Write-Host 'Link language check failed and logs/link-lang-check-results.json could not be parsed.'
}
} else {
Write-Host 'Link language check failed and logs/link-lang-check-results.json was not found.'
}
exit 1
}