Skip to content

feat: automate and standardize repository setup#54

Merged
c-vigo merged 179 commits intodevfrom
feature/37-automate-standardize-repository-setup
Feb 17, 2026
Merged

feat: automate and standardize repository setup#54
c-vigo merged 179 commits intodevfrom
feature/37-automate-standardize-repository-setup

Conversation

@c-vigo
Copy link
Contributor

@c-vigo c-vigo commented Feb 12, 2026

Description

Fully automate and standardize the repository setup for the devcontainer template. This PR delivers the complete infrastructure for commit message validation, branch naming enforcement, automated release cycles, CI/CD pipelines, security hardening, and code coverage — establishing a reproducible, audit-ready starting point for all projects.

Related Issue(s)

Closes #37

Related to #36, #38, #48, #50, #52

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Test updates

Changes Made

Commit Message Standardization (#36)

  • Conventional Commits format (type(scope)!: subject) with mandatory Refs: #<issue> line
  • docs/COMMIT_MESSAGE_STANDARD.md defining format, approved types, and traceability requirements
  • scripts/validate_commit_msg.py validation script with .githooks/commit-msg hook
  • Pre-commit integration, .gitmessage template, and Cursor rules/commands
  • chore commits may omit Refs: when no issue is directly related
  • Full workspace template included in assets/workspace/

Branch Naming Enforcement (#38)

  • Pre-commit hook enforcing <type>/<issue>-<summary> naming convention
  • Cursor rules (.cursor/rules/branch-naming.mdc) for branch naming workflow and gh issue develop integration
  • Integration tests for valid and invalid branch names

Automated Release Cycle (#48)

  • prepare-release and finalize-release justfile commands triggering GitHub Actions workflows
  • prepare-changelog.py with prepare, validate, reset, and finalize commands
  • prepare-release.yml workflow: validates semantic version, creates release branch, prepares CHANGELOG
  • Unified release.yml pipeline: validate → finalize → build/test → publish → rollback
  • post-release.yml workflow for post-merge cleanup
  • Comprehensive docs/RELEASE_CYCLE.md documentation

CI/CD Infrastructure (#48)

  • ci.yml workflow replacing test.yml with streamlined project checks
  • Reusable composite actions: setup-env, build-image, test-image, test-integration, test-project
  • Artifact transfer between jobs for consistent image testing
  • Retry logic across all CI operations for transient failure handling
  • Consolidated test files by domain (6 → 4 files)
  • Replaced setup-python-uv with flexible setup-env composite action

Security Hardening (#50)

  • Containerfile hardened with digest-pinned base image and SHA256 checksum verification for all binaries
  • Minisign signature verification for cargo-binstall
  • GitHub Actions and Docker actions pinned to commit SHAs across all workflows
  • Pre-commit hook repos pinned to commit SHAs
  • scripts/check_action_pins.py enforcement script with pre-commit hook and CI check
  • Workflow permissions hardened with least-privilege principle
  • Input sanitization: inline expression interpolation replaced with env variables
  • SECURITY.md with vulnerability reporting procedures
  • CODEOWNERS for automated review assignment
  • dependabot.yml for automated dependency update PRs
  • OpenSSF Scorecard (scorecard.yml) and CodeQL analysis (codeql.yml) workflows
  • Vulnerability scanning and dependency review in CI pipeline
  • SBOM generation, container signing (cosign), and provenance attestation in release workflow

Code Coverage (#52)

  • Coverage measurement integrated into test-project action
  • Coverage threshold raised to 50%
  • Expanded unit tests for utils.py, validate_commit_msg.py, and prepare_changelog.py

Additional Improvements

Testing

  • Tests pass locally (just test)

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly (README.md, CONTRIBUTE.md, etc.)
  • I have updated the CHANGELOG.md in the [Unreleased] section
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

This is a large feature branch (70 files changed, ~10,300 insertions, ~1,800 deletions) that consolidates work from multiple sub-issues (#36, #38, #48, #50, #52) into the umbrella issue #37. The branch includes all infrastructure needed to make the devcontainer template self-enforcing and audit-ready from day one, targeting medical-device compliance (IEC 62304 / ISO 13485).

Key files added/changed

Area Key files
Commit standard docs/COMMIT_MESSAGE_STANDARD.md, scripts/validate_commit_msg.py, .githooks/commit-msg
Branch enforcement .cursor/rules/branch-naming.mdc, .pre-commit-config.yaml
Release cycle docs/RELEASE_CYCLE.md, scripts/prepare-changelog.py, .github/workflows/release.yml, prepare-release.yml, post-release.yml
CI/CD .github/workflows/ci.yml, .github/actions/{setup-env,build-image,test-image,test-integration,test-project}/action.yml
Security SECURITY.md, .github/CODEOWNERS, .github/dependabot.yml, scripts/check_action_pins.py, .github/workflows/{codeql,scorecard}.yml
Tests tests/test_validate_commit_msg.py, tests/test_check_action_pins.py, tests/test_prepare_changelog.py, tests/test_utils.py, tests/test_integration.py

c-vigo and others added 30 commits January 30, 2026 11:38
- Exclude issue and template docs from .github_data
- Autofix shellcheck
- Autofix pymarkdown
- Add license compliance check
- Added pre-commit hook for enforcing branch naming convention
- Updated pre-commit configuration in the repository and workspace
- Included integration tests for branch name validation
- Documented cursor rules for branch naming and issue workflow
…trategy-enforcement

Standardize and enforce branch names
- Introduced a comprehensive document outlining the commit message format for the repository.
- Defined structure, approved types, and compliance requirements to ensure consistency and traceability.
- Included guidelines for enforcing the standard in development environments and CI.

Refs: #36
- Introduced a new script to validate commit messages against the project's standard.
- Added a corresponding test suite to ensure the validation logic works correctly.
- Added test recipe to justfile
- Updated documentation to include the new validation command in the available recipes.

Refs: #36
- Modified init.sh to Install git template locally during project setup

Refs: #36
- Introduced a detailed guide for the Git commit workflow, outlining steps for analyzing staged changes and writing accurate commit messages.
- Added rules for commit message formatting, including mandatory structure and compliance requirements to ensure consistency.

Refs: #36
- Introduced a new commit-msg hook script to enforce commit message standards when committing within the development container.
- Updated init.sh to ensure the new hook is executable during setup.

Refs: #36
- Updated the validation script to require that GitHub issue references in commit messages use the '#' symbol (e.g., #36).
- Added a test case to ensure that commit messages without the hashtag in the Refs line are correctly identified as invalid.

Refs: #36
- Updated commit message guidelines to eliminate the requirement for a trailing newline at the end of the message.
- Adjusted validation logic and corresponding tests to reflect this change, ensuring commit messages can be valid without a trailing newline.

Refs: #36
- Added a new hook to validate commit messages during the commit-msg stage, ensuring adherence to the project's standards.
- The hook executes a Python script to perform the validation.

Refs: #36
…ages

feat: add commit message standardization (#36)
- Introduced a new test to verify that the .venv/bin/activate script does not contain 'template-project' and is correctly renamed to 'test_project' during container initialization.
- Updated the test placeholders to include the post-create.sh script in the devcontainer configuration.

Refs: #34
- Added a line to replace 'template-project' with '{{SHORT_NAME}}' in the .venv/bin/activate script during container initialization.

Refs: #34
- Added 'norecursedirs' entry to prevent tests from being collected from the 'tmp' directory, which is used for integration-test workspace directories with template tests.

Refs: #34
…reation

feat: rename venv prompt to project name on container creation (#34)
- Install just-lsp via cargo-binstall for justfile language support
- Replace promptexecution.justlang-lsp with nefrob.vscode-just-syntax
- Add test for just-lsp binary

Refs: #44
- Git commit sometimes requires an editor for interactive operations.
- Install nano package in Containerfile
- Add test to verify nano installation

Refs: #37
- Updated the expected versions for 'uv' from 0.9. to 0.10. and 'ruff' from 0.14. to 0.15. to reflect the latest releases.

Refs: #37
- Changed the instruction to suggest a git commit command for user review instead of executing it directly.
- Added notes to avoid using specific flags like `--trailer` and `--no-verify`.

Refs: #36, #37
- Introduced a new test to verify that pip-licenses is installed and checks its version against the expected value.
- Updated the expected versions dictionary to include pip-licenses.

Refs: #43
- Updated the Containerfile to include pip-licenses in the system installation alongside ruff.
- This change ensures that pip-licenses is available for license management in the container.
- Fixes #43

Refs: #43
- Call copy-host-user-conf.sh after workspace initialization
- Add run_user_conf() helper for host-side setup (git, ssh, gh)
- Add integration tests for .devcontainer/.conf/ directory creation
- Verify expected config files and gh/ subdirectory

Refs: #35
- Add setup_git_repo function to initialize git if missing
- Create initial commit "chore: initial project scaffold" for new repos
- Create main and dev branches automatically
- Add test-install justfile recipe for running install tests
- Add tests for git repo initialization, branches, and initial commit
- Update README.md and CONTRIBUTE.md with new test-install recipe

Refs: #35
- Implement conditional execution of BATS tests using GNU parallel for improved performance
- Update justfile to check for parallel availability and run tests accordingly
- Add parallel installation instructions to requirements.yaml for user convenience
-Remove old QEMU requirement for multi-arch builds

Refs: #35
- Consolidated Podman installation with other apt commands
- Updated git initialization to set the default branch to 'main'

Refs: #35
Add comprehensive BATS test suites for build, clean, init, install, and prepare-build scripts. Tests verify script structure, argument parsing, function definitions, error handling, and OS/runtime detection patterns using static analysis.

Refs: #35
Add BATS (Bash Automated Testing System) support to CI workflows:
- setup-env action: new install-bats input with bats-core/bats-action
- test-project action: enable BATS installation and run BATS tests
- test_helper.bash: support both local (node_modules) and CI (BATS_LIB_PATH) library resolution

Refs: #35
The bats-action installs libraries to /usr/lib but never exports
BATS_LIB_PATH, causing all 216 BATS tests to fail with
"Could not find library 'bats-support'".

Refs: #35
copy-host-user-conf.sh only creates .gh_token, SSH key, allowed-signers,
and gh/ when the corresponding tools are configured on the host. In CI
these preconditions are not met, causing a hard assertion failure.

Split expected files into required (git config, always created) and
optional (warn instead of fail when missing).

Refs: #35
Allow GHSA-wvrr-2x4r-394v (bats-file false positive) via a new
exceptions file that mirrors .trivyignore conventions. A validation
step parses expiration dates and fails CI when exceptions expire,
forcing periodic review.

Refs: #37
The bats-core/bats-action step output was not being correctly captured,
causing all 216 BATS tests to fail with "Could not find library 'bats-support'".
Manually construct BATS_LIB_PATH pointing to standard installation directories
since the libraries are consistently installed to /usr/lib paths.

Refs: #37
Added exception for GHSA-fjxv-7rqg-78g4 (CVE-2025-7783) affecting form-data@2.3.3.
This is a transitive dependency through unmaintained legacy packages (verbose, reconnect, request).
Risk is limited to CI/test environment; exploit requires active MITM + attacker control of request field.
Expiration set to 2026-05-17 to force periodic review and investigation of BATS alternatives.

Refs: #37
Added entry documenting the GHSA-fjxv-7rqg-78g4 (CVE-2025-7783) exception
with risk assessment, dependency chain, and expiration details.

Refs: #37
…encies

Add GHSA-h4j5-c7cj-74xg (xmlhttprequest@1.5.0 arbitrary code injection) to dependency review exceptions.

This vulnerability appears only in unmaintained legacy test dependencies (bats-assert → verbose → engine.io-client@0.7.12 → xmlhttprequest@1.5.0) and is isolated to CI-only usage with no execution of untrusted code. Part of ongoing BATS framework modernization efforts.

Refs: #37
The test helper was failing to load BATS support libraries in GitHub Actions
because it relied on bats_load_library, which requires BATS internal functions
to be fully initialized. These functions may not be available when the test
helper loads during the setup phase.

Changed the library resolution to use absolute paths for system-installed
libraries (/usr/lib/bats-*) before falling back to bats_load_library. This
ensures libraries are found in CI environments where bats-core/bats-action
installs them to standard system paths.

Library resolution order:
1. Local node_modules (development mode)
2. System /usr/lib paths (CI mode via bats-core/bats-action)
3. bats_load_library (fallback using BATS_LIB_PATH)

Fixes: All 216 BATS tests failing with "Could not find library 'bats-support'"

Refs: #37
- Update CHANGELOG
- Documented risk assessments and mitigations in SECURITY.md d

Refs: #37
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements comprehensive repository setup automation for medical-device compliance, consolidating work from issues #36, #38, #48, #50, and #52. It establishes commit message standardization, branch naming enforcement, automated release cycles, CI/CD infrastructure, security hardening, and code coverage measurement.

Changes:

  • Commit message standardization with validation hooks and documentation
  • Branch naming enforcement via pre-commit hooks and Cursor integration
  • Automated release workflow with CHANGELOG management and GitHub Actions
  • Reusable composite GitHub Actions for CI/CD (setup-env, build-image, test-image, test-integration, test-project)
  • Security hardening: SHA-pinned actions, digest-pinned Containerfile, Dependabot, SECURITY.md, CODEOWNERS
  • Code coverage integration with 50% threshold and expanded unit tests
  • Additional tooling: nano, just-lsp, pip-licenses, vig-utils package, BATS shell tests

Reviewed changes

Copilot reviewed 90 out of 93 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
justfile Updated release commands, fixed TEST_REGISTRY usage (CRITICAL BUG)
justfile.podman Standardized output formatting (minor text duplication bugs)
Containerfile Digest-pinned base image, SHA256 checksums, minisign verification
.github/workflows/* New workflows: ci.yml, security-scan.yml, scorecard.yml, codeql.yml, post-release.yml
.github/actions/* Composite actions for CI reusability
scripts/* New: prepare-changelog.py, check_action_pins.py; Updated: prepare-build.sh, build.sh
packages/vig-utils/* New Python package with CLI tools (validate-commit-msg, check-action-pins, prepare-changelog)
tests/* Expanded pytest tests, new BATS shell tests
docs/* New: COMMIT_MESSAGE_STANDARD.md, CONTAINER_SECURITY.md, SECURITY.md
.pre-commit-config.yaml SHA-pinned repos, branch naming enforcement, commit-msg validation
pyproject.toml Coverage config, vig-utils dependency
install.sh --org flag, git repo setup, host user config

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Eliminated shell injection vulnerability in install.sh by:
1. Sanitizing ORG_NAME using the existing sanitize_name function to strip shell metacharacters
2. Refactoring command construction from string interpolation to bash array
3. Replacing eval execution with safe array expansion "${CMD[@]}"

This prevents attackers from injecting arbitrary shell commands via crafted --org argument values.

Refs: #37
- Change FORCE flag comparison from equality to existence check (better for string vars)
- Replace multi-line array printing with explicit full command output in dry-run mode
- Ensure --force flag is properly appended only when present

Refs: #37
@c-vigo c-vigo merged commit c034fa9 into dev Feb 17, 2026
11 checks passed
@c-vigo c-vigo deleted the feature/37-automate-standardize-repository-setup branch February 17, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants