forked from actions/runner
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Vscode launch scripts (actions#1117)
* Stop ignoring .vscode (launch scripts) * Check in launch scripts for config and run This can cause an issue with existing launch configuration on the machines of contributors. * Improve error msg when runner is not configured * Unignore .vscode/launch and tasks only * Remove stopAtEntry and add eof newline * Remove Runner.Listener from error message * Rename tasks and run configs * Ignore BuildConstants.cs * Use better error msg * Explain development steps in depth * Add launch config to directly debug worker * Update docs with VS Code tips * Remove auto-generated comments * Fix link to quickstart in vscode.md * Remove ':' from link to quickstart * Revert "Ignore BuildConstants.cs" This reverts commit 0f13922. * Replace `.sh` with `.(sh/cmd)` in docs
- Loading branch information
Showing
6 changed files
with
224 additions
and
16 deletions.
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
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