Skip to content

[azuredevops_go] Pipeline: đóng gap so với Python plugin (environment_pattern) #4

@magiskboy

Description

@magiskboy

Bối cảnh

azuredevops_go đã cover phần lớn Pipeline (builds incremental, timeline → cicd_pipelines/cicd_tasks, deployment/production regex cho DORA). Issue này đóng gap còn lại so với Python plugin.

Phạm vi: Pipeline / CI/CD — builds, timeline jobs, deployment detection (không bao gồm Board/TICKET).


Hiện trạng (đã có ✅)

  • collectBuilds — incremental qua minTime + continuation token
  • collectApiTimelineRecords — per-build timeline, skip 404/empty (YAML error builds)
  • convertApiBuildscicd_pipelines, cicd_pipeline_commits
  • convertApiTimelineRecordscicd_tasks
  • deploymentPattern / productionPattern trong scope config → RegexEnricher → DORA cicd_deployment_commits
  • E2E: build_test.go, timeline_records_test.go

Gap so với Python

1. environment_pattern (ưu tiên cao)

Python plugin (azuredevops/streams/jobs.py) hỗ trợ regex extract tên environment từ job/stage name:

# scope config
environment_pattern: Optional[re.Pattern]
# ví dụ: r'(?:deploy|predeploy)[_-](.+?)(?:[_-](?:helm|terraform))?$'

Dùng trong converter để set cicd_tasks.environment chính xác hơn productionPattern match trên tên job.

Tasks:

  • Thêm EnvironmentPattern string vào models/scope_config.go
  • Load vào RegexEnricher trong impl/PrepareTaskData (hoặc logic riêng như Python extract_environment_name)
  • Áp dụng trong ci_cd_timeline_records_converter.go khi set CICDTask.Environment
  • Thêm field vào Config UI azure/transformation.tsx (section CI/CD)
  • Migration script cho scope config table

2. Filter timeline record type

Python chỉ collect type in ("Job", "Stage"). Go extract tất cả timeline records.

  • Thêm filter trong ci_cd_timeline_records_extractor.go: chỉ lưu JobStage
  • Hoặc document nếu cố ý giữ tất cả records

3. Timeline collector — failed builds

Go skip builds result IN ('failed', 'none') khi collect timeline. Python vẫn thử (handle 204/404).

  • Đánh giá có nên collect timeline cho failed builds (jobs có thể chạy trước khi fail)
  • Align behavior với Python nếu cần metric đầy đủ

4. Docs

  • Cập nhật README — giải thích deploymentPattern, productionPattern, environmentPattern và impact lên DORA
  • Ví dụ regex cho Azure Pipeline naming convention phổ biến

Acceptance Criteria

  • environment_pattern hoạt động end-to-end: UI → scope config → cicd_tasks.environment
  • DORA deployment detection chính xác hơn với pipeline có naming phức tạp
  • E2E timeline test cập nhật nếu thay filter logic
  • Không regression build collection incremental

Không nằm trong scope

  • Board / work items (issue riêng)
  • Repository migration Python → Go (issue riêng)

Ước lượng

~3–5 ngày

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions