opensearch-project / opensearch-build-libraries

Apache License 2.0
6 stars 23 forks source link

Update gradle publish library to handle `invokeType` #423

Closed prudhvigodithi closed 2 months ago

prudhvigodithi commented 2 months ago

Description

Coming from a failed gradle check job https://build.ci.opensearch.org/job/gradle-check/38585/console with error No such property: pr_number for class: groovy.lang.Binding because this job was invoked by parameterizedCron.

Update gradle publish library to handle the invokeType so that the failed jobs can be filtered by invokeType.

Issues Resolved

https://github.com/opensearch-project/opensearch-build/issues/4708

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. For more information on following Developer Certificate of Origin and signing off your commits, please check here.

prudhvigodithi commented 2 months ago

I have tested the mappings update for existing indices and the new documents can be still be indexed with field invoked_by, example

Existing Mapping we have

PUT /gradle_check
{
  "mappings": {
    "properties": {
      "build_number": { "type": "integer" },
      "pull_request": { "type": "keyword" },
      "pr_description": { "type": "text" },
      "test_class": { "type": "keyword" },
      "test_name": { "type": "keyword" },
      "test_status": { "type": "keyword" },
      "build_result": { "type": "keyword" },
      "test_fail_count": { "type": "integer" },
      "test_skipped_count": { "type": "integer" },
      "test_passed_count": { "type": "integer" },
      "build_duration": { "type": "float" },
      "build_start_time": { "type": "date" }
    }
  }
}

Still it allows to index the documents with invoked_by.

POST /gradle_check/_doc
{
  "build_number": 1234,
  "pull_request": "PR-567",
  "pr_description": "Fixes a bug in the authentication module",
  "test_class": "AuthenticationTests",
  "test_name": "test_login",
  "test_status": "pass",
  "build_result": "success",
  "test_fail_count": 0,
  "test_skipped_count": 0,
  "test_passed_count": 1,
  "build_duration": 120.5,
  "build_start_time": "2024-05-13T08:00:00"
}

POST /gradle_check/_doc
{
  "build_number": 1234,
  "pull_request": "PR-567",
  "invoked_by": "manual",
  "pr_description": "Fixes a bug in the authentication module",
  "test_class": "AuthenticationTests",
  "test_name": "test_login",
  "test_status": "pass",
  "build_result": "success",
  "test_fail_count": 0,
  "test_skipped_count": 0,
  "test_passed_count": 1,
  "build_duration": 120.5,
  "build_start_time": "2024-05-13T08:00:00"
}

For the existing indices the invoked_by field will have the default mapping created.

        "invoked_by": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        },

For the new indices this is already solved as the mappings are created at the beginning of the index creation, example as

PUT /gradle_check_tmp
{
  "mappings": {
    "properties": {
      "build_number": { "type": "integer" },
      "pull_request": { "type": "keyword" },
      "invoked_by": { "type": "keyword" },
      "pr_description": { "type": "text" },
      "test_class": { "type": "keyword" },
      "test_name": { "type": "keyword" },
      "test_status": { "type": "keyword" },
      "build_result": { "type": "keyword" },
      "test_fail_count": { "type": "integer" },
      "test_skipped_count": { "type": "integer" },
      "test_passed_count": { "type": "integer" },
      "build_duration": { "type": "float" },
      "build_start_time": { "type": "date" }
    }
  }
}