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

feat (codespaces) - Add initial support for codespaces #27483

Merged
merged 5 commits into from
Mar 10, 2022

Conversation

ShreyasJejurkar
Copy link
Contributor

@ShreyasJejurkar ShreyasJejurkar commented Feb 21, 2022

  1. Added support for codespaces using .NET and SQL Server docker image.
  2. Entire repository can be built and can run tests in the cloud.
  3. Added commonly used tasks to tasks.json can be invoked using pressing CTRL + SHIFT + P and selecting Run Tasks as an option.
  4. Added sql-cmd to the PATH, so that users can access DB right off after the creating container. Developers can access both sql-cmd on the command line and with GUI inside VSCode for SQL Server.
  5. I have built the entire repository successfully and is workable. The inner loop just works nicely!

Once all changes as done as part of PR feedback, planning to include a section for VSCode and codespaces users on how to build, developed, and test EF in the cloud in this doc => https://github.com/dotnet/efcore/blob/main/docs/getting-and-building-the-code.md.

@ajcvickers
Copy link
Member

@captainsafia Kevin mentioned that you had some experience of enabling codespaces. Could you take a look at this and see what you think?

"omnisharp.enableRoslynAnalyzers": true,
"omnisharp.enableEditorConfigSupport": true,
"omnisharp.enableImportCompletion": true,
"omnisharp.useModernNet": true,
Copy link
Member

Choose a reason for hiding this comment

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

Oooh! Interesting. I think we probably want to enable this in the aspnetcore repo too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean the last option right? useModernNet? Yes, right now am using it in codespaces for the aspnetcore repo. But somehow the intellisense got slowed because of this. Am still figuring out that one for the aspnetcore repo. But this works great here in efcore repo.

"settings": {
"mssql.connections": [
{
"server": "localhost,1433",
Copy link
Member

Choose a reason for hiding this comment

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

I assume this is here so the SQL extension can automatically connect to the dev database from VS Code?

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, interestingly, I can able to run tests from the efcore repo directly against this DB!

Copy link
Member

Choose a reason for hiding this comment

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

Test__SqlServer__DefaultConnection below makes it happen.

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, exactly I did that based on docs on repo!

Copy link
Member

@captainsafia captainsafia left a comment

Choose a reason for hiding this comment

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

The Codespaces specific stuff looks legit.

I'm not experienced with the mssql bit of things but it seems like a sensible dev setup.

@ShreyasJejurkar
Copy link
Contributor Author

ShreyasJejurkar commented Mar 4, 2022

The Codespaces specific stuff looks legit.

I'm not experienced with the mssql bit of things but it seems like a sensible dev setup.

Yes, I want people from the EF core repo (who do commit every day to this repo) to try this and provide feedback. Because the experience is quite great for old and newcomers as well. We can write code, write tests, execute against local DB which is inside codespace and much more! Please give it a try EF core people!

Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

The SQL Server setup looks good to me, thanks!

I'm no VS Code/Codespaces expert and didn't verify this all the way (a VS Code test runner would need to be installed etc.), but is looks good enough to merge. Will leave this open for a few more days in case someone else from the team feels like playing around with it.

dacpath=$2
sqlpath=$3

echo "SELECT * FROM SYS.DATABASES" | dd of=testsqlconnection.sql
Copy link
Member

Choose a reason for hiding this comment

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

Any reason not to simplify to:

Suggested change
echo "SELECT * FROM SYS.DATABASES" | dd of=testsqlconnection.sql
echo "SELECT * FROM SYS.DATABASES" > testsqlconnection.sql

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 script was automatically created when we asked codespaces to include support for SQL Server. So I didn't touch.
Sorry for the late reply! :(

echo "SELECT * FROM SYS.DATABASES" | dd of=testsqlconnection.sql
for i in {1..60};
do
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SApassword -d master -i testsqlconnection.sql > /dev/null
Copy link
Member

Choose a reason for hiding this comment

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

Or even better: sqlcmd supports providing a query on the cmdline with -Q, can use that instead of a temp file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the script was created by codespaces itself. I didn't write this!

If we can improve it by any means, I am ok with it! :)

@ajcvickers ajcvickers merged commit 9599197 into dotnet:main Mar 10, 2022
@ajcvickers
Copy link
Member

Thanks @ShreyasJejurkar for the PR, and thanks @captainsafia for the review.

"DOTNET_MULTILEVEL_LOOKUP": "0",
"TARGET": "net7.0",
"DOTNET_WATCH_SUPPRESS_LAUNCH_BROWSER": "true",
"Test__SqlServer__DefaultConnection ": "Server=localhost;Database=master;User Id=sa;password=Pass@word;Trusted_Connection=False;MultipleActiveResultSets=true;"
Copy link
Member

Choose a reason for hiding this comment

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

Is space at the end of env var correct? While repo will build/test fine if SqlServer is not running, need to see if SqlServer tests actually ran.

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, before creating this PR, I run all tests with the script which is at the root of the repo, not even a single test case failed!

ajcvickers added a commit that referenced this pull request Mar 16, 2022
@captainsafia
Copy link
Member

@ajcvickers Aw shucks! Any reason this needed to be reverted? I'm trying to stay aware of any Codespace-related issue affecting our repos.

@ajcvickers
Copy link
Member

@captainsafia "Passwords are not allowed in config files." Will forward you the internal email on this.

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

Successfully merging this pull request may close these issues.

5 participants