Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gitlab / linters: refactoring + testing #29969

Open
wants to merge 73 commits into
base: main
Choose a base branch
from

Conversation

CelianR
Copy link
Contributor

@CelianR CelianR commented Oct 9, 2024

What does this PR do?

This refactors the code related to linters / gitlab:

  • Refactors docstrings using Google Python Syntax
  • Adds --all-files to the jobs code owners linter
  • Refactors gitlab_ci_jobs_owners
  • Tests the gitlab_ci_jobs_owners linter
  • Removed rules for new linters to make them required

Motivation

Describe how to test/QA your changes

Possible Drawbacks / Trade-offs

Additional Notes

CelianR and others added 30 commits October 1, 2024 17:59
Co-authored-by: Nicolas Schweitzer <nicolas.schweitzer@datadoghq.com>
Co-authored-by: Nicolas Schweitzer <nicolas.schweitzer@datadoghq.com>
@CelianR CelianR added changelog/no-changelog qa/no-code-change Skip QA week as there is no code change in Agent code team/agent-devx-infra labels Oct 9, 2024
@CelianR CelianR self-assigned this Oct 9, 2024
@CelianR CelianR requested review from a team as code owners October 9, 2024 08:45
@agent-platform-auto-pr
Copy link
Contributor

agent-platform-auto-pr bot commented Oct 9, 2024

Gitlab CI Configuration Changes

Modified Jobs

compute_gitlab_ci_config
  compute_gitlab_ci_config:
    artifacts:
      expire_in: 1 day
      paths:
      - artifacts/
      when: always
    before_script:
    - git fetch origin main
    - git checkout main
    - git checkout -
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/deb_arm64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
    needs: []
-   rules:
-   - if: $CI_PIPELINE_SOURCE != "push"
-     when: never
-   - when: on_success
    script:
    - GITLAB_TOKEN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $GITLAB_FULL_API_TOKEN)
      || exit $?; export GITLAB_TOKEN
    - mkdir -p artifacts
    - inv -e gitlab.compute-gitlab-ci-config --before-file artifacts/before.gitlab-ci.yml
      --after-file artifacts/after.gitlab-ci.yml --diff-file artifacts/diff.gitlab-ci.yml
    stage: .pre
    tags:
    - arch:arm64
lint_gitlab_ci
  lint_gitlab_ci:
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/deb_x64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
    needs:
    - compute_gitlab_ci_config
-   rules:
-   - if: $CI_PIPELINE_SOURCE != "push"
-     when: never
-   - changes:
-       compare_to: main
-       paths:
-       - .gitlab-ci.yml
-       - .gitlab/**/*
-       - .gitlab/**/.*
-   - if: $CI_COMMIT_BRANCH =~ /^mq-working-branch-/
-     when: on_success
-   - if: $CI_COMMIT_BRANCH == "main"
    script:
    - inv -e linter.gitlab-ci-jobs-needs-rules --config-file artifacts/after.gitlab-ci.yml
    - inv -e linter.gitlab-ci-jobs-owners --config-file artifacts/after.gitlab-ci.yml
    stage: .pre
    tags:
    - arch:amd64
lint_gitlab_ci_jobs_codeowners
  lint_gitlab_ci_jobs_codeowners:
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/deb_arm64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
    needs: []
-   rules:
-   - changes:
-       compare_to: main
-       paths:
-       - .gitlab-ci.yml
-       - .gitlab/**/*
-       - .gitlab/**/.*
    script:
    - inv -e linter.gitlab-ci-jobs-codeowners --all-files
    stage: .pre
    tags:
    - arch:arm64
notify_gitlab_ci_changes
  notify_gitlab_ci_changes:
    image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/datadog-agent-buildimages/deb_x64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
    needs:
    - compute_gitlab_ci_config
    rules:
-   - if: $CI_PIPELINE_SOURCE != "push"
-     when: never
    - changes:
        compare_to: main
        paths:
        - .gitlab-ci.yml
        - .gitlab/**/*.yml
    script:
    - python3 -m pip install -r tasks/libs/requirements-github.txt
    - GITHUB_KEY_B64=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_GITHUB_APP key_b64)
      || exit $?; export GITHUB_KEY_B64
    - GITHUB_APP_ID=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_GITHUB_APP app_id)
      || exit $?; export GITHUB_APP_ID
    - GITHUB_INSTALLATION_ID=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_GITHUB_APP
      installation_id) || exit $?; export GITHUB_INSTALLATION_ID
    - echo "Using agent GitHub App"
    - inv -e notify.gitlab-ci-diff --from-diff artifacts/diff.gitlab-ci.yml --pr-comment
    stage: notify
    tags:
    - arch:amd64

Removed Jobs

  • .compute_gitlab_ci_config_rules

Changes Summary

Removed Modified Added Renamed
1 4 0 0

ℹ️ Diff available in the job log.

@CelianR CelianR marked this pull request as draft October 9, 2024 08:54
@agent-platform-auto-pr
Copy link
Contributor

agent-platform-auto-pr bot commented Oct 9, 2024

[Fast Unit Tests Report]

On pipeline 46280366 (CI Visibility). The following jobs did not run any unit tests:

Jobs:
  • tests_deb-arm64-py3
  • tests_deb-x64-py3
  • tests_flavor_dogstatsd_deb-x64
  • tests_flavor_heroku_deb-x64
  • tests_flavor_iot_deb-x64
  • tests_rpm-arm64-py3
  • tests_rpm-x64-py3
  • tests_windows-x64

If you modified Go files and expected unit tests to run in these jobs, please double check the job logs. If you think tests should have been executed reach out to #agent-devx-help

Copy link

cit-pr-commenter bot commented Oct 9, 2024

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Run ID: 9fee3be1-04c6-4311-9f0e-64ee52113aa0

Baseline: 521bc73
Comparison: 5cc7734

Regression Detector: ✅

Bounds Checks: ✅

Significant changes in experiment optimization goals

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

perf experiment goal Δ mean % Δ mean % CI trials links
pycheck_lots_of_tags % cpu utilization -5.14 [-8.51, -1.77] 1 Logs

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
idle_all_features memory utilization +0.52 [+0.42, +0.62] 1 Logs
file_tree memory utilization +0.32 [+0.21, +0.44] 1 Logs
tcp_syslog_to_blackhole ingress throughput +0.17 [+0.12, +0.22] 1 Logs
file_to_blackhole_1000ms_latency egress throughput +0.09 [-0.40, +0.58] 1 Logs
file_to_blackhole_100ms_latency egress throughput +0.01 [-0.21, +0.24] 1 Logs
file_to_blackhole_0ms_latency egress throughput +0.01 [-0.32, +0.34] 1 Logs
file_to_blackhole_500ms_latency egress throughput +0.01 [-0.24, +0.26] 1 Logs
tcp_dd_logs_filter_exclude ingress throughput +0.00 [-0.01, +0.01] 1 Logs
uds_dogstatsd_to_api ingress throughput -0.01 [-0.10, +0.08] 1 Logs
file_to_blackhole_300ms_latency egress throughput -0.10 [-0.28, +0.08] 1 Logs
otel_to_otel_logs ingress throughput -0.31 [-1.11, +0.50] 1 Logs
idle memory utilization -0.53 [-0.57, -0.49] 1 Logs
uds_dogstatsd_to_api_cpu % cpu utilization -0.92 [-1.65, -0.20] 1 Logs
basic_py_check % cpu utilization -3.89 [-7.69, -0.08] 1 Logs
pycheck_lots_of_tags % cpu utilization -5.14 [-8.51, -1.77] 1 Logs

Bounds Checks Passed

perf experiment bounds_check_name replicates_passed links
file_to_blackhole_0ms_latency memory_usage 10/10
file_to_blackhole_1000ms_latency memory_usage 10/10
file_to_blackhole_100ms_latency memory_usage 10/10
file_to_blackhole_300ms_latency memory_usage 10/10
file_to_blackhole_500ms_latency memory_usage 10/10
idle memory_usage 10/10

Explanation

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

@CelianR CelianR changed the title Gitlab / linters: refactoring Gitlab / linters: refactoring + testing Oct 10, 2024
@CelianR CelianR marked this pull request as ready for review October 10, 2024 12:31
@@ -33,11 +31,12 @@

@task
def generate_ci_visibility_links(_ctx, output: str | None):
"""Generates links to CI Visibility for the current job.

Usage:
Copy link
Member

Choose a reason for hiding this comment

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

Could we make the usage the same between the tasks. Either use deva or inv everywhere but not a mix of the two?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog qa/no-code-change Skip QA week as there is no code change in Agent code team/agent-devx-infra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants