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

Use same working directory for preparing cache directory as it used in running analysis #3421

Merged
merged 1 commit into from
Jul 16, 2021
Merged

Conversation

JoshuaBehrens
Copy link
Contributor

Imagine the following directory structure

.
|____test
| |____phpunit.xml
|____dev-ops
| |____.build
| |____psalm.xml
|____composer.json
|____src
| |____FooBar.php

The psalm.xml looks like this:

<?xml version="1.0"?>
<psalm
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="https://getpsalm.org/schema/config"
    xsi:schemaLocation="https://getpsalm.org/schema/config ../vendor/vimeo/psalm/config.xsd"
    cacheDirectory=".build/psalm"
    errorLevel="1"
    resolveFromConfigFile="true"
>
    <projectFiles>
        <directory name="../src/" />
        <directory name="../test/" />
        <ignoreFiles>
            <directory name="../vendor/" />
        </ignoreFiles>
    </projectFiles>
</psalm>

The dev-ops/.build directory is intended to contain every temporary files that should not be versioned and are only used to be a file dump for caches and processing.

Like this the cache directory is prepared in .build/psalm/cachehash1234567890 but every cache writes into dev-ops/.build/psalm/cachehash1234567890.

This is due to the fact that the config prepares the cache folder before the working directory is later changed during processing

psalm/src/psalm.php

Lines 310 to 313 in 9aa4622

if ($config->resolve_from_config_file) {
$current_dir = $config->base_dir;
chdir($current_dir);
}

The solution is open to discussion as I am unsure whether it should be solved like this on the long run but it works out for me not creating an empty directory at a location it should not write to.

JoshuaBehrens added a commit to HEPTACOM/heptaconnect-dataset-base that referenced this pull request Nov 2, 2020
@JoshuaBehrens
Copy link
Contributor Author

Just a short bumper for others looking for a solution: the current way to fix this is to change the working directory to the directory of the configuration file before executing psalm. Sort of ok but should not be needed

JoshuaBehrens added a commit to HEPTACOM/heptaconnect-sdk that referenced this pull request Dec 4, 2020
src/Psalm/Config.php Show resolved Hide resolved
src/Psalm/Config.php Outdated Show resolved Hide resolved
@weirdan
Copy link
Collaborator

weirdan commented Dec 4, 2020

@muglug this looks reasonable. Are there any reasons to not merge this?

@JoshuaBehrens
Copy link
Contributor Author

Thank you for the review. I'll gonna squash your suggestions :)

@JoshuaBehrens
Copy link
Contributor Author

I added your suggestions and rebased the code 😁

@weirdan weirdan requested a review from muglug December 6, 2020 23:01
@weirdan weirdan merged commit 26859d3 into vimeo:master Jul 16, 2021
@weirdan
Copy link
Collaborator

weirdan commented Jul 16, 2021

Thanks!

@JoshuaBehrens
Copy link
Contributor Author

Damn that merge surprised my notifications 😲 I must admit I forgot that I made this change but I exactly know what I'll change in my projects now :)

thank you for the merge 🙇

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.

None yet

2 participants