Skip to content

Create copilot-setup-steps.yml #115834

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

Merged
merged 2 commits into from
May 22, 2025
Merged

Create copilot-setup-steps.yml #115834

merged 2 commits into from
May 22, 2025

Conversation

CarnaViire
Copy link
Member

@CarnaViire CarnaViire commented May 21, 2025

Based on copilot-setup-steps.yml from dotnet/aspire and dotnet/aspnetcore.

Script args based on

- script: $(Build.SourcesDirectory)/eng/common/msbuild.sh --restore --ci --warnaserror false ${{ parameters.sendParams }}

Expected to help with the Firewall warnings over pkgs.dev.azure.com on Copilot PRs (e.g. #115826)

@Copilot Copilot AI review requested due to automatic review settings May 21, 2025 13:45
@CarnaViire CarnaViire requested review from jeffhandley and a team as code owners May 21, 2025 13:45
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR creates a new GitHub Actions workflow file for running Copilot setup steps. It defines a new job named "copilot-setup-steps" which checks out the repository code and then runs a build script to restore the solution.

  • Added a new workflow file (.github/workflows/copilot-setup-steps.yml)
  • Configured the job to run on ubuntu-latest with proper permissions and setup steps

@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label May 21, 2025
@stephentoub
Copy link
Member

Expected to help with the Firewall warnings over pkgs.dev.azure.com on Copilot PRs (e.g. #115826)

Should we also add the relevant endpoints to the firewall allow list?

@danmoseley
Copy link
Member

Should we also add the relevant endpoints to the firewall allow list?

We can, but if this makes that unnecessary, its nice to keep the network isolation?

@danmoseley danmoseley enabled auto-merge (squash) May 21, 2025 15:41
@danmoseley danmoseley added area-Infrastructure and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels May 21, 2025
Copy link
Contributor

Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

@stephentoub
Copy link
Member

if this makes that unnecessary

Does it? I very frequently see builds trying to do partial restores even after I've done full builds.

@ericstj ericstj requested a review from ViktorHofer May 21, 2025 16:00
@danmoseley
Copy link
Member

Does it? I very frequently see builds trying to do partial restores even after I've done full builds.

Then it will be necessary as well yeah.

# You can define any steps you want, and they will run before the agent starts.
# If you do not check out your code, Copilot will do this for you.
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Copy link
Member

Choose a reason for hiding this comment

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

How does this get updated?

Copy link
Member

Choose a reason for hiding this comment

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

I guess we have other usages https://github.com/search?q=repo%3Adotnet%2Fruntime%20actions%2Fcheckout%40&type=code. Consider using a tag if that's better.

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Restore solution
Copy link
Member

Choose a reason for hiding this comment

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

Thinking aloud here - would it also help to set some things in the environment so that it would use the dotnet that it pulled down on the path? I'm not sure what sort of resources the agent will be using, but we should try to set it up for local-development as close as possible. How do we see / measure how good these steps are working for the agent? Can we see it try them and then see how successful it is at doing things?

Copy link
Member

Choose a reason for hiding this comment

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

it seems to successfully know to go to the root of the repo and run 'build.sh' or whatever the onboarding instructions say.

But, if you add a .github\copilot-instructions.md you can be explicit about how it should do incremental subtree builds and how to run tests too.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think putting dotnet on the path and including some instructions for building individual projects, testing individual projects might be a good idea since I expect the agent is actually doing these things so giving it the quicker inner-loops like real devs use should make it more efficient.

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree it's a good idea to add some specific instructions. I'll try it out in a separate PR.

@danmoseley
Copy link
Member

I'm not sure it technically even needs this step, since runtime can be built from a single entry-point. My understanding of this workflow is to help steer it towards the right actions (acquiring pre-requisites for example and setting up the env). Starting with a restore isn't a bad thing, but I'm not sure it's not necessar

@ericstj not sure whether you're aware based on this comment but by default the agent itself is completely firewalled. The idea is that this build step will pull things down so that subsequent builds succeed. They're talking about things like caching the built tree, etc eventually. Of course, you can also open the firewall selectively.

@ViktorHofer
Copy link
Member

ViktorHofer commented May 21, 2025

If you want to restore more it needs to be told to include test projects, additionally I think there are some other projects that only build for things like mono / wasm etc. @ViktorHofer do we have a knob that says "restore for everything?" sort of like how allconfigurations used to work?

Not that I know of. I don't think it's possible to include the default subsets and also include the libs tests and other test subsets without listing them explicitly. The subset infrastructure in runtime isn't great. It also became extremely complex over the years.

FWIW I would probably add /p:BuildAllConfigurations=true /p:DotNetBuildAllRuntimePacks=true here to make sure that all libraries TFMs and all runtime packs projects are restored.

@ericstj
Copy link
Member

ericstj commented May 21, 2025

I'm not sure it technically even needs this step, since runtime can be built from a single entry-point. My understanding of this workflow is to help steer it towards the right actions (acquiring pre-requisites for example and setting up the env). Starting with a restore isn't a bad thing, but I'm not sure it's not necessar

@ericstj not sure whether you're aware based on this comment but by default the agent itself is completely firewalled. The idea is that this build step will pull things down so that subsequent builds succeed. They're talking about things like caching the built tree, etc eventually. Of course, you can also open the firewall selectively.

I see, that makes sense. I see that here https://docs.github.com/en/copilot/customizing-copilot/customizing-or-disabling-the-firewall-for-copilot-coding-agent. Seems like that should be mentioned in the main article since that seems to be the motivating factor behind adding these.

Co-authored-by: Eric StJohn <ericstj@microsoft.com>
@CarnaViire
Copy link
Member Author

/ba-g copilot infra-only change

@danmoseley danmoseley merged commit 7e7e195 into main May 22, 2025
13 of 14 checks passed
@CarnaViire CarnaViire deleted the CarnaViire-patch-1 branch May 22, 2025 10:09
@CarnaViire
Copy link
Member Author

Good news: this setup actually helped with restore (at least for the libs).

Bad news: it is insistent on using dotnet build ./src/libraries/....csproj instead of build.sh ..., so the build still fails because clr should have been built first 🥲

Maybe .github\copilot-instructions.md will be able to help with that.

@ericstj
Copy link
Member

ericstj commented May 22, 2025

Yeah that should help. We might also want to put dotnet on the path so that it can directly build projects like that. I think that should make it more effective rather than doing a full build from the root every time.

@ViktorHofer
Copy link
Member

ViktorHofer commented May 22, 2025

We might also want to put dotnet on the path so that it can directly build projects like that

We should use the new global.json paths feature: https://learn.microsoft.com/en-us/dotnet/core/tools/global-json#paths. So that the resolution of the desired .NET SDK is handled by the host. It still needs to be acquired of course which is handled by the eng/common scripts and a globally installed one would need to be available.

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

Successfully merging this pull request may close these issues.

8 participants