Skip to content
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

Add graphql mutations to delete builds and invocations #80

Merged
merged 6 commits into from
Feb 11, 2025
Merged
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
116 changes: 65 additions & 51 deletions ent/gen/ent/migrate/schema.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions ent/schema/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ go_library(
"@com_github_google_uuid//:uuid",
"@io_entgo_contrib//entgql",
"@io_entgo_ent//:ent",
"@io_entgo_ent//dialect/entsql",
"@io_entgo_ent//schema",
"@io_entgo_ent//schema/edge",
"@io_entgo_ent//schema/field",
Expand Down
6 changes: 5 additions & 1 deletion ent/schema/actioncachestatistics.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package schema

import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
Expand Down Expand Up @@ -42,6 +43,9 @@ func (ActionCacheStatistics) Edges() []ent.Edge {
Unique(),

// Breakdown of the cache misses based on the reasons behind them.
edge.To("miss_details", MissDetail.Type),
edge.To("miss_details", MissDetail.Type).
Annotations(
entsql.OnDelete(entsql.Cascade),
),
}
}
16 changes: 13 additions & 3 deletions ent/schema/actionsummary.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package schema

import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
Expand Down Expand Up @@ -46,13 +47,22 @@ func (ActionSummary) Edges() []ent.Edge {
Unique(),

// Contains the top N actions by number of actions executed.
edge.To("action_data", ActionData.Type),
edge.To("action_data", ActionData.Type).
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Count of which Runner types were executed which actions.
edge.To("runner_count", RunnerCount.Type),
edge.To("runner_count", RunnerCount.Type).
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Information about the action cache behavior during a single invocation.
edge.To("action_cache_statistics", ActionCacheStatistics.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),
}
}
21 changes: 17 additions & 4 deletions ent/schema/artifactmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package schema

import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema/edge"
)

