Skip to content

Commit

Permalink
Fixes issue where the import script API would put the updated harness…
Browse files Browse the repository at this point in the history
… files into PROJECT_ROOT/../client/resources instead of PROJECT_ROOT/client/resources; also updates permission handling for the sandbox environment
  • Loading branch information
howard-e committed Sep 12, 2024
1 parent afede8d commit 153ac27
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
9 changes: 9 additions & 0 deletions deploy/roles/application/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@

- include: upload-source-code.yml

- name: Allow aria-bot user to run import script as admin on sandbox
lineinfile:
path: /etc/sudoers
state: present
line: 'aria-bot ALL=(ALL) NOPASSWD:{{source_dir}}/deploy/scripts/export-and-exec.sh'
validate: 'visudo -cf %s'
become: yes
when: deployment_mode == 'sandbox'

# TODO: these permissions changes are a workaround solution

- name: Make server scripts folder writable for import tests API endpoint
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/TestController.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async function importTests(req, res) {
console.log(error.message);
// This is when the script fails because the git hash is invalid
// Sending semantic error.
res.sendStatus(422);
res.status(422).send(error.message);
}
}

Expand Down
11 changes: 9 additions & 2 deletions server/scripts/import-tests/testPlanVersionOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,15 @@ const processTestPlanVersion = async ({
*/
const importHarness = () => {
const sourceFolder = path.resolve(`${testsDirectory}/resources`);
const targetFolder = path.resolve('../', 'client/resources');
console.info(`Updating harness directory, ${targetFolder} ...`);
const targetFolder = path.resolve(
__dirname,
'../../../',
'client',
'resources'
);
console.info(
`Updating harness directory, copying from ${sourceFolder} to ${targetFolder} ...`
);
fse.rmSync(targetFolder, { recursive: true, force: true });

// Copy source folder
Expand Down
1 change: 1 addition & 0 deletions server/services/TestService.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ async function runImportScript(git_hash) {
let importScriptDirectoryPrefix = isDevelopmentProcess ? '.' : './server';
let command = `${deployDirectoryPrefix}/deploy/scripts/export-and-exec.sh ${process.env.IMPORT_CONFIG} node ${importScriptDirectoryPrefix}/scripts/import-tests/index.js`;
if (git_hash) command += ` -c ${git_hash}`;
if (process.env.ENVIRONMENT === 'sandbox') command = `sudo ${command}`;
exec(command, (error, stdout, stderr) => {
if (error) {
reject(error);
Expand Down

0 comments on commit 153ac27

Please sign in to comment.