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

Refresh compilation before build and deploy to fix 8239 #8721

Merged
merged 4 commits into from
Oct 27, 2022

Conversation

bhsubra
Copy link
Contributor

@bhsubra bhsubra commented Oct 19, 2022

Fixes #8239

Bicep file used in build and deploy could contain load functions like loadTextContent(..). If files used in load functions are updated, we don't update compilation. We need to manually refresh compilation before build and deploy operations so that file changes are picked up when build/deploy operations are kicked off.

Microsoft Reviewers: Open in CodeFlow

@bhsubra bhsubra marked this pull request as draft October 19, 2022 16:47
@bhsubra bhsubra changed the title Fix 8238 Fix 8239 Oct 19, 2022
@bhsubra bhsubra changed the title Fix 8239 Refresh compilation before build and deploy to fix 8239 Oct 19, 2022
@bhsubra bhsubra marked this pull request as ready for review October 19, 2022 21:41
@@ -134,6 +134,8 @@ private Compilation GetCompilation(DocumentUri documentUri)
{
var fileUri = documentUri.ToUri();

// Bicep file could contain load functions like loadTextContent(..). We'll refresh compilation to detect changes in files referenced in load functions.
Copy link
Contributor

Choose a reason for hiding this comment

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

@anthony-c-martin @majastrz Could you please review this PR? I assume the changes are probably sufficient to fix deployment from vscode. But is this indicative of a deeper problem that should be fixed elsewhere? E.g. should we be watching for changes to loadTextContent()/etc targets? Not sure if it affects anything else.

@bhsubra Does this not also affect the build command?

Copy link
Member

Choose a reason for hiding this comment

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

RefreshCompilation() was added so we could recompile after module restore is performed because there isn't a small set of files to watch in that case.

We're able to recompile as needed when files that the module depends on change today. The existing logic handles bicep files and ARM template files, but not anything that load...() functions load. It would be good to fix that problem this way and not rely on RefreshCompilation()

The tricky part will be that other file linking is done via syntax before the semantic model is created, but this logic would have to happen after binding because you need symbols to identify load...() functions.

I am also curious why we didn't have to do it for the build command.

Copy link
Member

Choose a reason for hiding this comment

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

Btw, @stan-sz is looking to solve a similar problem on #5715, so it'd be good to collaborate on a shared fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should bicep have a new command to list all inputs?

Copy link
Member

Choose a reason for hiding this comment

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

But is this indicative of a deeper problem that should be fixed elsewhere? E.g. should we be watching for changes to loadTextContent()/etc targets? Not sure if it affects anything else.

Yes, it is. This PR is a stopgap - we should be thinking about addressing the root cause in the long run.

Copy link
Member

Choose a reason for hiding this comment

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

Yup, I'm totally fine with this fix!

Copy link
Member

Choose a reason for hiding this comment

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

+1 I'm also fine with the stopgap solution.

Copy link
Member

Choose a reason for hiding this comment

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

Should bicep have a new command to list all inputs?

Yes, I think we should.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stan-sz, I created #8803 to add a new command to list all inputs. Thank you!

@@ -83,6 +83,8 @@ private string GenerateCompiledFileAndReturnBuildOutputMessage(string bicepFileP

var fileUri = documentUri.ToUri();

// Bicep file could contain load functions like loadTextContent(..). We'll refresh compilation to detect changes in files referenced in load functions.
compilationManager.RefreshCompilation(fileUri);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@majastrz, @StephenWeatherford , this change is for build command. We have same issue for build as well.

@bhsubra bhsubra merged commit 9d65be6 into main Oct 27, 2022
@bhsubra bhsubra deleted the dev/bhsubra/Fix_8239 branch October 27, 2022 23:50
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.

VS Code 'Deploy Bicep File' does not detect change in file used in loadTextContent()
5 participants