github-issue-parser icon indicating copy to clipboard operation
github-issue-parser copied to clipboard

Using env.runner_temp instead of home directory to write json file

Open joshjohanning opened this issue 2 years ago • 1 comments

I was wondering what the issue parser json file was doing in my home directory with a self-hosted runner: image

Changing this to use ${env.RUNNER_TEMP} as a more GitHub-native way to store temporary files.

The path to a temporary directory on the runner. This directory is emptied at the beginning and end of each job. Note that files will not be removed if the runner's user account does not have permission to delete them. For example, D:\a\_temp

For Linux, it stores it under <runner-dir>/_work/_temp, and it's deleted after the job completes. The file is no longer needed since the output var is being set.

joshjohanning avatar Jun 16 '23 21:06 joshjohanning

Ahh, it breaks a test 🤔

joshjohanning avatar Jun 16 '23 21:06 joshjohanning

I think you have to also update mocks of ENV in tests

https://github.com/stefanbuck/github-issue-parser/blob/2ac1a18553a52ccc22739a40e99bf97300961e37/test.spec.js#L14-L17

correct

gr2m avatar Apr 29 '24 16:04 gr2m

@gr2m do you know if it's still running my old commit? It seems so. I removed home path from a new commit https://github.com/stefanbuck/github-issue-parser/commit/3be98d8236a496713411bf7c4f94b0476705ed00

but still seeing in the action failure:

Expected: "<home path>/issue-parser-result.json"
Received: "undefined/issue-parser-result.json"

When I run it locally:

$ npm run test

> [email protected] test
> jest .

 PASS  ./test.spec.js
  ✓ smoke test (1 ms)
  ✓ readme example (20 ms)
  ✓ full example (15 ms)
  ✓ multiple paragraphs (28 ms)
  ✓ blank (5 ms)

Test Suites: 1 passed, 1 total
Tests:       5 passed, 5 total
Snapshots:   0 total
Time:        1.218 s
Ran all test suites matching /./i.

So I think this PR is good to go, but unsure why it's running the old test code in the action.

joshjohanning avatar May 29 '24 00:05 joshjohanning

hmm yeah I don't see the error locally either. Pushing a new commit or sending the same PR from a branch doesn't seem to trigger the CI right now: https://github.com/stefanbuck/github-issue-parser/pull/73. Not sure what's going on, but I'm tempted to just merge it in since CI is passing locally

gr2m avatar May 29 '24 18:05 gr2m

:tada: This PR is included in version 3.2.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

github-actions[bot] avatar May 29 '24 18:05 github-actions[bot]

we missed one HOME in the test: https://github.com/stefanbuck/github-issue-parser/commit/3c890f099963e8c04826a69416444bcbeecb345c#diff-870c1528a9710168a5ac887a90f4232e243a6193f2be70cb7c22946238760f67R129

gr2m avatar May 29 '24 18:05 gr2m

Ahh, weird! Good find though @gr2m.

Interesting that my local copy of the branch had 0 instances of home left in the test file 😕

image

Is it possible that because the branch was so old, it didn't have that particular line for me to change in my branch? And the Actions workflow is running the tests based on the code that is in main and not in my branch? I perhaps should have considered cutting a new branch/rebasing it seems.

Either way, thank you for fixing the last remaining test and merging this in 🎉

joshjohanning avatar May 29 '24 20:05 joshjohanning

yeah it might be that it was a test that was added after you started your pull request, so the CI build triggered on the merge commit failed

gr2m avatar May 29 '24 20:05 gr2m

Maybe https://github.com/stefanbuck/github-issue-parser/pull/71/files#diff-870c1528a9710168a5ac887a90f4232e243a6193f2be70cb7c22946238760f67R99.

It seems that it also confused the semantic-release bot - https://github.com/stefanbuck/github-issue-parser/pull/71#issuecomment-2138045496

jamacku avatar May 30 '24 06:05 jamacku