Poseidon: Clean workspace between executions

This commit is contained in:
Sebastian Serth
2021-10-18 00:06:45 +02:00
parent a6a477e361
commit 696cd6a236
2 changed files with 5 additions and 2 deletions

View File

@ -95,7 +95,10 @@ class Runner::Strategy::Poseidon < Runner::Strategy
} }
end end
url = "#{runner_url}/files" url = "#{runner_url}/files"
body = {copy: copy}
# First, clean the workspace and second, copy all files to their location.
# This ensures that no artefacts from a previous submission remain in the workspace.
body = {copy: copy, delete: ['./']}
connection = Faraday.new nil, ssl: {ca_file: self.class.config[:ca_file]} connection = Faraday.new nil, ssl: {ca_file: self.class.config[:ca_file]}
response = connection.patch url, body.to_json, self.class.headers response = connection.patch url, body.to_json, self.class.headers
return if response.status == 204 return if response.status == 204

View File

@ -319,7 +319,7 @@ describe Runner::Strategy::Poseidon do
WebMock WebMock
.stub_request(:patch, "#{described_class.config[:url]}/runners/#{runner_id}/files") .stub_request(:patch, "#{described_class.config[:url]}/runners/#{runner_id}/files")
.with( .with(
body: {copy: [{path: file.filepath, content: encoded_file_content}]}, body: {copy: [{path: file.filepath, content: encoded_file_content}], delete: ['./']},
headers: {'Content-Type' => 'application/json'} headers: {'Content-Type' => 'application/json'}
) )
.to_return(body: response_body, status: response_status) .to_return(body: response_body, status: response_status)