Skip to content

Fix/tmp dir build #16859

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

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open

Conversation

0xbad0c0d3
Copy link
Contributor

Noticed the issue with abandoned "tmp" dirs during local tests development.

cursor[bot]

This comment was marked as outdated.

@Lms24 Lms24 requested a review from mydea July 9, 2025 11:39
originalPath,
dirname(__dirname)
]
ig.add(['.gitignore', 'node_modules', 'dist', 'build']);
Copy link
Member

Choose a reason for hiding this comment

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

is it safe to not copy node_modules? I'm not familiar yet with the temp dir change (which is why I requested a review from @mydea) so it might be fine, if we install deps after we copied everything to the temp dir.

Copy link
Member

Choose a reason for hiding this comment

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

this should be fine, we install dependencies inside of the tmp dir then. However, this should not really be necessary after this has settled - if you just run yarn clean:all once, all of these things will not exist in the monorepo anymore anyhow 🤔 this is why I did not add any handling for this, not sure if we want to add this complexity here...?

TLDR this is only a "problem" if you have stale state from previous local runs. Running yarn clean should actually get rid of this fully.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, you are right, but... Usually , while developing tests, you will run them more than once (locally) and after each run you have to do pnpm install inside test-app dir. That's why this PR, also, removes:
await asyncExec('pnpm clean:test-applications', { env, cwd: __dirname });
It is useless and annoying because test-app is being copied to tmp dir.

Lms24

This comment was marked as off-topic.

}
} catch (error) {
console.error(error);
process.exit(1);
} finally {
await cleanup();
Copy link
Member

Choose a reason for hiding this comment

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

I do not think we want to cleanup when tests fail - the reason being that it makes debugging stuff super hard! Right now, if a test fails you can cd into the tmp dir and debug the actual application state properly. Since all the code is in a tmp dir, it should (in theory) be cleaned up by the OS anyhow after some time 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, OS will clean it up after reboot (at least linux). What if we will make it configurable as SKIP_REGISTRY for example?

Copy link
Member

Choose a reason for hiding this comment

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

alternative idea: What if we prefix the temp dirs we create somehow (e.g. sentry-test-…), and then make sure that running yarn clean also cleans the tmp dirs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

alternative idea: What if we prefix the temp dirs we create somehow (e.g. sentry-test-…), and then make sure that running yarn clean also cleans the tmp dirs?

Yes, why not.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@0xbad0c0d3 0xbad0c0d3 requested review from a team as code owners July 11, 2025 13:48
cod1k added 5 commits July 11, 2025 16:52
Corrected a spelling error in the console log output from "Runnings tests" to "Running tests" for clarity. This change ensures proper messaging during test execution.
Removed the `clean:test-applications` command from e2e test setup as it is unnecessary. Improved the `copyToTemp` function by integrating `.gitignore` and `node_modules` filtering to exclude unwanted files during the copy process. This ensures a cleaner and more efficient temporary workspace.
Updated the `copyToTemp` function to respect ignore patterns defined in `.gitignore` files and exclude unwanted files like `node_modules`, `dist`, and `build`. This ensures that only relevant files are copied to the temporary directory, improving efficiency and alignment with project standards.
Replace manual stdout/stderr piping with predefined stdio settings for concise and reliable output handling. Also, update the asyncExec function signature to use a stricter SpawnOptions type with omitted 'shell' and 'stdio' properties.
Replaced inline `rimraf` calls with a dedicated `clean.ts` script for better maintainability. Standardized temporary directory management by introducing a consistent prefix and leveraging `path.basename` for clarity. These changes improve code organization and simplify future modifications.
Comment on lines +16 to +18
function asyncExec(command: string, options: Omit<SpawnOptions, 'shell'|'stdio'>): Promise<void> {
return new Promise((resolve, reject) => {
const process = spawn(command, { ...options, shell: true });

process.stdout.on('data', data => {
console.log(`${data}`);
});

process.stderr.on('data', data => {
console.error(`${data}`);
});
const process = spawn(command, { ...options, shell: true, stdio: ['ignore', 'inherit', 'inherit'] });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessary, but why not to have it more clean

Comment on lines +60 to +61
const tmpPrefix = join(tmpdir(), 'sentry-e2e-tests-')
await rimraf(`${tmpPrefix}*`, { glob: true });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is here, because yarn clean will also delete everything inside test-apps, which is good, but not with active developing. And by doing like this, I believe that we will be able to debut issues, between the executions

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.

3 participants