Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
May 29, 2024

Conversation

joshjohanning
Copy link
Contributor

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
Copy link
Contributor Author

Ahh, it breaks a test 🤔

Copy link
Contributor

@jamacku jamacku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

// mock ENV
const env = {
HOME: "<home path>",
};

@gr2m
Copy link
Collaborator

gr2m commented Apr 29, 2024

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

// mock ENV
const env = {
HOME: "<home path>",
};

correct

@joshjohanning
Copy link
Contributor Author

@gr2m do you know if it's still running my old commit? It seems so. I removed home path from a new commit 3be98d8

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.

@gr2m
Copy link
Collaborator

gr2m commented May 29, 2024

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: #73. Not sure what's going on, but I'm tempted to just merge it in since CI is passing locally

@gr2m gr2m merged commit 7296f08 into stefanbuck:main May 29, 2024
1 check failed
Copy link

🎉 This PR is included in version 3.2.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@gr2m
Copy link
Collaborator

gr2m commented May 29, 2024

@joshjohanning
Copy link
Contributor Author

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 🎉

@gr2m
Copy link
Collaborator

gr2m commented May 29, 2024

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

@jamacku
Copy link
Contributor

jamacku commented May 30, 2024

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

It seems that it also confused the semantic-release bot - #71 (comment)

@@ -12,7 +12,7 @@ Use this action to convert issues into a unified JSON structure. Read the [Codel
with:
template-path: .github/ISSUE_TEMPLATE/bug-report.yml # optional but recommended

- run: cat ${HOME}/issue-parser-result.json
- run: cat ${{ runner.temp }}/issue-parser-result.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be considered a breaking change (v4) since it changes the behavior of the action.

Copy link
Contributor Author

@joshjohanning joshjohanning Jun 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could definitely see that. Maybe there should have been an output variable instead of a hardcoded path. And the implications of changing that path might have affected some people. Apologies!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants