Skip to content

Commit 3dfdcb9

Browse files
authored
Add instructions for using Codespaces (#60996)
* Add instructions for using Codespaces * Automate resetting the HEAD to the same commit ID used to build the pre-built container * - Add notes about testing changes. - Add 4-core machines * Revert 4-core change since prebuild doesn't support multiple sku_names.
1 parent 0797038 commit 3dfdcb9

File tree

5 files changed

+48
-0
lines changed

5 files changed

+48
-0
lines changed

.devcontainer/devcontainer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
// Use 'onCreateCommand' to run pre-build commands inside the codespace
2424
"onCreateCommand": "${containerWorkspaceFolder}/.devcontainer/scripts/onCreateCommand.sh",
2525

26+
// Use 'postCreateCommand' to run commands after the container is created.
27+
"postCreateCommand": "${containerWorkspaceFolder}/.devcontainer/scripts/postCreateCommand.sh",
28+
2629
// Add the locally installed dotnet to the path to ensure that it is activated
2730
// This allows developers to just use 'dotnet build' on the command-line, and the local dotnet version will be used.
2831
"remoteEnv": {

.devcontainer/scripts/onCreateCommand.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ set -e
44

55
# prebuild the repo, so it is ready for development
66
./build.sh libs+clr -rc Release
7+
8+
# save the commit hash of the currently built assemblies, so developers know which version was built
9+
git rev-parse HEAD > ./artifacts/prebuild.sha
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# reset the repo to the commit hash that was used to build the prebuilt Codespace
6+
git reset --hard $(cat ./artifacts/prebuild.sha)

docs/workflow/Codespaces.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Using Codespaces
2+
Codespaces allows you to develop in a Docker container running in the cloud. You can use an in-browser version of VS Code or the full VS Code application with the [GitHub Codespaces VS Code Extension](https://marketplace.visualstudio.com/items?itemName=GitHub.codespaces). This means you don't need to install dotnet/runtime's prerequisites on your current machine in order to develop in dotnet/runtime.
3+
4+
## Create a Codespace
5+
6+
dotnet/runtime runs a nightly GitHub Action to build the latest code in the repo. This allows you to immediately start developing and testing after creating a codespace without having to build the whole repo. When the machine is created, it will have built the repo using the code as of 6 AM UTC that morning.
7+
8+
**NOTE**: In order to use a prebuilt codespace, when you create your machine be sure to select an **`8 core`** machine.
9+
10+
See https://docs.github.com/codespaces/developing-in-codespaces/creating-a-codespace#creating-a-codespace for instructions on how to create a new codespace.
11+
12+
## Updating dotnet/runtime's Codespaces Configuration
13+
14+
The Codespaces configuration is spread across the following places:
15+
16+
1. The [.devcontainer](../../.devcontainer) folder contains:
17+
- `devcontainer.json` file configures the codespace and mostly has VS Code settings
18+
- The Dockerfile used to create the image
19+
- The `scripts` folder contains any scripts that are executed during the creation of the codespace. This has the build command that builds the entire repo for prebuilds.
20+
2. The GitHub Action can be configured at [create-codespaces-prebuild](../../.github/workflows/create-codespaces-prebuild.yml)
21+
- This contains when the Action is run, what regions we build prebuilds for, and what size machines
22+
23+
To test out changes to the `.devcontainer` files, you can follow the process in [Applying changes to your configuration](https://docs.github.com/codespaces/customizing-your-codespace/configuring-codespaces-for-your-project#applying-changes-to-your-configuration) docs. This allows you to rebuild the Codespace privately before creating a PR.
24+
25+
To test out your `.yml` changes, here is the process:
26+
27+
**Note**: *Executing these steps will overwrite the current prebuilt container for the entire repo. Afterwards, anyone creating a new codespace will get a prebuilt machine with your test changes until the Action in `main` is executed again.*
28+
29+
1. Edit and commit the files to a branch.
30+
2. Push that to a branch on dotnet/runtime. Be careful that you aren't pushing to `main` or some other important branch. Prefix your branch name with your GitHub account name, so others know it is a dev branch. ex. `username/FixCodespaces`.
31+
3. In the "Actions" tab at the top of dotnet/runtime:
32+
- Select "Create Codespaces Prebuild" action on the left
33+
- On the right click "Run workflow" and pick your branch
34+
- After it runs, try to create a codespace

docs/workflow/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ To build just one part you use the root build script (build.cmd/sh), and you add
4646

4747
For instructions on how to edit code and debug your changes, see [Editing and Debugging](editing-and-debugging.md).
4848

49+
For instructions on using GitHub Codespaces, see [Codespaces](Codespaces.md).
50+
4951
## Configurations
5052

5153
You may need to build the tree in a combination of configurations. This section explains why.

0 commit comments

Comments
 (0)