From 696cd6a236e18d5da66d60fcf7548c674471a7d6 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Mon, 18 Oct 2021 00:06:45 +0200 Subject: [PATCH] Poseidon: Clean workspace between executions --- lib/runner/strategy/poseidon.rb | 5 ++++- spec/lib/runner/strategy/poseidon_spec.rb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/runner/strategy/poseidon.rb b/lib/runner/strategy/poseidon.rb index 1c8ed3b9..7080ddd9 100644 --- a/lib/runner/strategy/poseidon.rb +++ b/lib/runner/strategy/poseidon.rb @@ -95,7 +95,10 @@ class Runner::Strategy::Poseidon < Runner::Strategy } end 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]} response = connection.patch url, body.to_json, self.class.headers return if response.status == 204 diff --git a/spec/lib/runner/strategy/poseidon_spec.rb b/spec/lib/runner/strategy/poseidon_spec.rb index b87bf462..f81670da 100644 --- a/spec/lib/runner/strategy/poseidon_spec.rb +++ b/spec/lib/runner/strategy/poseidon_spec.rb @@ -319,7 +319,7 @@ describe Runner::Strategy::Poseidon do WebMock .stub_request(:patch, "#{described_class.config[:url]}/runners/#{runner_id}/files") .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'} ) .to_return(body: response_body, status: response_status)