mirror of
https://github.com/trailofbits/algo.git
synced 2026-09-26 19:44:56 +02:00
* ci: modernize tooling with prek, ty, and security scanning Migrate from pre-commit to prek (Rust-native, faster hooks) and add comprehensive CI improvements for code quality and security. Changes: - Replace pre-commit with prek for git hooks - Add ty type checker (Rust-based, replaces mypy) - Expand ruff rules: security (S), simplify (SIM), commented code (ERA) - Add pip-audit workflow for Python dependency CVE scanning - Add actionlint and zizmor for GitHub Actions linting/security - Add ruff format check to CI - Enable stricter ansible-lint rules (no-changed-when, risky-file-permissions) - Remove obsolete Claude workflow files - Apply ruff formatting fixes to test files Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(ci): resolve actionlint install and ty type errors - Use actionlint's official install script instead of broken URL pattern - Exclude test mock modules from ty type checking - Run workflows on push only for main/master to avoid duplicate PR runs Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(ci): use glob pattern for actionlint, exclude all tests from ty - actionlint requires *.yml glob, not directory path - Exclude all tests from ty type checking (test code has looser typing) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(ci): quote shell variables to fix shellcheck warnings Fix SC2046/SC2086 warnings in workflow scripts: - Quote $(uname -r) in apt-get install - Quote $(pwd) in docker volume mount - Quote $existing in gh issue comment Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix(ci): move key-order[task] to warn_list Too many existing violations in the codebase to enable as error. Move to warn_list for gradual fixes over time. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
185 lines
5.3 KiB
YAML
185 lines
5.3 KiB
YAML
---
|
|
name: Lint
|
|
|
|
'on':
|
|
push:
|
|
branches: [main, master]
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
ansible-lint:
|
|
name: Ansible linting
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v5.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Setup Algo environment
|
|
uses: ./.github/actions/setup-algo
|
|
with:
|
|
install-ansible-collections: 'true'
|
|
|
|
- name: Run ansible-lint
|
|
run: |
|
|
uv run --with ansible-lint ansible-lint .
|
|
|
|
- name: Run playbook dry-run check (catch runtime issues)
|
|
run: |
|
|
# Test main playbook logic without making changes
|
|
# This catches filter warnings, collection issues, and runtime errors
|
|
uv run ansible-playbook main.yml --check --connection=local \
|
|
-e "server_ip=test" \
|
|
-e "server_name=ci-test" \
|
|
-e "IP_subject_alt_name=192.168.1.1" \
|
|
|| echo "Dry-run check completed with issues - review output above"
|
|
|
|
yaml-lint:
|
|
name: YAML linting
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v5.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Setup uv environment
|
|
uses: ./.github/actions/setup-uv
|
|
|
|
- name: Run yamllint
|
|
run: uv run --with yamllint yamllint -c .yamllint .
|
|
|
|
python-lint:
|
|
name: Python linting
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v5.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Setup Algo environment
|
|
uses: ./.github/actions/setup-algo
|
|
|
|
- name: Run ruff check
|
|
run: |
|
|
# Fast Python linter
|
|
uv run --with ruff ruff check .
|
|
|
|
- name: Run ruff format check
|
|
run: |
|
|
# Verify consistent Python formatting
|
|
uv run --with ruff ruff format --check .
|
|
|
|
python-types:
|
|
name: Python type checking
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v5.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Setup Algo environment
|
|
uses: ./.github/actions/setup-algo
|
|
|
|
- name: Run ty check
|
|
run: |
|
|
# Type checking with ty
|
|
uv run --with ty ty check
|
|
|
|
shellcheck:
|
|
name: Shell script linting
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v5.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Setup Algo environment
|
|
uses: ./.github/actions/setup-algo
|
|
with:
|
|
install-shellcheck: 'true'
|
|
|
|
- name: Run shellcheck
|
|
run: |
|
|
# Check all shell scripts, not just algo and install.sh
|
|
find . -type f -name "*.sh" -not -path "./.git/*" -exec shellcheck {} \;
|
|
|
|
powershell-lint:
|
|
name: PowerShell script linting
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v5.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Install PowerShell
|
|
run: |
|
|
# Install PowerShell Core
|
|
wget -q https://github.com/PowerShell/PowerShell/releases/download/v7.4.0/powershell_7.4.0-1.deb_amd64.deb
|
|
sudo dpkg -i powershell_7.4.0-1.deb_amd64.deb
|
|
sudo apt-get install -f
|
|
|
|
- name: Install PSScriptAnalyzer
|
|
run: |
|
|
pwsh -Command "Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser"
|
|
|
|
- name: Run PowerShell syntax check
|
|
run: |
|
|
# Check syntax by parsing the script
|
|
pwsh -NoProfile -NonInteractive -Command "
|
|
try {
|
|
\$null = [System.Management.Automation.PSParser]::Tokenize((Get-Content -Path './algo.ps1' -Raw), [ref]\$null)
|
|
Write-Host '✓ PowerShell syntax check passed'
|
|
} catch {
|
|
Write-Error 'PowerShell syntax error: ' + \$_.Exception.Message
|
|
exit 1
|
|
}
|
|
"
|
|
|
|
- name: Run PSScriptAnalyzer
|
|
run: |
|
|
pwsh -Command "
|
|
\$results = Invoke-ScriptAnalyzer -Path './algo.ps1' -Severity Warning,Error
|
|
if (\$results.Count -gt 0) {
|
|
\$results | Format-Table -AutoSize
|
|
exit 1
|
|
} else {
|
|
Write-Host '✓ PSScriptAnalyzer check passed'
|
|
}
|
|
"
|
|
|
|
actionlint:
|
|
name: GitHub Actions linting
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v5.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Install actionlint
|
|
run: |
|
|
bash <(curl -sL https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
|
|
sudo mv actionlint /usr/local/bin/
|
|
|
|
- name: Run actionlint
|
|
run: |
|
|
actionlint .github/workflows/*.yml
|
|
|
|
zizmor:
|
|
name: GitHub Actions security audit
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98 # v5.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Install zizmor
|
|
run: |
|
|
pip install zizmor
|
|
|
|
- name: Run zizmor
|
|
run: |
|
|
zizmor .github/workflows/
|