Skip to content
Snippets Groups Projects
Commit ef7b423c authored by David O'Regan's avatar David O'Regan Committed by Mikołaj Wawrzyniak
Browse files

Add Pages public folder check

Throw an InvalidStateError
if there is no public
folder present inside
a pages build artifact

Changelog: other
parent 01990faa
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -30,6 +30,7 @@ module Projects
 
validate_state!
validate_max_size!
validate_public_folder!
validate_max_entries!
 
build.artifacts_file.use_file do |artifacts_path|
Loading
Loading
@@ -180,6 +181,10 @@ module Projects
end
end
 
def validate_public_folder!
raise InvalidStateError, 'Error: The `public/` folder is missing, or not declared in `.gitlab-ci.yml`.' unless total_size > 0
end
def entries_count
# we're using the full archive and pages daemon needs to read it
# so we want the total count from entries, not only "public/" directory
Loading
Loading
Loading
Loading
@@ -13,6 +13,7 @@ RSpec.describe Projects::UpdatePagesService do
 
let(:file) { fixture_file_upload("spec/fixtures/pages.zip") }
let(:empty_file) { fixture_file_upload("spec/fixtures/pages_empty.zip") }
let(:empty_metadata_filename) { "spec/fixtures/pages_empty.zip.meta" }
let(:metadata_filename) { "spec/fixtures/pages.zip.meta" }
let(:metadata) { fixture_file_upload(metadata_filename) if File.exist?(metadata_filename) }
 
Loading
Loading
@@ -91,6 +92,17 @@ RSpec.describe Projects::UpdatePagesService do
end
end
 
context 'when archive does not have pages directory' do
let(:file) { empty_file }
let(:metadata_filename) { empty_metadata_filename }
it 'returns an error' do
expect(execute).not_to eq(:success)
expect(GenericCommitStatus.last.description).to eq("Error: The `public/` folder is missing, or not declared in `.gitlab-ci.yml`.")
end
end
it 'limits pages size' do
stub_application_setting(max_pages_size: 1)
expect(execute).not_to eq(:success)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment