| 62 | } |
| 63 | |
| 64 | func (dev *EngineDev) notifyOnFailure(ctx context.Context, repo *dagger.GitRepository, err error, discordWebhook *dagger.Secret) error { |
| 65 | if err == nil { |
| 66 | return nil |
| 67 | } |
| 68 | if discordWebhook == nil { |
| 69 | return err |
| 70 | } |
| 71 | |
| 72 | commit, err := repo.Head().Commit(ctx) |
| 73 | if err != nil { |
| 74 | commit = "failed to find commit SHA" |
| 75 | } |
| 76 | |
| 77 | daggerCloudURL, err := dag.Notify().DaggerCloudTraceURL(ctx) |
| 78 | if err != nil { |
| 79 | return fmt.Errorf("failed to fetch trace URL for failed benchmarks: %w", err) |
| 80 | } |
| 81 | |
| 82 | message := fmt.Sprintf( |
| 83 | "[failed](%s) on SHA [%s](https://github.com/dagger/dagger/commit/%s)", |
| 84 | daggerCloudURL, |
| 85 | commit, |
| 86 | commit, |
| 87 | ) |
| 88 | _, discordErr := dag.Notify().Discord(ctx, discordWebhook, message) |
| 89 | if discordErr != nil { |
| 90 | return fmt.Errorf("failed to notify discord that benchmarks failed: %w, discord error %w", err, discordErr) |
| 91 | } |
| 92 | return err |
| 93 | } |
| 94 | |
| 95 | // Run specific benchmarks while curling (pprof) dumps from their associated dev engine: |
| 96 | // defaults to heap dumps, eg: take a heap dump every second and one after the tests complete: |