Skip to content

Working directory and environment variables#19

Open
tomitrescak wants to merge 2 commits intogithub-education-resources:mainfrom
tomitrescak:main
Open

Working directory and environment variables#19
tomitrescak wants to merge 2 commits intogithub-education-resources:mainfrom
tomitrescak:main

Conversation

@tomitrescak
Copy link
Copy Markdown

Adds support to specify working directory where tests are executed. This is helpful when multiple tests are executed in different parts of the projects (e.g. in monorepos)

Also, it solves the problem where environment variables from the action are not included in the command execution and only subset specified in the action was passed.

  const processEnv = {
    ...process.env,
    ...env,
  }

  execSync(setupCommand, {timeout, cwd: workingDirectory, env: processEnv, stdio: 'inherit'})

@DerekHarter
Copy link
Copy Markdown

I had been looking for this feature, and I see @tomitrescak has a pull request pending for it for some time.

Just wanted to mention, I had tested this out by creating a public repo of @tomitrescak code here and doing the basic steps to Creating a Javascript Action.

I did want to note that I was mostly interested in getting environment variables to be available for the setup-command and command run by the autograding-command-grader. For the commit 66a2287 if you don't specify the optional 'working-directory' I get a Error: spawnSync /bin/sh ENOENT because it appears that the working-directory is a null or none value (I am not really a js coder). I did make one modification to fix this, specifying using default current directory if working-directory is not defined:

  const workingDirectory = core.getInput('working-directory') || '.'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants