Skip to content

Commit

Permalink
Add ECE version attributes (#2997)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcawl authored May 6, 2024
1 parent 1cb0bdd commit f64f777
Show file tree
Hide file tree
Showing 77 changed files with 295 additions and 34 deletions.
3 changes: 3 additions & 0 deletions conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2075,6 +2075,9 @@ contents:
repo: cloud
path: docs/shared
exclude_branches: [ 1.0 ]
-
repo: docs
path: shared/versions/ece/{version}.asciidoc
-
repo: cloud-assets
path: docs
Expand Down
54 changes: 53 additions & 1 deletion integtest/spec/all_books_change_detection_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def extra
Some text.
ASCIIDOC
STACK_VERSIONS = 'shared/versions/stack/'

ECE_VERSIONS = 'shared/versions/ece/'
def self.build_twice(
before_first_build:,
before_second_build:
Expand Down Expand Up @@ -921,6 +921,58 @@ def self.add_branch(src)
)
include_examples 'second build is not a noop'
end
context "because the docs repo's ece version file " \
'for master changes' do
build_one_book_out_of_two_repos_twice(
init: lambda do |src|
init_docs src,
"#{ECE_VERSIONS}/{branch}.asciidoc", '{ece-version}'
end,
before_second_build: lambda do |src, _config|
docs_repo = src.repo 'docs'
docs_repo.append "#{ECE_VERSIONS}/master.asciidoc", <<~ASCIIDOC
:ece-version: pig
ASCIIDOC
docs_repo.commit 'changed'
end
)
include_examples 'second build is not a noop'
end
context "because the docs repo's current ece version file changes" do
build_one_book_out_of_two_repos_twice(
init: lambda do |src|
init_docs src, "#{ECE_VERSIONS}/current.asciidoc", '{ece-version}'
end,
before_second_build: lambda do |src, _config|
docs_repo = src.repo 'docs'
docs_repo.write "#{ECE_VERSIONS}/current.asciidoc", <<~ASCIIDOC
include::master.asciidoc[]
ASCIIDOC
docs_repo.commit 'changed'
end
)
include_examples 'second build is not a noop'
end
context "because the file referenced by the docs repo's current " \
'ece version file changes' do
build_one_book_out_of_two_repos_twice(
init: lambda do |src|
path = "#{ECE_VERSIONS}/current.asciidoc"
init_docs src, path, '{ece-version}'
docs_repo = src.repo 'docs'
docs_repo.write path, 'include::master.asciidoc[]'
docs_repo.commit 'use master'
end,
before_second_build: lambda do |src, _config|
docs_repo = src.repo 'docs'
docs_repo.append "#{ECE_VERSIONS}/master.asciidoc", <<~ASCIIDOC
:ece-version: cow
ASCIIDOC
docs_repo.commit 'changed'
end
)
include_examples 'second build is not a noop'
end
end
end

Expand Down
95 changes: 93 additions & 2 deletions integtest/spec/all_books_sources_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,34 @@ def self.init_docs_repo(src)

m[1]
end
let(:master_ece_version) do
contents = docs_repo.read 'shared/versions/ece/master.asciidoc'
m = contents.match(/:ece-version:\s+(.+)\n/)
raise "couldn't parse #{contents}" unless m

m[1]
end
let(:current_version) do
contents = docs_repo.read "shared/versions/stack/#{current_target}"
m = contents.match(/:elasticsearch_version:\s+(.+)\n/)
raise "couldn't parse #{contents}" unless m

m[1]
end
let(:current_ece_target) do
contents = docs_repo.read 'shared/versions/ece/current.asciidoc'
m = contents.match(/include::(.+)\[\]/)
raise "couldn't parse #{contents}" unless m

m[1]
end
let(:current_ece_version) do
contents = docs_repo.read "shared/versions/ece/#{current_ece_target}"
m = contents.match(/:ece-version:\s+(.+)\n/)
raise "couldn't parse #{contents}" unless m

m[1]
end
describe 'attributes file' do
convert_all_before_context do |src|
repo = src.repo_with_index 'repo', <<~ASCIIDOC
Expand All @@ -60,7 +81,7 @@ def self.init_docs_repo(src)
end
end
end
describe 'versions files' do
describe 'stack versions files' do
convert_all_before_context do |src|
extra_branches = ['5.5', '6.3', '7.2']
repo = src.repo_with_index 'repo', <<~ASCIIDOC
Expand Down Expand Up @@ -104,7 +125,7 @@ def self.init_docs_repo(src)
include_examples 'references the real path', '5.5'
end
end
describe 'the current version file' do
describe 'the current stack version file' do
convert_all_before_context do |src|
repo = src.repo_with_index 'repo', <<~ASCIIDOC
include::{docs-root}/shared/versions/stack/current.asciidoc[]
Expand Down Expand Up @@ -136,6 +157,76 @@ def self.init_docs_repo(src)
end
end
end
describe 'ece versions files' do
convert_all_before_context do |src|
extra_branches = ['ms-92']
repo = src.repo_with_index 'repo', <<~ASCIIDOC
include::{docs-root}/shared/versions/ece/{source_branch}.asciidoc[]
{ece-version}
ASCIIDOC
extra_branches.each { |b| repo.switch_to_new_branch b }
docs_repo = init_docs_repo src
book = src.book 'Test'
book.branches += extra_branches
book.source repo, 'index.asciidoc'
book.source docs_repo, 'shared/versions/ece/{branch}.asciidoc'
end
shared_examples 'resolved ece attribute' do |branch, value|
page_context "raw/test/#{branch}/chapter.html" do
it 'resolves an attribute from the docs repo' do
expect(body).to include(<<~HTML.strip)
<p>#{value == 'master' ? master_ece_version : value}</p>
HTML
end
end
end
include_examples 'resolved ece attribute', 'ms-92', '3.6.2'
file_context 'html/branches.yaml' do
shared_examples 'references the real path' do |branch|
context "#{branch} branch" do
it 'references the real path' do
expect(contents).to include(<<~LOG.strip)
Test/shared/versions/ece/#{branch}.asciidoc/#{branch}: #{hash}
LOG
end
end
end
include_examples 'references the real path', 'ms-92'
end
end
describe 'the current ece version file' do
convert_all_before_context do |src|
repo = src.repo_with_index 'repo', <<~ASCIIDOC
include::{docs-root}/shared/versions/ece/current.asciidoc[]
{ece-version}
ASCIIDOC
docs_repo = init_docs_repo src
book = src.book 'Test'
book.source repo, 'index.asciidoc'
book.source docs_repo, 'shared/versions/ece/current.asciidoc'
end
page_context 'raw/test/current/chapter.html' do
it 'resolves an attribute from the docs repo' do
expect(body).to include(<<~HTML.strip)
<p>#{current_ece_version}</p>
HTML
end
end
file_context 'html/branches.yaml' do
it 'references current.asciidoc' do
expect(contents).to include(<<~LOG.strip)
Test/shared/versions/ece/current.asciidoc/master: #{hash}
LOG
end
it "references current.asciidoc's target" do
expect(contents).to include(<<~LOG.strip)
Test/shared/versions/ece/#{current_ece_target}/master: #{hash}
LOG
end
end
end
describe 'when the build fails' do
convert_before do |src, dest|
repo = src.repo_with_index 'repo', 'include::garbage.adoc[]'
Expand Down
25 changes: 25 additions & 0 deletions lib/ES/DocsRepo.pm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ sub add_source {
};
}

