Skip to content

Development Workflow

Relevant Source Files

This document covers the development workflow, code quality enforcement, and automated testing infrastructure for the NI Compute Subnet project. It details the pre-commit hooks system, branch naming conventions, continuous integration pipeline, and dependency management processes that ensure code quality and consistency across the project.

For information about project structure and organization, see Project Structure. For details about CLI tools used in development, see CLI Tools.

The project uses a comprehensive pre-commit hooks system to enforce code quality standards before commits are made. The configuration is defined in .pre-commit-config.yaml:1-64 and includes multiple stages of validation.

The pre-commit system includes the following hook categories:

Hook CategoryPurposeStage
Code FormattingTrailing whitespace and end-of-file fixespre-commit, manual
Commit ValidationConventional commit message formatcommit-msg
Branch ValidationBranch naming convention enforcementpre-commit, pre-push, manual
Dependency ManagementRequirements file synchronizationpre-commit, manual
TestingAutomated test executionpre-commit, manual
flowchart TD
    DEV["Developer makes commit"] --> PRECOMMIT["pre-commit hooks triggered"]
    
    PRECOMMIT --> WHITESPACE["trailing-whitespace hook"]
    PRECOMMIT --> ENDFILE["end-of-file-fixer hook"]
    PRECOMMIT --> BRANCH["check-branch-name hook"]
    PRECOMMIT --> PIPCOMPILE["pip-compile hooks"]
    PRECOMMIT --> PYTEST["run-pytest hook"]
    
    WHITESPACE --> PASS1{Passes?}
    ENDFILE --> PASS2{Passes?}
    BRANCH --> BRANCHSCRIPT["./scripts/check-current-branch.sh"]
    BRANCHSCRIPT --> PASS3{Passes?}
    PIPCOMPILE --> REQSYNC["Requirements sync"]
    REQSYNC --> PASS4{Passes?}
    PYTEST --> TESTRUN["pytest --alluredir allure-results"]
    TESTRUN --> PASS5{Passes?}
    
    PASS1 -->|No| FAIL["Commit blocked"]
    PASS2 -->|No| FAIL
    PASS3 -->|No| FAIL
    PASS4 -->|No| FAIL
    PASS5 -->|No| FAIL
    
    PASS1 -->|Yes| SUCCESS["All hooks pass"]
    PASS2 -->|Yes| SUCCESS
    PASS3 -->|Yes| SUCCESS
    PASS4 -->|Yes| SUCCESS
    PASS5 -->|Yes| SUCCESS
    
    SUCCESS --> COMMIT["Commit allowed"]
    FAIL --> ABORT["Fix issues and retry"]

Sources: .pre-commit-config.yaml:1-64 , scripts/check-current-branch.sh:1-7

The project enforces strict branch naming conventions through the check-branch-name.sh script, which validates branch names against predefined patterns.

The branch validation system supports the following patterns:

Branch TypePatternExample
Featurefeat/CSN-XXXX-descriptionfeat/CSN-1234-add-gpu-validation
Bug Fixfix/CSN-XXXX-descriptionfix/CSN-5678-memory-leak-issue
Hotfixhotfix/vX.Y.Z-CSN-XXXX-descriptionhotfix/v1.2.3-CSN-9999-critical-fix
Releaserelease/vX.Y.Zrelease/v2.1.0
Chorechore/CSN-XXXX-descriptionchore/CSN-1111-update-dependencies
flowchart TD
    BRANCH_INPUT["Branch name input"] --> EMPTY_CHECK{Empty or HEAD?}
    EMPTY_CHECK -->|Yes| ERROR1["❌ Unable to determine branch name"]
    
    EMPTY_CHECK -->|No| SPECIAL_CHECK{dev or main branch?}
    SPECIAL_CHECK -->|Yes| ALLOW1["✅ Branch allowed without validation"]
    
    SPECIAL_CHECK -->|No| RELEASE_CHECK{Starts with release/?}
    RELEASE_CHECK -->|Yes| RELEASE_PATTERN["Check release/vX.Y.Z pattern"]
    RELEASE_PATTERN --> RELEASE_VALID{Valid?}
    RELEASE_VALID -->|Yes| ALLOW2["✅ Valid release branch"]
    RELEASE_VALID -->|No| ERROR2["❌ Invalid release format"]
    
    RELEASE_CHECK -->|No| HOTFIX_CHECK{Starts with hotfix/?}
    HOTFIX_CHECK -->|Yes| HOTFIX_PATTERN["Check hotfix/vX.Y.Z-CSN-XXXX-desc"]
    HOTFIX_PATTERN --> HOTFIX_VALID{Valid?}
    HOTFIX_VALID -->|Yes| ALLOW3["✅ Valid hotfix branch"]
    HOTFIX_VALID -->|No| ERROR3["❌ Invalid hotfix format"]
    
    HOTFIX_CHECK -->|No| PREFIX_CHECK["Check allowed prefixes"]
    PREFIX_CHECK --> PREFIX_VALID{Valid prefix?}
    PREFIX_VALID -->|No| ERROR4["❌ Invalid prefix"]
    
    PREFIX_VALID -->|Yes| JIRA_CHECK["Extract JIRA ticket CSN-XXXX"]
    JIRA_CHECK --> JIRA_VALID{JIRA found?}
    JIRA_VALID -->|No| ERROR5["❌ Missing JIRA ticket"]
    
    JIRA_VALID -->|Yes| DESC_CHECK["Check description format"]
    DESC_CHECK --> KEBAB_CASE{Lowercase kebab-case?}
    KEBAB_CASE -->|No| ERROR6["❌ Invalid description format"]
    KEBAB_CASE -->|Yes| ALLOW4["✅ Valid branch name"]
    
    ERROR1 --> EXIT1["exit 1"]
    ERROR2 --> EXIT1
    ERROR3 --> EXIT1
    ERROR4 --> EXIT1
    ERROR5 --> EXIT1
    ERROR6 --> EXIT1
    
    ALLOW1 --> EXIT0["exit 0"]
    ALLOW2 --> EXIT0
    ALLOW3 --> EXIT0
    ALLOW4 --> EXIT0

Sources: scripts/check-branch-name.sh:1-114 , .pre-commit-config.yaml:19-26

The validation logic is implemented in scripts/check-branch-name.sh:1-114 with the following key components:

Sources: scripts/check-branch-name.sh:4-16

The development workflow enforces code quality through multiple automated checks that run at different stages of the development process.

graph LR
    subgraph "Pre-commit Stage"
        PC_WHITESPACE["trailing-whitespace"]
        PC_EOF["end-of-file-fixer"]
        PC_BRANCH["check-branch-name"]
        PC_DEPS["pip-compile"]
        PC_TEST["run-pytest"]
    end
    
    subgraph "Commit Message Stage"
        CM_LINT["commitlint"]
        CM_CONV["@commitlint/config-conventional"]
    end
    
    subgraph "Post-checkout Stage"
        PCO_BRANCH["post-checkout-check"]
    end
    
    subgraph "CI/CD Stage"
        CI_PRECOMMIT["pre-commit/[email protected]"]
        CI_PYTHON["Python 3.12 setup"]
        CI_DEPS["Install dependencies"]
    end
    
    PC_WHITESPACE --> COMMIT_READY
    PC_EOF --> COMMIT_READY
    PC_BRANCH --> COMMIT_READY
    PC_DEPS --> COMMIT_READY
    PC_TEST --> COMMIT_READY
    
    COMMIT_READY --> CM_LINT
    CM_LINT --> CM_CONV
    CM_CONV --> COMMITTED
    
    COMMITTED --> PCO_BRANCH
    PCO_BRANCH --> CHECKOUT_COMPLETE
    
    CHECKOUT_COMPLETE --> CI_PYTHON
    CI_PYTHON --> CI_DEPS
    CI_DEPS --> CI_PRECOMMIT
    CI_PRECOMMIT --> PIPELINE_SUCCESS

Sources: .pre-commit-config.yaml:1-64 , .github/workflows/pre-commit.yml:1-22

The pre-commit system includes automated test execution using pytest with Allure reporting:

Sources: .pre-commit-config.yaml:56-63

The project uses GitHub Actions for continuous integration, with the workflow defined in .github/workflows/pre-commit.yml:1-22 .

ConfigurationValuePurpose
Trigger Eventspull_request, push to dev/mainAutomated validation on key events
Runnerubuntu-latestConsistent Linux environment
Python Version3.12Latest stable Python version
Cache Strategypip with pyproject.toml, requirements*.txtDependency caching for performance
sequenceDiagram
    participant TRIGGER as "PR/Push Event"
    participant RUNNER as "ubuntu-latest Runner"
    participant PYTHON as "Python 3.12 Setup"
    participant CACHE as "Pip Cache"
    participant DEPS as "Dependencies"
    participant PRECOMMIT as "pre-commit/action"
    
    TRIGGER->>RUNNER: "Start CI job"
    RUNNER->>PYTHON: "Setup Python 3.12"
    PYTHON->>CACHE: "Check pip cache"
    CACHE->>DEPS: "Install -e .[dev] -r requirements*.txt"
    DEPS->>PRECOMMIT: "Run pre-commit hooks"
    PRECOMMIT->>RUNNER: "Report results"
    RUNNER->>TRIGGER: "Complete CI job"

Sources: .github/workflows/pre-commit.yml:8-22

The project uses pip-tools for dependency management with automated synchronization through pre-commit hooks.

The dependency management system includes two compilation targets:

flowchart TD
    PYPROJECT["pyproject.toml changes"] --> PRECOMMIT_TRIGGER["pre-commit triggered"]
    
    PRECOMMIT_TRIGGER --> PROD_COMPILE["pip-compile hook"]
    PRECOMMIT_TRIGGER --> DEV_COMPILE["pip-compile-dev hook"]
    
    PROD_COMPILE --> PROD_CMD["python -m piptools compile --quiet -o requirements.txt"]
    DEV_COMPILE --> DEV_CMD["python -m piptools compile --quiet --extra dev -o requirements-dev.txt"]
    
    PROD_CMD --> REQ_FILE["requirements.txt updated"]
    DEV_CMD --> REQ_DEV_FILE["requirements-dev.txt updated"]
    
    REQ_FILE --> COMMIT_READY["Dependencies synchronized"]
    REQ_DEV_FILE --> COMMIT_READY
    
    COMMIT_READY --> COMMIT_SUCCESS["Commit proceeds"]

Sources: .pre-commit-config.yaml:38-53

The CI/CD pipeline installs dependencies in the following order as defined in .github/workflows/pre-commit.yml:20 :

  1. pip install -e .[dev] - Install package in development mode with dev extras
  2. -r requirements.txt - Install production dependencies
  3. -r requirements-dev.txt - Install development dependencies

Sources: .github/workflows/pre-commit.yml:20