-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Vscode launch scripts #1117
Merged
Merged
Vscode launch scripts #1117
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ecb5ff3
Stop ignoring .vscode (launch scripts)
fhammerl 59064d8
Check in launch scripts for config and run
fhammerl 59c0a58
Improve error msg when runner is not configured
fhammerl e4375f9
Unignore .vscode/launch and tasks only
fhammerl dd9b087
Remove stopAtEntry and add eof newline
fhammerl d091bcc
Merge branch 'main' of https://github.com/actions/runner into vscode-…
fhammerl 7db191e
Remove Runner.Listener from error message
fhammerl 695b75c
Rename tasks and run configs
fhammerl 0f13922
Ignore BuildConstants.cs
fhammerl dba9bf4
Use better error msg
fhammerl 530f7b9
Explain development steps in depth
fhammerl 596d967
Merge branch 'main' of https://github.com/actions/runner into vscode-…
fhammerl b6f1879
Add launch config to directly debug worker
fhammerl 5bb8282
Update docs with VS Code tips
fhammerl 971fa39
Remove auto-generated comments
fhammerl 982de0f
Fix link to quickstart in vscode.md
fhammerl 0d1b5d4
Remove ':' from link to quickstart
fhammerl bcc5730
Revert "Ignore BuildConstants.cs"
fhammerl 3f13eb0
Replace `.sh` with `.(sh/cmd)` in docs
fhammerl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Run [build]", | ||
"type": "coreclr", | ||
"request": "launch", | ||
"preLaunchTask": "build runner layout", | ||
"program": "${workspaceFolder}/_layout/bin/Runner.Listener", | ||
"args": [ | ||
"run" | ||
], | ||
"cwd": "${workspaceFolder}/src", | ||
"console": "integratedTerminal", | ||
"requireExactSource": false, | ||
}, | ||
{ | ||
"name": "Run", | ||
"type": "coreclr", | ||
"request": "launch", | ||
"program": "${workspaceFolder}/_layout/bin/Runner.Listener", | ||
"args": [ | ||
"run" | ||
], | ||
"cwd": "${workspaceFolder}/src", | ||
"console": "integratedTerminal", | ||
"requireExactSource": false, | ||
}, | ||
{ | ||
"name": "Configure", | ||
"type": "coreclr", | ||
"request": "launch", | ||
"preLaunchTask": "create runner layout", | ||
"program": "${workspaceFolder}/_layout/bin/Runner.Listener", | ||
"args": [ | ||
"configure" | ||
], | ||
"cwd": "${workspaceFolder}/src", | ||
"console": "integratedTerminal", | ||
"requireExactSource": false, | ||
}, | ||
{ | ||
"name": "Debug Worker", | ||
"type": "coreclr", | ||
"request": "attach", | ||
"processName": "Runner.Worker", | ||
"requireExactSource": false, | ||
}, | ||
{ | ||
"name": "Attach Debugger", | ||
"type": "coreclr", | ||
"request": "attach", | ||
"processId": "${command:pickProcess}", | ||
"requireExactSource": false, | ||
}, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "create runner layout", | ||
"detail": "Build and Copy all projects, scripts and external dependencies to _layout from src (run this the first time or after deleting _layout)", | ||
"command": "./dev.sh", | ||
"windows": { | ||
"command": "dev.cmd" | ||
}, | ||
"args": [ | ||
"layout" | ||
], | ||
"options": { | ||
"cwd": "${workspaceFolder}/src" | ||
}, | ||
}, | ||
{ | ||
"label": "build runner layout", | ||
"detail": "Build and Copy all projects to _layout from src (run this on code change)", | ||
"command": "./dev.sh", | ||
"windows": { | ||
"command": "dev.cmd" | ||
}, | ||
"args": [ | ||
"build" | ||
], | ||
"options": { | ||
"cwd": "${workspaceFolder}/src" | ||
}, | ||
} | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,12 +19,35 @@ We ask that before significant effort is put into code changes, that we have agr | |
|
||
An ADR is an Architectural Decision Record. This allows consensus on the direction forward and also serves as a record of the change and motivation. [Read more here](adrs/README.md) | ||
|
||
## Development Life Cycle | ||
|
||
### Required Dev Dependencies | ||
## Required Dev Dependencies | ||
|
||
  Git for Windows and Linux [Install Here](https://git-scm.com/downloads) (needed for dev sh script) | ||
|
||
## Quickstart: Run a job from a real repository | ||
|
||
If you just want to get from building the sourcecode to using it to execute an action, you will need: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. source code |
||
|
||
- The url of your repository | ||
- A runner registration token. You can find it at `https://github.com/{your-repo}/settings/actions/runners/new` | ||
|
||
|
||
```bash | ||
git clone https://github.com/actions/runner | ||
cd runner/src | ||
./dev.(sh/cmd) layout # the runner that built from source is in {root}/_layout | ||
cd ../_layout | ||
./config.(sh/cmd) --url https://github.com/{your-repo} --token ABCABCABCABCABCABCABCABCABCAB # accept default name, labels and work folder | ||
./run.(sh/cmd) | ||
``` | ||
|
||
If you trigger a job now, you can see the runner execute it. | ||
|
||
Tip: Make sure your job can run on this runner. The easiest way is to set `runs-on: self-hosted` in the workflow file. | ||
|
||
|
||
## Development Life Cycle | ||
If you're using VS Code, you can follow [these](contribute/vscode.md) steps instead. | ||
|
||
### To Build, Test, Layout | ||
|
||
Navigate to the `src` directory and run the following command: | ||
|
@@ -39,7 +62,7 @@ Navigate to the `src` directory and run the following command: | |
* `build` (`b`): Build everything and update runner layout folder | ||
* `test` (`t`): Build runner binaries and run unit tests | ||
|
||
**Sample developer flow:** | ||
### Sample developer flow: | ||
|
||
```bash | ||
git clone https://github.com/actions/runner | ||
|
@@ -51,40 +74,81 @@ cd ./src | |
./dev.(sh/cmd) test # run all unit tests before git commit/push | ||
``` | ||
|
||
**Configure Runner:** | ||
Let's break that down. | ||
|
||
### Clone repository: | ||
|
||
```bash | ||
git clone https://github.com/actions/runner | ||
cd runner | ||
``` | ||
If you want to push your changes to a remote, it is recommended you fork the repository and use that fork as your origin instead of `https://github.com/actions/runner`. | ||
|
||
|
||
### Build Layout: | ||
|
||
This command will build all projects, then copies them and other dependencies into a folder called `_layout`. The binaries in this folder are then used for running, debugging the runner. | ||
|
||
```bash | ||
cd ./src # execute the script from this folder | ||
./dev.(sh/cmd) layout # the runner that built from source is in {root}/_layout | ||
``` | ||
|
||
If you make code changes after this point, use the argument `build` to build your code in the `src` folder to keep your `_layout` folder up to date. | ||
|
||
```bash | ||
cd ./src | ||
./dev.(sh/cmd) build # {root}/_layout will get updated | ||
``` | ||
### Test Layout: | ||
|
||
This command runs the suite of unit tests in the project | ||
|
||
```bash | ||
cd ./src | ||
./dev.(sh/cmd) test # run all unit tests before git commit/push | ||
``` | ||
|
||
### Configure Runner: | ||
|
||
If you want to manually test your runner and run actions from a real repository, you'll have to configure it before running it. | ||
|
||
```bash | ||
cd runner/_layout | ||
./config.sh # configure your custom runner | ||
./config.(sh/cmd) # configure your custom runner | ||
``` | ||
|
||
You will need your the name of your repository and a runner registration token. | ||
You can find both at `https://github.com/{your-repo}/settings/actions/runners/new` | ||
You will need your the name of your repository and a runner registration token. | ||
Check [Quickstart](##Quickstart:-Run-a-job-from-a-real-repository) if you don't know how to get this token. | ||
|
||
These can also be passed down as arguments to `config.(sh/cmd)`: | ||
```bash | ||
cd runner/_layout | ||
./config.sh --url https://github.com/{your-repo} --token ABCABCABCABCABCABCABCABCABCAB | ||
./config.(sh/cmd) --url https://github.com/{your-repo} --token ABCABCABCABCABCABCABCABCABCAB | ||
``` | ||
|
||
**Run Runner (Configure first!):** | ||
### Run Runner | ||
|
||
All that's left to do is to start the runner: | ||
```bash | ||
cd runner/_layout | ||
./run.sh # run your custom runner | ||
./run.(sh/cmd) # run your custom runner | ||
``` | ||
|
||
**View logs:** | ||
### View logs: | ||
|
||
```bash | ||
cd runner/_layout/_diag | ||
ls | ||
cat (Runner/Worker)_TIMESTAMP.log # view your log file | ||
``` | ||
|
||
### Editors | ||
## Editors | ||
|
||
[Using Visual Studio Code](https://code.visualstudio.com/) | ||
[Using Visual Studio](https://code.visualstudio.com/docs) | ||
|
||
### Styling | ||
## Styling | ||
|
||
We use the .NET Foundation and CoreCLR style guidelines [located here]( | ||
https://github.com/dotnet/corefx/blob/master/Documentation/coding-guidelines/coding-style.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Development Life Cycle using VS Code: | ||
|
||
These examples use VS Code, but the idea should be similar across all IDEs as long as you attach to the same processes in the right folder. | ||
## Configure | ||
|
||
To successfully start the runner, you need to register it using a repository and a runner registration token. | ||
Run `Configure` first to build the source code and set up the runner in `_layout`. | ||
Once it's done creating `_layout`, it asks for the url of your repository and your token in the terminal. | ||
|
||
Check [Quickstart](../contribute.md#quickstart-run-a-job-from-a-real-repository) if you don't know how to get this token. | ||
|
||
## Debugging | ||
|
||
Debugging the full lifecycle of a job can be tricky, because there are multiple processes involved. | ||
All the configs below can be found in `.vscode/launch.json`. | ||
|
||
## Debug the Listener | ||
|
||
```json | ||
{ | ||
"name": "Run [build]", | ||
"type": "coreclr", | ||
"request": "launch", | ||
"preLaunchTask": "build runner layout", // use the config called "Run" to launch without rebuild | ||
"program": "${workspaceFolder}/_layout/bin/Runner.Listener", | ||
"args": [ | ||
"run" // run without args to print usage | ||
], | ||
"cwd": "${workspaceFolder}/src", | ||
"console": "integratedTerminal", | ||
"requireExactSource": false, | ||
} | ||
``` | ||
|
||
If you launch `Run` or `Run [build]`, it starts a process called `Runner.Listener`. | ||
This process will receive any job queued on this repository if the job runs on matching labels (e.g `runs-on: self-hosted`). | ||
Once a job is received, a `Runner.Listener` starts a new process of `Runner.Worker`. | ||
Since this is a diferent process, you can't use the same debugger session debug it. | ||
Instead, a parallel debugging session has to be started, using a different launch config. | ||
Luckily, VS Code supports multiple parallel debugging sessions. | ||
|
||
## Debug the Worker | ||
|
||
Because the worker process is usually started by the listener instead of an IDE, debugging it from start to finish can be tricky. | ||
For this reason, `Runner.Worker` can be configured to wait for a debugger to be attached before it begins any actual work. | ||
|
||
Set the environment variable `GITHUB_ACTIONS_RUNNER_ATTACH_DEBUGGER` to `true` or `1` to enable this wait. | ||
All worker processes now will wait 20 seconds before they start working on their task. | ||
|
||
This gives enough time to attach a debugger by running `Debug Worker`. | ||
If for some reason you have multiple workers running, run the launch config `Attach` instead. | ||
Select `Runner.Worker` from the running processes when VS Code prompts for it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote up a quickstart session as a good way to get to know the repo, let me know what you think.