if ( $path eq 'shared/versions/ece/current.asciidoc' ) {
push @$sources, {
repo => $self,
prefix => $prefix,
path => $self->_current_ece_version_file,
exclude => $exclude,
map_branches => $map_branches,
private => $private,
alternatives => $alternatives,
};
}

$self->SUPER::add_source( $sources, $prefix, $path, $exclude, $map_branches, $private, $alternatives );
}

Expand Down Expand Up @@ -92,5 +104,18 @@ sub _current_stack_version_file {
return $self->{current_stack_version_file};
}

#===================================
sub _current_ece_version_file {
#===================================
my ( $self ) = @_;
unless ( $self->{current_ece_version_file} ) {
my $current = $self->{dir}->file( 'shared/versions/ece/current.asciidoc' );
my $contents = $current->slurp( iomode => '<:encoding(UTF-8)' );
die "Can't parse current.asciidoc: $contents" unless $contents =~ /include::(.+)\[\]/;
$self->{current_ece_version_file} = "shared/versions/ece/$1";
}
return $self->{current_ece_version_file};
}


1
2 changes: 1 addition & 1 deletion shared/attributes.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Elastic Cloud
:ess-console: https://cloud.elastic.co{ess-utm-params}
:ess-console-name: {ess} Console
:ess-deployments: https://cloud.elastic.co/deployments{ess-utm-params}
:ece-ref: https://www.elastic.co/guide/en/cloud-enterprise/current
:ece-ref: https://www.elastic.co/guide/en/cloud-enterprise/{ece-version-link}
:eck-ref: https://www.elastic.co/guide/en/cloud-on-k8s/current
:ess-leadin: You can run Elasticsearch on your own hardware or use our hosted Elasticsearch Service that is available on AWS, GCP, and Azure. {ess-trial}[Try the Elasticsearch Service for free].
:ess-leadin-short: Our hosted Elasticsearch Service is available on AWS, GCP, and Azure, and you can {ess-trial}[try it for free].
Expand Down
3 changes: 3 additions & 0 deletions shared/versions/ece/1.0.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 1.0.2
:ece-version-short: 1.0
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/1.1.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 1.1.5
:ece-version-short: 1.1
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/2.0.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 2.0.1
:ece-version-short: 2.0
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/2.1.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 2.1.1
:ece-version-short: 2.1
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/2.2.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 2.2.3
:ece-version-short: 2.2
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/2.3.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 2.3.2
:ece-version-short: 2.3
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/2.4.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 2.4.3
:ece-version-short: 2.4
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/2.5.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 2.5.1
:ece-version-short: 2.5
:ece-version-link: current
1 change: 1 addition & 0 deletions shared/versions/ece/current.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include::ms-105.asciidoc[]
3 changes: 3 additions & 0 deletions shared/versions/ece/master.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 3.7.0
:ece-version-short: 3.7
:ece-version-link: 3.7
3 changes: 3 additions & 0 deletions shared/versions/ece/ms-105.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 3.7.0
:ece-version-short: 3.7
:ece-version-link: 3.7
3 changes: 3 additions & 0 deletions shared/versions/ece/ms-47.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 2.7.2
:ece-version-short: 2.7
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/ms-49.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 2.8.1
:ece-version-short: 2.8
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/ms-53.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 2.9.2
:ece-version-short: 2.9
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/ms-57.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 2.10.0
:ece-version-short: 2.10
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/ms-59.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 2.11.2
:ece-version-short: 2.11
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/ms-62.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 2.12.1
:ece-version-short: 2.12
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/ms-65.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 2.13.2
:ece-version-short: 2.13
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/ms-69.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 3.0.0
:ece-version-short: 3.0
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/ms-70.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 3.1.0
:ece-version-short: 3.1
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/ms-72.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 3.2.1
:ece-version-short: 3.2
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/ms-75.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 3.3.0
:ece-version-short: 3.3
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/ms-81.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 3.4.1
:ece-version-short: 3.4
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/ms-92.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 3.6.2
:ece-version-short: 3.6
:ece-version-link: current
3 changes: 3 additions & 0 deletions shared/versions/ece/release-ms-41.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:ece-version: 2.6.2
:ece-version-short: 2.6
:ece-version-link: current
1 change: 1 addition & 0 deletions shared/versions/stack/5.5.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:minor-version: 5.5
:major-version: 5.x
:prev-major-version: 2.x
:ece-version-link: current

//////////
release-state can be: released | prerelease | unreleased
Expand Down
1 change: 1 addition & 0 deletions shared/versions/stack/5.6.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
:minor-version: 5.6
:major-version: 5.x
:prev-major-version: 2.x
:ece-version-link: current

//////////
release-state can be: released | prerelease | unreleased
Expand Down
1 change: 1 addition & 0 deletions shared/versions/stack/6.0.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
:minor-version: 6.0
:major-version: 6.x
:prev-major-version: 5.x
:ece-version-link: current

//////////
release-state can be: released | prerelease | unreleased
Expand Down
Loading

0 comments on commit f64f777

Please sign in to comment.