Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# EditorConfig: https://editorconfig.org
# A trusted VS Code EditorConfig extension can enforce these on save,
# converting CRLF to LF in any file opened in the editor.
root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

[Makefile]
indent_style = tab

[*.{groovy,gradle}]
indent_size = 4
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Enforce LF endings for tracked text files to prevent CRLF regressions.
* text=auto eol=lf
49 changes: 49 additions & 0 deletions .github/workflows/bootstrap-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,54 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install Linux setup prerequisites
run: |
sudo apt-get update
sudo apt-get install -y python3-yaml

- name: Run bootstrap checks
run: bash bin/run-checks.sh

- name: Smoke test Python setup engine
run: |
mkdir -p tmp-ci-python-workspace
cd tmp-ci-python-workspace
python3 ../bin/ide-workspace-setup.py
python3 ../bin/ide-workspace-setup.py --apply
test -f .vscode/settings.json
test -f .vscode/extensions.json
test -f cspell.config.yaml
test -f vscode-project-words.txt

- name: Smoke test shell wrapper
run: |
mkdir -p tmp-ci-shell-workspace
cd tmp-ci-shell-workspace
bash ../bin/ide-workspace-setup.sh

validate-windows-bootstrap:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Validate Windows bootstrap prerequisites
shell: pwsh
run: .\bin\bootstrap-windows-dev.ps1 -ValidateOnly

- name: Smoke test PowerShell wrapper
shell: pwsh
run: |
New-Item -ItemType Directory -Path tmp-ci-windows-workspace | Out-Null
Push-Location tmp-ci-windows-workspace
try {
& ..\bin\ide-workspace-setup.ps1
& ..\bin\ide-workspace-setup.ps1 -Apply
if (-not (Test-Path .vscode\settings.json)) { throw 'Missing .vscode/settings.json' }
if (-not (Test-Path .vscode\extensions.json)) { throw 'Missing .vscode/extensions.json' }
if (-not (Test-Path cspell.config.yaml)) { throw 'Missing cspell.config.yaml' }
if (-not (Test-Path vscode-project-words.txt)) { throw 'Missing vscode-project-words.txt' }
}
finally {
Pop-Location
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/zzz-*
.vscode/
/local_ide_settings.yml
50 changes: 41 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Shared linting, check, and IDE bootstrap assets for this and other repositories.

This repository exists to help the team implement coding practices they have
agreed on. Content is added here only after team agreement, typically through
the PR review process.

This repository is designed to be consumed as a git submodule.
Consumer repositories add it as a top-level `code_checking/` directory and
keep local wrapper scripts and `.github/workflows` in their own tree.
Expand All @@ -10,7 +14,7 @@ keep local wrapper scripts and `.github/workflows` in their own tree.

- Provide reusable, generic check scripts across repositories
- Keep check behavior consistent for CLI, pre-commit, and GitHub Actions
- Provide IDE baseline guidance and profile overlays
- Provide IDE baseline guidance and a single YAML customization input
- Reduce duplicate checker logic and drift between repositories

## Non-Goals
Expand All @@ -25,6 +29,15 @@ keep local wrapper scripts and `.github/workflows` in their own tree.
- Visibility: Public
- Primary maintainer group: DAOS-DO/Developers

## Local Scratch Files

- Repository-local scratch files should use a `zzz-` prefix.
- Scratch files are for temporary planning notes, draft commit messages, and
similar local work in progress.
- Scratch files must not be committed to the repository.
- Root-level `zzz-*` files are ignored through the tracked `.gitignore` so
`git status` stays focused on commit candidates.

## Checker Behavior Policy

- Checks are non-mutating by default.
Expand All @@ -36,6 +49,12 @@ keep local wrapper scripts and `.github/workflows` in their own tree.

Add this repository as a top-level submodule in a consumer repository:

- Commands in this README that reference `code_checking/` assume the submodule
directory is named `code_checking`.
- If your submodule uses a different directory name, replace that path prefix
in commands.
- Run submodule-integration commands from the consumer repository root.

```bash
git submodule add https://github.com/daos-do/code-checking code_checking
git submodule update --init --recursive
Expand All @@ -57,17 +76,30 @@ Consumer repositories keep:
Shared scripts in this repository are invoked by those local wrappers and
workflows.

## Initial Consumer Targets
Maintenance planning notes are documented in
[docs/maintenance.md](docs/maintenance.md).

## IDE Customization

- Run commands from the base directory of the consumer repository clone.
- Use your chosen submodule directory name as the path prefix for scripts and
reference files in this repository.
- If you want local overrides, keep an optional user-maintained file at
`./local_ide_settings.yml` in the directory where setup is run.
- `./local_ide_settings.yml` is intentionally untracked and belongs in
`.gitignore`; it should not be committed.
- Run the bootstrap script for your platform first, then run
`ide-workspace-setup` in dry-run mode before `--apply`.
- If you are developing this repository directly rather than using it as a
submodule, drop the `code_checking/` path prefix from commands.

- `ansible-lab`
- `system-pipeline-lib`
Detailed usage is in [docs/usage.md](docs/usage.md).

## Planned Content Areas
Recommended VS Code extensions and platform-specific tool requirements are
documented in [docs/vscode-extensions.md](docs/vscode-extensions.md).

- Shell and PowerShell check runners
- Check script library (ansible-lint, yamllint, shellcheck, markdownlint,
groovylint, codespell)
- IDE setup baselines and profile overlays for VS Code
Configuration model details are in
[docs/ide-customization.md](docs/ide-customization.md).

## Cross-Repo Reuse

Expand Down
93 changes: 93 additions & 0 deletions bin/bootstrap-python.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

function Test-PythonCommand {
param(
[Parameter(Mandatory = $true)][string]$Command,
[switch]$UsePyLauncher
)

$cmd = Get-Command $Command -ErrorAction SilentlyContinue
if (-not $cmd) {
return $null
}

try {
if ($UsePyLauncher) {
$versionOut = & $Command '-3' '--version' 2>&1
}
else {
$versionOut = & $Command '--version' 2>&1
}
if ($LASTEXITCODE -ne 0) {
return $null
}
return @{
Command = $Command
Path = $cmd.Source
Version = ($versionOut | Out-String).Trim()
}
}
catch {
return $null
}
}

Write-Host '[bootstrap-python] checking for Python 3 runtime'

$detected = Test-PythonCommand -Command 'py' -UsePyLauncher
if (-not $detected) {
$detected = Test-PythonCommand -Command 'python'
}

if ($detected) {
Write-Host "[bootstrap-python] found: $($detected.Command)"
Write-Host "[bootstrap-python] path: $($detected.Path)"
Write-Host "[bootstrap-python] version: $($detected.Version)"
Write-Host '[bootstrap-python] Python bootstrap check passed'
exit 0
}

Write-Host '[bootstrap-python] Python 3 not found; attempting install via winget'

$winget = Get-Command winget -ErrorAction SilentlyContinue
if (-not $winget) {
Write-Error @'
[bootstrap-python] Python 3 not found and winget is not available.

Install Python 3 manually, then rerun this script.
Recommended command:
winget install -e --id Python.Python.3.12
'@
exit 1
}

& winget install -e --id Python.Python.3.12 --accept-package-agreements --accept-source-agreements
if ($LASTEXITCODE -ne 0) {
Write-Error "[bootstrap-python] winget install failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}

Write-Host '[bootstrap-python] rechecking Python runtime after install'
$detected = Test-PythonCommand -Command 'py' -UsePyLauncher
if (-not $detected) {
$detected = Test-PythonCommand -Command 'python'
}

if (-not $detected) {
Write-Error @'
[bootstrap-python] Python install appears complete, but python is not yet on PATH.

Open a new terminal and rerun bootstrap-python.ps1.

Future enhancement:
- add a separate script for controlled Python runtime updates.
'@
exit 1
}

Write-Host "[bootstrap-python] found: $($detected.Command)"
Write-Host "[bootstrap-python] path: $($detected.Path)"
Write-Host "[bootstrap-python] version: $($detected.Version)"
Write-Host '[bootstrap-python] Python bootstrap install/check passed'
exit 0
21 changes: 21 additions & 0 deletions bin/bootstrap-python.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail

echo "[bootstrap-python] checking for Python 3 runtime"

if ! command -v python3 >/dev/null 2>&1; then
cat >&2 <<'EOF'
[bootstrap-python] Python 3 was not found.

Install Python 3, then open a new terminal and rerun this script.

Examples:
- Ubuntu/Debian: sudo apt install python3
- macOS (Homebrew): brew install python
EOF
exit 1
fi

echo "[bootstrap-python] found: python3"
echo "[bootstrap-python] version: $(python3 --version)"
echo "[bootstrap-python] Python bootstrap check passed"
Loading
Loading