|
| 1 | +name: Lint and Validate |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + |
| 10 | +jobs: |
| 11 | + powershell: |
| 12 | + name: PowerShell Script Analysis |
| 13 | + if: ${{ ! startsWith(github.head_ref, 'release-please--branches--') }} |
| 14 | + runs-on: windows-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Install PSScriptAnalyzer |
| 20 | + shell: powershell |
| 21 | + run: | |
| 22 | + Set-PSRepository PSGallery -InstallationPolicy Trusted |
| 23 | + Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser |
| 24 | +
|
| 25 | + - name: Run PSScriptAnalyzer |
| 26 | + shell: powershell |
| 27 | + run: | |
| 28 | + $results = Invoke-ScriptAnalyzer -Path ./scripts/windows -Recurse -ReportSummary |
| 29 | + if ($results) { |
| 30 | + $results | Format-Table -AutoSize |
| 31 | + throw "PSScriptAnalyzer found issues" |
| 32 | + } |
| 33 | + Write-Host "PowerShell scripts passed analysis" -ForegroundColor Green |
| 34 | +
|
| 35 | + shellcheck: |
| 36 | + name: Shell Script Analysis |
| 37 | + runs-on: ubuntu-latest |
| 38 | + |
| 39 | + steps: |
| 40 | + - uses: actions/checkout@v4 |
| 41 | + |
| 42 | + - name: Run ShellCheck |
| 43 | + uses: ludeeus/action-shellcheck@master |
| 44 | + with: |
| 45 | + scandir: './scripts' |
| 46 | + ignore_paths: 'scripts/windows' |
| 47 | + severity: warning |
| 48 | + |
| 49 | + markdown: |
| 50 | + name: Markdown Lint |
| 51 | + runs-on: ubuntu-latest |
| 52 | + |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v4 |
| 55 | + |
| 56 | + - name: Run markdownlint |
| 57 | + uses: DavidAnson/markdownlint-cli2-action@v16 |
| 58 | + with: |
| 59 | + globs: | |
| 60 | + **/*.md |
| 61 | + !node_modules/** |
| 62 | +
|
| 63 | + json-yaml: |
| 64 | + name: JSON/YAML Validation |
| 65 | + runs-on: ubuntu-latest |
| 66 | + |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + |
| 70 | + - name: Validate JSON files |
| 71 | + run: | |
| 72 | + find . -name "*.json" -type f -not -path "./node_modules/*" | while read file; do |
| 73 | + echo "Validating $file" |
| 74 | + python -m json.tool "$file" > /dev/null || exit 1 |
| 75 | + done |
| 76 | + echo "All JSON files are valid" |
| 77 | +
|
| 78 | + - name: Setup Python |
| 79 | + uses: actions/setup-python@v5 |
| 80 | + with: |
| 81 | + python-version: '3.x' |
| 82 | + |
| 83 | + - name: Validate YAML files |
| 84 | + run: | |
| 85 | + pip install pyyaml |
| 86 | + find . -name "*.yml" -o -name "*.yaml" -type f -not -path "./node_modules/*" | while read file; do |
| 87 | + echo "Validating $file" |
| 88 | + python -c "import yaml; yaml.safe_load(open('$file'))" || exit 1 |
| 89 | + done |
| 90 | + echo "All YAML files are valid" |
| 91 | +
|
| 92 | + security: |
| 93 | + name: Security Scan |
| 94 | + runs-on: ubuntu-latest |
| 95 | + |
| 96 | + steps: |
| 97 | + - uses: actions/checkout@v4 |
| 98 | + |
| 99 | + - name: Run Trivy security scanner |
| 100 | + uses: aquasecurity/trivy-action@master |
| 101 | + with: |
| 102 | + scan-type: 'fs' |
| 103 | + scan-ref: '.' |
| 104 | + format: 'sarif' |
| 105 | + output: 'trivy-results.sarif' |
| 106 | + |
| 107 | + - name: Upload Trivy results to GitHub Security |
| 108 | + uses: github/codeql-action/upload-sarif@v3 |
| 109 | + if: always() |
| 110 | + with: |
| 111 | + sarif_file: 'trivy-results.sarif' |
0 commit comments