From d62144fa9f1eee9a408175307b40fd84c3fc3703 Mon Sep 17 00:00:00 2001 From: Ambient Code Bot Date: Sat, 30 May 2026 07:32:47 +0000 Subject: [PATCH 1/7] Add AGENTS.md and CLAUDE.md for AI agent onboarding Adds a minimal ~60 line AGENTS.md file documenting project structure, key files, commands, and architecture for AI coding assistants. Includes test structure and pytest commands. CLAUDE.md is a symlink to AGENTS.md. Co-Authored-By: Claude Opus 4.5 --- AGENTS.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ CLAUDE.md | 1 + 2 files changed, 67 insertions(+) create mode 100644 AGENTS.md create mode 120000 CLAUDE.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..62782b8 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,66 @@ +# iib-tekton-utils + +Tekton task for building multi-architecture Operator Index Images (IIB) using Python orchestration with buildah. + +## What This Does + +Builds container images for OLM file-based catalogs across multiple architectures (amd64, arm64, ppc64le, s390x), generates OPM cache, and pushes multi-arch manifest lists. + +## Tech Stack + +- Python 3.9+ (orchestration) +- Tekton Tasks (Kubernetes CI/CD) +- Buildah (container builds) +- OPM (Operator Package Manager) +- pytest (testing) + +## Key Files + +- `task/iib-image-builder-oci-ta/iib-image-builder-oci-ta.yaml` - Tekton Task definition +- `task/iib-image-builder-oci-ta/multi-arch-builder.py` - Python build orchestrator +- `Containerfile.iib-build-task` - Container image for the build task +- `pyproject.toml` - Project config and test dependencies + +## Directory Structure + +``` +task/iib-image-builder-oci-ta/ # Tekton task + Python script +tests/ + conftest.py # Shared fixtures, module loader for hyphenated filename + unit/test_multi_arch_builder.py # Unit tests for Python script + tekton/test_iib_image_builder_task.py # YAML structure validation +.github/workflows/ # CI workflows +``` + +## Commands + +```bash +# Install test dependencies +pip install ".[test]" + +# Run all tests +pytest + +# Run unit tests only +pytest tests/unit/ + +# Run Tekton task validation tests only +pytest tests/tekton/ + +# Build container image +buildah build -f Containerfile.iib-build-task -t iib-build-task:latest . +``` + +## Architecture Notes + +- `MultiArchBuilder` class in multi-arch-builder.py:201 orchestrates the build +- `generate_cache_locally()` at :144 runs OPM to create FBC cache +- Retry logic via tenacity for buildah operations (:271, :365) +- Exception hierarchy: `IIBBaseException` > `IIBError`, `ExternalServiceError` +- Tests use `conftest.py` to load hyphenated `multi-arch-builder.py` via importlib + +## Test Coverage + +- Unit tests mock all subprocess/filesystem calls (no container runtime needed) +- Tekton tests validate YAML structure with pyyaml (no cluster needed) +- Key fixtures: `build_config`, `builder` (conftest.py:46, :62) diff --git a/CLAUDE.md b/CLAUDE.md new file mode 120000 index 0000000..47dc3e3 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1 @@ +AGENTS.md \ No newline at end of file From ab807e64ba07d9d689c0a835d01b8b1df6803180 Mon Sep 17 00:00:00 2001 From: Ambient Code Bot Date: Sun, 31 May 2026 04:24:32 +0000 Subject: [PATCH 2/7] chore: add .gitignore with Python patterns Adds standard Python .gitignore patterns for: - __pycache__ and bytecode files - Virtual environments - Testing artifacts - IDE files - AgentReady reports Co-Authored-By: Claude Opus 4.5 --- .gitignore | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..25bc25d --- /dev/null +++ b/.gitignore @@ -0,0 +1,47 @@ +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# Virtual environments +.venv/ +venv/ +ENV/ + +# Testing +.pytest_cache/ +.coverage +htmlcov/ +.tox/ +.nox/ + +# IDE +.idea/ +.vscode/ +*.swp +*.swo +*~ + +# OS +.DS_Store +Thumbs.db + +# AgentReady reports +.agentready/ From 489d4dae62a7fad15ce8fe94208ff26aa077be4e Mon Sep 17 00:00:00 2001 From: Ambient Code Bot Date: Sun, 31 May 2026 04:24:35 +0000 Subject: [PATCH 3/7] chore: add PR and issue templates Adds GitHub templates for better issue/PR workflows: - PULL_REQUEST_TEMPLATE.md with summary, testing checklist - bug_report.md issue template - feature_request.md issue template Co-Authored-By: Claude Opus 4.5 --- .github/ISSUE_TEMPLATE/bug_report.md | 39 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 23 +++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 17 ++++++++++ 3 files changed, 79 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..9ae6a71 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,39 @@ +--- +name: Bug Report +about: Report a bug in the Tekton task or Python script +title: '[BUG] ' +labels: bug +assignees: '' +--- + +## Description + + + +## Steps to Reproduce + +1. +2. +3. + +## Expected Behavior + + + +## Actual Behavior + + + +## Environment + +- OCP/Kubernetes version: +- Tekton version: +- OPM version: + +## Logs + + + +``` +paste logs here +``` diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..d42f16c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,23 @@ +--- +name: Feature Request +about: Suggest a new feature or enhancement +title: '[FEATURE] ' +labels: enhancement +assignees: '' +--- + +## Description + + + +## Use Case + + + +## Proposed Solution + + + +## Alternatives Considered + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..a7a80d3 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,17 @@ +## Summary + + + +## Related Issues + + + +## Testing + +- [ ] Tests added/updated +- [ ] All tests pass (`pytest`) + +## Checklist + +- [ ] Code follows project conventions +- [ ] Documentation updated if needed From 12bbf75d98b9b7f7349f9fa48d31fff8f8c8d83f Mon Sep 17 00:00:00 2001 From: Ambient Code Bot Date: Sun, 31 May 2026 04:24:39 +0000 Subject: [PATCH 4/7] chore: add Dependabot configuration Configures Dependabot for automated security updates: - Weekly pip dependency updates - Weekly GitHub Actions updates Co-Authored-By: Claude Opus 4.5 --- .github/dependabot.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..b0f5089 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,13 @@ +version: 2 +updates: + - package-ecosystem: pip + directory: / + schedule: + interval: weekly + open-pull-requests-limit: 5 + + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + open-pull-requests-limit: 5 From d31352c5571aa0b6a2eb0742f0e483e288a01428 Mon Sep 17 00:00:00 2001 From: Ambient Code Bot Date: Sun, 31 May 2026 04:24:42 +0000 Subject: [PATCH 5/7] chore: add pre-commit configuration Configures pre-commit hooks for code quality: - trailing-whitespace, end-of-file-fixer - check-yaml, check-added-large-files - ruff linter and formatter - conventional-pre-commit for commit message validation Co-Authored-By: Claude Opus 4.5 --- .pre-commit-config.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..e7cd9da --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.4.4 + hooks: + - id: ruff + args: [--fix] + - id: ruff-format + + - repo: https://github.com/compilerla/conventional-pre-commit + rev: v3.2.0 + hooks: + - id: conventional-pre-commit + stages: [commit-msg] From 63825aec87c20390b644bb6d76ab8042e706762e Mon Sep 17 00:00:00 2001 From: Ambient Code Bot Date: Sun, 31 May 2026 04:24:46 +0000 Subject: [PATCH 6/7] chore: add requirements.txt with pinned versions Adds pinned dependency versions for reproducible builds: - tenacity==8.2.3 (runtime) - pytest==8.2.1, pytest-mock==3.14.0, PyYAML==6.0.1 (test) Co-Authored-By: Claude Opus 4.5 --- requirements.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..a2b9156 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,10 @@ +# Pinned dependencies for reproducible builds +# Generated from pyproject.toml + +# Runtime dependencies +tenacity==8.2.3 + +# Test dependencies +pytest==8.2.1 +pytest-mock==3.14.0 +PyYAML==6.0.1 From 7fbc51e073b3a5ef86fb07927c9554a4c8414b7b Mon Sep 17 00:00:00 2001 From: Ambient Code Bot Date: Sun, 31 May 2026 04:24:50 +0000 Subject: [PATCH 7/7] docs: add single-file verification and pattern references to AGENTS.md Updates AGENTS.md with: - Single-file lint command (ruff check) - Single-file type check command (mypy) - Pre-commit setup command - Pattern References section for common changes Co-Authored-By: Claude Opus 4.5 --- AGENTS.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 62782b8..219e38f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -47,10 +47,25 @@ pytest tests/unit/ # Run Tekton task validation tests only pytest tests/tekton/ +# Single-file lint (fast feedback) +ruff check task/iib-image-builder-oci-ta/multi-arch-builder.py + +# Single-file type check +mypy task/iib-image-builder-oci-ta/multi-arch-builder.py + # Build container image buildah build -f Containerfile.iib-build-task -t iib-build-task:latest . + +# Setup pre-commit hooks +pip install pre-commit && pre-commit install ``` +## Pattern References + +- **Adding a new Tekton parameter**: Follow pattern in `task/iib-image-builder-oci-ta/iib-image-builder-oci-ta.yaml:17-58` +- **Adding retry logic**: See `_build_image()` at multi-arch-builder.py:271 for tenacity decorator pattern +- **Adding a new test class**: Follow `TestRunCmd` pattern in tests/unit/test_multi_arch_builder.py:66 + ## Architecture Notes - `MultiArchBuilder` class in multi-arch-builder.py:201 orchestrates the build