Expand All @@ -26,25 +27,37 @@ func (ArtifactMetrics) Edges() []ent.Edge {
// Measures all source files newly read this build. Does not include
// unchanged sources on incremental builds.
edge.To("source_artifacts_read", FilesMetric.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Measures all output artifacts from executed actions. This includes
// actions that were cached locally (via the action cache) or remotely (via
// a remote cache or executor), but does *not* include outputs of actions
// that were cached internally in Skyframe.
edge.To("output_artifacts_seen", FilesMetric.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Measures all output artifacts from actions that were cached locally
// via the action cache. These artifacts were already present on disk at the
// start of the build. Does not include Skyframe-cached actions' outputs.
edge.To("output_artifacts_from_action_cache", FilesMetric.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Measures all artifacts that belong to a top-level output group. Does not
// deduplicate, so if there are two top-level targets in this build that
// share an artifact, it will be counted twice.
edge.To("top_level_artifacts", FilesMetric.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),
}
}
24 changes: 20 additions & 4 deletions ent/schema/bazelinvocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package schema
import (
"entgo.io/contrib/entgql"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
Expand Down Expand Up @@ -99,21 +100,36 @@ func (BazelInvocation) Edges() []ent.Edge {
// Edge to any probles detected.
// NOTE: Uses custom resolver / types.
edge.To("problems", BazelInvocationProblem.Type).
Annotations(entgql.Skip(entgql.SkipType)),
Annotations(
entgql.Skip(entgql.SkipType),
entsql.OnDelete(entsql.Cascade),
),

// Build Metrics for the Completed Invocation
edge.To("metrics", Metrics.Type).
Annotations(
entsql.OnDelete(entsql.Cascade),
).
Unique(),

// Test Data for the completed Invocation
edge.To("test_collection", TestCollection.Type),
edge.To("test_collection", TestCollection.Type).
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Target Data for the completed Invocation
edge.To("targets", TargetPair.Type),
edge.To("targets", TargetPair.Type).
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Edge to source control information
edge.To("source_control", SourceControl.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),
}
}

Expand Down
6 changes: 5 additions & 1 deletion ent/schema/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package schema
import (
"entgo.io/contrib/entgql"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
Expand All @@ -28,7 +29,10 @@ func (Build) Fields() []ent.Field {
// Edges of the Build.
func (Build) Edges() []ent.Edge {
return []ent.Edge{
edge.To("invocations", BazelInvocation.Type),
edge.To("invocations", BazelInvocation.Type).
Annotations(
entsql.OnDelete(entsql.Cascade),
),
}
}

Expand Down
26 changes: 21 additions & 5 deletions ent/schema/buildgraphmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package schema

import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
Expand Down Expand Up @@ -84,32 +85,47 @@ func (BuildGraphMetrics) Edges() []ent.Edge {
// those that transitively depend on a node that changed by itself (e.g. one
// representing a file in the file system)
edge.To("dirtied_values", EvaluationStat.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Changed Values.
// Number of SkyValues that changed by themselves. For example, when a file
// on the file system changes, the SkyValue representing it will change.
edge.To("changed_values", EvaluationStat.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Built Values.
// Number of SkyValues that were built. This means that they were evaluated
// and were found to have changed from their previous version.
edge.To("built_values", EvaluationStat.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Cleaned Values.
// Number of SkyValues that were evaluated and found clean, i.e. equal to
// their previous version.
edge.To("cleaned_values", EvaluationStat.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Evaluated Values.
// Number of evaluations to build SkyValues. This includes restarted
// evaluations, which means there can be multiple evaluations per built
// SkyValue. Subtract built_values from this number to get the number of
// restarted evaluations.
edge.To("evaluated_values", EvaluationStat.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),
}
}
6 changes: 5 additions & 1 deletion ent/schema/dynamicexecutionmetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package schema

import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema/edge"
)

Expand All @@ -24,6 +25,9 @@ func (DynamicExecutionMetrics) Edges() []ent.Edge {
Unique(),

// Race statistics grouped by mnemonic, local_name, remote_name.
edge.To("race_statistics", RaceStatistics.Type),
edge.To("race_statistics", RaceStatistics.Type).
Annotations(
entsql.OnDelete(entsql.Cascade),
),
}
}
11 changes: 9 additions & 2 deletions ent/schema/executioninfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package schema

import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
Expand Down Expand Up @@ -44,9 +45,15 @@ func (ExectionInfo) Edges() []ent.Edge {
// Represents a hierarchical timing breakdown of an activity.
// The top level time should be the total time of the activity.
// Invariant: `time` >= sum of `time`s of all direct children.
edge.To("timing_breakdown", TimingBreakdown.Type).Unique(),
edge.To("timing_breakdown", TimingBreakdown.Type).Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// resource usage info
edge.To("resource_usage", ResourceUsage.Type),
edge.To("resource_usage", ResourceUsage.Type).
Annotations(
entsql.OnDelete(entsql.Cascade),
),
}
}
6 changes: 5 additions & 1 deletion ent/schema/memorymetrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package schema

import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
Expand Down Expand Up @@ -37,6 +38,9 @@ func (MemoryMetrics) Edges() []ent.Edge {
Unique(),

// Metrics about garbage collection
edge.To("garbage_metrics", GarbageMetrics.Type),
edge.To("garbage_metrics", GarbageMetrics.Type).
Annotations(
entsql.OnDelete(entsql.Cascade),
),
}
}
51 changes: 41 additions & 10 deletions ent/schema/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package schema
import (
"entgo.io/contrib/entgql"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
)
Expand All @@ -27,43 +28,73 @@ func (Metrics) Edges() []ent.Edge {

// The action summmary with details about actions executed.
edge.To("action_summary", ActionSummary.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Details about memory usage and garbage collections.
edge.To("memory_metrics", MemoryMetrics.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Target metrics.
edge.To("target_metrics", TargetMetrics.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Package metrics.
edge.To("package_metrics", PackageMetrics.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Timing metrics.
edge.To("timing_metrics", TimingMetrics.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Cumulative metrics.
edge.To("cumulative_metrics", CumulativeMetrics.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Artifact metrics.
edge.To("artifact_metrics", ArtifactMetrics.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Network metrics if available.
edge.To("network_metrics", NetworkMetrics.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Dynamic execution metrics if available.
edge.To("dynamic_execution_metrics", DynamicExecutionMetrics.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),

// Build graph metrics.
edge.To("build_graph_metrics", BuildGraphMetrics.Type).
Unique(),
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
),
}
}

Expand Down
Loading