-
Notifications
You must be signed in to change notification settings - Fork 462
[CI] Add support to test packages with basic subscription #13377
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
Merged
Merged
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
9679c7c
Add support to run Elastic stack with other licenses
mrodm 6e586b7
Add support to report issues related to subscription
mrodm 495da16
Refactor to build common summary and string from dataError
mrodm e74ae7e
Refactor to buld common error links data from its object
mrodm 081ffd3
Add option to enable verbose mode
mrodm 969e38b
Test setting subscription basic - to be removed
mrodm cf0da7b
Rename function
mrodm 099dea6
Check first if owners is not nil in summary template
mrodm 2247914
Test with trial subscription
mrodm d7e479c
Test with other packages with other scenarios
mrodm b37ac87
Test again with basic subscription
mrodm 3c114bd
Add target mage for subscription validation
mrodm 0ee660e
Add some more packages to test
mrodm 51bbb78
Test with bash functions
mrodm 5d03168
Try with mage targets - added missing installation
mrodm 1dc0401
Test all packages with basic license
mrodm 69edc0a
Not shown files from git-diff checks
mrodm bee404b
Show annotation with skipped files
mrodm 7252015
Fix collapsed annotation
mrodm 571eca9
Test annotation
mrodm ce0b4a7
Just show skipped packages
mrodm d1a7db4
Test elastic-package PR 2511 - 62704d87
mrodm 5522c3d
Update version in .go-version file
mrodm 28e6578
Revert changes moved to other PRs
mrodm 067f900
Test all packages with basic license
mrodm 139851c
Merge upstream/main into test_packages_basic_subscription
mrodm f3fee7c
Include summary data into description data too
mrodm 0a2b778
Add stack version entry if it has empty string
mrodm 6805016
Test updating just one package
mrodm 999aa58
Add collapsed blocks in trigger step
mrodm b9173ae
Remove one collapsed block
mrodm eaed4c4
Remove comments and changes for debugging
mrodm 63fcf64
Test creation of GH issues
mrodm 87e64da
Add default values
mrodm ef66216
Remove step to test with LogsDB and basic subscription
mrodm 3f606bb
Add comment
mrodm 4b5a98d
Remove kibana from test packages
mrodm 51e2db1
Rename function
mrodm 592acb2
Remove changes for debugging
mrodm 8934110
Remove show skipped packages as annotation
mrodm 8461649
Revert changes in go.mod go.sum
mrodm fcfc90a
Remove whitespace
mrodm 2dd8413
Update go.mod
mrodm 3c93e90
Revert .go-version file
mrodm fe32361
Use stdout to indicate whether or not it is supported
mrodm 7560c46
Test some packages
mrodm ae345bb
Update error management
mrodm 5f301e4
Add debug messages
mrodm 4eea916
Test with elastic-pacakge v0.111.0
mrodm d32eb44
Add collapsed block
mrodm 092b361
Revert "Test with elastic-pacakge v0.111.0"
mrodm 1e3ee5c
Revert "Test some packages"
mrodm 383240f
Fix typo
mrodm 44080a4
Remove daily step
mrodm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ API_BUILDKITE_PIPELINES_URL="https://api.buildkite.com/v2/organizations/elastic/ | |
COVERAGE_FORMAT="generic" | ||
COVERAGE_OPTIONS="--test-coverage --coverage-format=${COVERAGE_FORMAT}" | ||
|
||
FATAL_ERROR="Fatal Error" | ||
|
||
running_on_buildkite() { | ||
if [[ "${BUILDKITE:-"false"}" == "true" ]]; then | ||
return 0 | ||
|
@@ -509,9 +511,15 @@ prepare_stack() { | |
fi | ||
|
||
if [ "${STACK_LOGSDB_ENABLED:-false}" == "true" ]; then | ||
echoerr "- Enable LogsDB" | ||
args="${args} -U stack.logsdb_enabled=true" | ||
fi | ||
|
||
if [ "${ELASTIC_SUBSCRIPTION:-""}" != "" ]; then | ||
echoerr "- Set Subscription ${ELASTIC_SUBSCRIPTION}" | ||
args="${args} -U stack.elastic_subscription=${ELASTIC_SUBSCRIPTION}" | ||
fi | ||
|
||
if [[ "${STACK_VERSION}" =~ ^7\.17 ]]; then | ||
# Required starting with STACK_VERSION 7.17.21 | ||
export ELASTIC_AGENT_IMAGE_REF_OVERRIDE="docker.elastic.co/beats/elastic-agent-complete:${STACK_VERSION}-amd64" | ||
|
@@ -668,6 +676,16 @@ get_to_changeset() { | |
echo "${to}" | ||
} | ||
|
||
is_subscription_compatible() { | ||
local reason="" | ||
|
||
if ! reason=$(mage -d "${WORKSPACE}" -w . isSubscriptionCompatible) ; then | ||
return 1 | ||
fi | ||
echo "${reason}" | ||
return 0 | ||
} | ||
|
||
is_pr_affected() { | ||
local package="${1}" | ||
local from="${2}" | ||
|
@@ -698,6 +716,15 @@ is_pr_affected() { | |
return 1 | ||
fi | ||
fi | ||
local compatible="" | ||
if ! compatible=$(is_subscription_compatible); then | ||
echo "${FATAL_ERROR}" | ||
return 1 | ||
fi | ||
if [[ "${compatible}" == "false" ]]; then | ||
echo "[${package}] PR is not affected: subscription not compatible with ${ELASTIC_SUBSCRIPTION}" | ||
return 1 | ||
fi | ||
Comment on lines
+720
to
+727
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For both cases, this function will return failure (code 1). Depending on the message echoed, the caller method should take one or other action. |
||
|
||
if [[ "${FORCE_CHECK_ALL}" == "true" ]];then | ||
echo "[${package}] PR is affected: \"force_check_all\" parameter enabled" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package citools | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/elastic/go-ucfg" | ||
"github.com/elastic/go-ucfg/yaml" | ||
) | ||
|
||
// kibanaConditions defines conditions for Kibana (e.g. required version). | ||
type kibanaConditions struct { | ||
Version string `config:"version" json:"version" yaml:"version"` | ||
} | ||
|
||
// elasticConditions defines conditions related to Elastic subscriptions or partnerships. | ||
type elasticConditions struct { | ||
Subscription string `config:"subscription" json:"subscription" yaml:"subscription"` | ||
} | ||
|
||
// conditions define requirements for different parts of the Elastic stack. | ||
type conditions struct { | ||
Kibana kibanaConditions `config:"kibana" json:"kibana" yaml:"kibana"` | ||
Elastic elasticConditions `config:"elastic" json:"elastic" yaml:"elastic"` | ||
} | ||
|
||
type packageManifest struct { | ||
Name string `config:"name" json:"name" yaml:"name"` | ||
License string `config:"license" json:"license" yaml:"license"` | ||
Conditions conditions `config:"conditions" json:"conditions" yaml:"conditions"` | ||
} | ||
|
||
func readPackageManifest(path string) (*packageManifest, error) { | ||
cfg, err := yaml.NewConfigWithFile(path, ucfg.PathSep(".")) | ||
if err != nil { | ||
return nil, fmt.Errorf("reading file failed (path: %s): %w", path, err) | ||
} | ||
|
||
var manifest packageManifest | ||
err = cfg.Unpack(&manifest) | ||
if err != nil { | ||
return nil, fmt.Errorf("unpacking package manifest failed (path: %s): %w", path, err) | ||
} | ||
return &manifest, nil | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package citools | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
func packageSubscription(path string) (string, error) { | ||
manifest, err := readPackageManifest(path) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
packageSubscription := manifest.Conditions.Elastic.Subscription | ||
if packageSubscription == "" { | ||
packageSubscription = manifest.License | ||
} | ||
if packageSubscription == "" { | ||
packageSubscription = "basic" | ||
} | ||
|
||
return packageSubscription, nil | ||
} | ||
|
||
func IsSubscriptionCompatible(stackSubscription, path string) (bool, error) { | ||
pkgSubscription, err := packageSubscription(path) | ||
if err != nil { | ||
return false, fmt.Errorf("failed to read subscription from manifest: %w", err) | ||
} | ||
|
||
if stackSubscription == "trial" { | ||
// All subscriptions supported | ||
return true, nil | ||
} | ||
|
||
if stackSubscription == "basic" { | ||
if pkgSubscription != "basic" { | ||
return false, nil | ||
} | ||
return true, nil | ||
} | ||
|
||
return false, fmt.Errorf("unknown subscription %s", stackSubscription) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would return failure if there is any failure (e.g. failed to read YAML file), and success in any other case (zero value).
When it returns success, the message echoed will show whether or not it is compatible (true or false).