Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions docs/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@ Next, clone https://github.com/dependabot/dependabot-core. This project contains

Try opening a terminal and run `script/dependabot update go_modules dependabot/cli --debug` in the `dependabot-core` project directory. This will drop you in an interactive session with the update ready to proceed.

To perform the update, you need to run two commands:
To perform the update, you need to run:

- `bin/run fetch_files`
- `bin/run update_files`

If the problem you are debugging is during the fetch step, the fetch_files command will be all you need to run.

If the problem is after the fetch step, you can repeatedly run update_files while you're debugging.

In the example `script/dependabot` command above, try running an update in the container.

Next, let's try adding a `debugger` statement. Open the `dependabot-core` project in your favorite editor. For example, we can open the file `go_modules/lib/dependabot/go_modules/update_checker.rb`. Then in `latest_resolvable_version` we can add a `debugger` statement like this:
Expand All @@ -32,7 +27,7 @@ Next, let's try adding a `debugger` statement. Open the `dependabot-core` projec

> **Note** You don't have to restart your CLI session, the changes are automatically synced to the container!

In the interactive debugging session, run `bin/run fetch_files` and `bin/run update_files`. During the update_files command, the Ruby debugger will open. It should look something like this:
In the interactive debugging session, run `bin/run update_files`. During the update_files command, the Ruby debugger will open. It should look something like this:

```ruby
[11, 20] in ~/go_modules/lib/dependabot/go_modules/update_checker.rb
Expand Down Expand Up @@ -60,7 +55,7 @@ At this prompt, you can run [debugger commands](https://github.com/ruby/debug) t

If your Dependabot job is hanging and would like to figure out why, the CLI is the perfect tool for the job.

Start by running the update that recreates the hang with `dependabot update <ecosystem> <org/repo>`. Once the hang is reproducible, run with the `--debug` flag and the run the `fetch_files` and `update_files` commands and wait until the job hangs.
Start by running the update that recreates the hang with `dependabot update <ecosystem> <org/repo>`. Once the hang is reproducible, run with the `--debug` flag and the run the `update_files` command and wait until the job hangs.

Once it does hang, hit CTL-C, and you'll get a stack trace leading you to the problematic code.

Expand Down
4 changes: 2 additions & 2 deletions internal/infra/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
)

var runCmds = map[model.RunCommand]string{
model.UpdateFilesCommand: "bin/run fetch_files && bin/run update_files",
model.UpdateGraphCommand: "bin/run fetch_files && bin/run update_graph",
model.UpdateFilesCommand: "bin/run update_files",
model.UpdateGraphCommand: "bin/run update_graph",
}

type RunParams struct {
Expand Down
3 changes: 0 additions & 3 deletions internal/infra/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const (

const (
guestInputDir = "/home/dependabot/dependabot-updater/job.json"
guestOutput = "/home/dependabot/dependabot-updater/output.json"
guestRepoDir = "/home/dependabot/dependabot-updater/repo"

caseSensitiveContainerRoot = "/dpdbot"
Expand Down Expand Up @@ -315,10 +314,8 @@ func userEnv(proxyURL string, apiUrl string, job *model.Job, additionalEnvVars [
fmt.Sprintf("DEPENDABOT_JOB_ID=%v", firstNonEmpty(os.Getenv("DEPENDABOT_JOB_ID"), jobID)),
fmt.Sprintf("DEPENDABOT_JOB_TOKEN=%v", ""),
fmt.Sprintf("DEPENDABOT_JOB_PATH=%v", guestInputDir),
fmt.Sprintf("DEPENDABOT_OUTPUT_PATH=%v", guestOutput),
fmt.Sprintf("DEPENDABOT_API_URL=%s", apiUrl),
fmt.Sprintf("SSL_CERT_FILE=%v/ca-certificates.crt", certsPath),
"UPDATER_ONE_CONTAINER=true",
"UPDATER_DETERMINISTIC=true",
}

Expand Down
1 change: 0 additions & 1 deletion testdata/scripts/basic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ exec docker build -qt dummy-updater .
dependabot update go_modules dependabot/cli --updater-image dummy-updater

# assert the dummy is working
stderr 'bin/run arguments: fetch_files'
stderr 'bin/run arguments: update_files'

exec docker rmi -f dummy-updater
Expand Down
2 changes: 0 additions & 2 deletions testdata/scripts/graph.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ exec docker build -qt graph-updater .
dependabot graph go_modules dependabot/cli -o out.yml --updater-image graph-updater

# assert the dummy is working
stderr 'bin/run arguments: fetch_files'
stderr 'bin/run arguments: update_graph'
stderr '"enable_dependency_submission_poc":true'

# Verify the smoke test can run the graph command
dependabot test -f out.yml --updater-image graph-updater

stderr 'bin/run arguments: fetch_files'
stderr 'bin/run arguments: update_graph'

exec docker rmi -f graph-updater
Expand Down
7 changes: 2 additions & 5 deletions testdata/scripts/smb-mount.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@ echo "Updated those certificates for ya"
-- run --
#!/usr/bin/env bash

if [ "$1" = "fetch_files" ]; then
# git clone would have created this directory
mkdir -p "$DEPENDABOT_REPO_CONTENTS_PATH"
exit 0
fi
# git clone would have created this directory
mkdir -p "$DEPENDABOT_REPO_CONTENTS_PATH"

echo "test file" > "$DEPENDABOT_REPO_CONTENTS_PATH/test.txt"
if [ -e "$DEPENDABOT_CASE_INSENSITIVE_REPO_CONTENTS_PATH/TEST.TXT" ]; then
Expand Down
Loading