refactor(workflow): unexport the matrix configuration limit error
- commit
- 87e67008ceaf535d628b223f4e88b17431c8a774
- author
- brice · · 2026-10-12 19:23 UTC
- committer
- brice · · 2026-10-18 14:59 UTC
- parent
- 98ea59f
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
4 files · +10 -10
M workflow/PORTING.md +1 -1
| @@ -78,7 +78,7 @@ code. | |||
| 78 | 78 | message of the commit the tag points at. Only the head commit counts. | |
| 79 | 79 | - [ ] **`ExpandMatrix`** (recorded: the unknown exclude key, once per | |
| 80 | 80 | offending entry, and the 256 limit message, see | |
| 81 | - | `ConfigurationLimitError`; matrix-edge-values, matrix-over-256): order of the product (first key slowest), include | |
| 81 | + | `configurationLimitError`; matrix-edge-values, matrix-over-256): order of the product (first key slowest), include | |
| 82 | 82 | semantics (added to every matching combination, never overwriting | |
| 83 | 83 | original values, later includes overwrite earlier added values, a | |
| 84 | 84 | non-matching include is a new combination, match by vector keys only), | |
| @@ -78,7 +78,7 @@ code. | |||||
| 78 | message of the commit the tag points at. Only the head commit counts. | 78 | message of the commit the tag points at. Only the head commit counts. | ||
| 79 | - [ ] **`ExpandMatrix`** (recorded: the unknown exclude key, once per | 79 | - [ ] **`ExpandMatrix`** (recorded: the unknown exclude key, once per | ||
| 80 | offending entry, and the 256 limit message, see | 80 | offending entry, and the 256 limit message, see | ||
| 81 | - | `ConfigurationLimitError`; matrix-edge-values, matrix-over-256): order of the product (first key slowest), include | 81 | + | `configurationLimitError`; matrix-edge-values, matrix-over-256): order of the product (first key slowest), include |
| 82 | semantics (added to every matching combination, never overwriting | 82 | semantics (added to every matching combination, never overwriting | ||
| 83 | original values, later includes overwrite earlier added values, a | 83 | original values, later includes overwrite earlier added values, a | ||
| 84 | non-matching include is a new combination, match by vector keys only), | 84 | non-matching include is a new combination, match by vector keys only), | ||
M workflow/matrix.go +5 -5
| @@ -62,7 +62,7 @@ func (c MatrixCombo) DisplayName(base string) string { | |||
| 62 | 62 | // mentions no vector key matches all), without overwriting the original | |
| 63 | 63 | // values; an entry that matches no combination becomes a combination of | |
| 64 | 64 | // its own; | |
| 65 | - | // - more than 256 jobs is a [*ConfigurationLimitError]. A strategy without a | |
| 65 | + | // - more than 256 jobs is a a limit error. A strategy without a | |
| 66 | 66 | // matrix gives a single combination. | |
| 67 | 67 | // | |
| 68 | 68 | // The work is bounded: the product of the vectors may not exceed | |
| @@ -158,19 +158,19 @@ func (m message) Error() string { return string(m) } | |||
| 158 | 158 | // the exclusions; this limit keeps the work bounded, see [MaxMatrixProduct]. | |
| 159 | 159 | var errProductTooBig = fmt.Errorf("matrix too large: the cross product of the vectors exceeds %d combinations", MaxMatrixProduct) | |
| 160 | 160 | ||
| 161 | - | // ConfigurationLimitError is returned when a matrix produces more than | |
| 161 | + | // configurationLimitError is returned when a matrix produces more than | |
| 162 | 162 | // [MaxMatrixJobs] configurations. Its text is GitHub's (recorded by | |
| 163 | 163 | // matrix-over-256): "Strategy for job 'too-many' produced 272 configurations | |
| 164 | 164 | // which exceeds the maximum of 256 configurations". Job is empty when the | |
| 165 | 165 | // matrix was expanded without a job, see [Job.EvaluateStrategy]. | |
| 166 | - | type ConfigurationLimitError struct { | |
| 166 | + | type configurationLimitError struct { | |
| 167 | 167 | // Job is the id of the job. | |
| 168 | 168 | Job string | |
| 169 | 169 | // Count is the number of configurations the matrix produces. | |
| 170 | 170 | Count int | |
| 171 | 171 | } | |
| 172 | 172 | ||
| 173 | - | func (e *ConfigurationLimitError) Error() string { | |
| 173 | + | func (e *configurationLimitError) Error() string { | |
| 174 | 174 | subject := "Strategy" | |
| 175 | 175 | if e.Job != "" { | |
| 176 | 176 | subject = fmt.Sprintf("Strategy for job '%s'", e.Job) | |
| @@ -319,7 +319,7 @@ func expand(ctx context.Context, vecs []vector, includes, excludes []*expr.Dicti | |||
| 319 | 319 | combos = append(combos, b.combo()) | |
| 320 | 320 | } | |
| 321 | 321 | if total > MaxMatrixJobs { | |
| 322 | - | return nil, false, &ConfigurationLimitError{Count: total} | |
| 322 | + | return nil, false, &configurationLimitError{Count: total} | |
| 323 | 323 | } | |
| 324 | 324 | if len(combos) == 0 { | |
| 325 | 325 | if len(vecs) == 0 && len(includes) == 0 && len(excludes) == 0 { | |
| @@ -62,7 +62,7 @@ func (c MatrixCombo) DisplayName(base string) string { | |||||
| 62 | // mentions no vector key matches all), without overwriting the original | 62 | // mentions no vector key matches all), without overwriting the original | ||
| 63 | // values; an entry that matches no combination becomes a combination of | 63 | // values; an entry that matches no combination becomes a combination of | ||
| 64 | // its own; | 64 | // its own; | ||
| 65 | - | // - more than 256 jobs is a [*ConfigurationLimitError]. A strategy without a | 65 | + | // - more than 256 jobs is a a limit error. A strategy without a |
| 66 | // matrix gives a single combination. | 66 | // matrix gives a single combination. | ||
| 67 | // | 67 | // | ||
| 68 | // The work is bounded: the product of the vectors may not exceed | 68 | // The work is bounded: the product of the vectors may not exceed | ||
| @@ -158,19 +158,19 @@ func (m message) Error() string { return string(m) } | |||||
| 158 | // the exclusions; this limit keeps the work bounded, see [MaxMatrixProduct]. | 158 | // the exclusions; this limit keeps the work bounded, see [MaxMatrixProduct]. | ||
| 159 | var errProductTooBig = fmt.Errorf("matrix too large: the cross product of the vectors exceeds %d combinations", MaxMatrixProduct) | 159 | var errProductTooBig = fmt.Errorf("matrix too large: the cross product of the vectors exceeds %d combinations", MaxMatrixProduct) | ||
| 160 | 160 | ||||
| 161 | - | // ConfigurationLimitError is returned when a matrix produces more than | 161 | + | // configurationLimitError is returned when a matrix produces more than |
| 162 | // [MaxMatrixJobs] configurations. Its text is GitHub's (recorded by | 162 | // [MaxMatrixJobs] configurations. Its text is GitHub's (recorded by | ||
| 163 | // matrix-over-256): "Strategy for job 'too-many' produced 272 configurations | 163 | // matrix-over-256): "Strategy for job 'too-many' produced 272 configurations | ||
| 164 | // which exceeds the maximum of 256 configurations". Job is empty when the | 164 | // which exceeds the maximum of 256 configurations". Job is empty when the | ||
| 165 | // matrix was expanded without a job, see [Job.EvaluateStrategy]. | 165 | // matrix was expanded without a job, see [Job.EvaluateStrategy]. | ||
| 166 | - | type ConfigurationLimitError struct { | 166 | + | type configurationLimitError struct { |
| 167 | // Job is the id of the job. | 167 | // Job is the id of the job. | ||
| 168 | Job string | 168 | Job string | ||
| 169 | // Count is the number of configurations the matrix produces. | 169 | // Count is the number of configurations the matrix produces. | ||
| 170 | Count int | 170 | Count int | ||
| 171 | } | 171 | } | ||
| 172 | 172 | ||||
| 173 | - | func (e *ConfigurationLimitError) Error() string { | 173 | + | func (e *configurationLimitError) Error() string { |
| 174 | subject := "Strategy" | 174 | subject := "Strategy" | ||
| 175 | if e.Job != "" { | 175 | if e.Job != "" { | ||
| 176 | subject = fmt.Sprintf("Strategy for job '%s'", e.Job) | 176 | subject = fmt.Sprintf("Strategy for job '%s'", e.Job) | ||
| @@ -319,7 +319,7 @@ func expand(ctx context.Context, vecs []vector, includes, excludes []*expr.Dicti | |||||
| 319 | combos = append(combos, b.combo()) | 319 | combos = append(combos, b.combo()) | ||
| 320 | } | 320 | } | ||
| 321 | if total > MaxMatrixJobs { | 321 | if total > MaxMatrixJobs { | ||
| 322 | - | return nil, false, &ConfigurationLimitError{Count: total} | 322 | + | return nil, false, &configurationLimitError{Count: total} |
| 323 | } | 323 | } | ||
| 324 | if len(combos) == 0 { | 324 | if len(combos) == 0 { | ||
| 325 | if len(vecs) == 0 && len(includes) == 0 && len(excludes) == 0 { | 325 | if len(vecs) == 0 && len(includes) == 0 && len(excludes) == 0 { | ||
M workflow/matrix_test.go +2 -2
| @@ -321,7 +321,7 @@ func TestMatrixProductCap(t *testing.T) { | |||
| 321 | 321 | } | |
| 322 | 322 | // 2^16 is allowed by the cap (and fails on the job limit), 2^16+1 is refused outright. | |
| 323 | 323 | _, err := ExpandMatrix(ctxbg, jsonValue(t, `{"matrix": {"a": `+vec(MaxMatrixProduct/2)+`, "b": `+vec(2)+`, "c": `+vec(1)+`}}`)) | |
| 324 | - | var limit *ConfigurationLimitError | |
| 324 | + | var limit *configurationLimitError | |
| 325 | 325 | if !errors.As(err, &limit) || limit.Count != MaxMatrixProduct { | |
| 326 | 326 | t.Errorf("err = %v", err) | |
| 327 | 327 | } | |
| @@ -425,7 +425,7 @@ jobs: | |||
| 425 | 425 | if err == nil || err.Error() != want { | |
| 426 | 426 | t.Errorf("err = %v, want %q", err, want) | |
| 427 | 427 | } | |
| 428 | - | var limit *ConfigurationLimitError | |
| 428 | + | var limit *configurationLimitError | |
| 429 | 429 | if !errors.As(err, &limit) || limit.Job != "too-many" || limit.Count != 272 { | |
| 430 | 430 | t.Errorf("err = %#v", err) | |
| 431 | 431 | } | |
| @@ -321,7 +321,7 @@ func TestMatrixProductCap(t *testing.T) { | |||||
| 321 | } | 321 | } | ||
| 322 | // 2^16 is allowed by the cap (and fails on the job limit), 2^16+1 is refused outright. | 322 | // 2^16 is allowed by the cap (and fails on the job limit), 2^16+1 is refused outright. | ||
| 323 | _, err := ExpandMatrix(ctxbg, jsonValue(t, `{"matrix": {"a": `+vec(MaxMatrixProduct/2)+`, "b": `+vec(2)+`, "c": `+vec(1)+`}}`)) | 323 | _, err := ExpandMatrix(ctxbg, jsonValue(t, `{"matrix": {"a": `+vec(MaxMatrixProduct/2)+`, "b": `+vec(2)+`, "c": `+vec(1)+`}}`)) | ||
| 324 | - | var limit *ConfigurationLimitError | 324 | + | var limit *configurationLimitError |
| 325 | if !errors.As(err, &limit) || limit.Count != MaxMatrixProduct { | 325 | if !errors.As(err, &limit) || limit.Count != MaxMatrixProduct { | ||
| 326 | t.Errorf("err = %v", err) | 326 | t.Errorf("err = %v", err) | ||
| 327 | } | 327 | } | ||
| @@ -425,7 +425,7 @@ jobs: | |||||
| 425 | if err == nil || err.Error() != want { | 425 | if err == nil || err.Error() != want { | ||
| 426 | t.Errorf("err = %v, want %q", err, want) | 426 | t.Errorf("err = %v, want %q", err, want) | ||
| 427 | } | 427 | } | ||
| 428 | - | var limit *ConfigurationLimitError | 428 | + | var limit *configurationLimitError |
| 429 | if !errors.As(err, &limit) || limit.Job != "too-many" || limit.Count != 272 { | 429 | if !errors.As(err, &limit) || limit.Job != "too-many" || limit.Count != 272 { | ||
| 430 | t.Errorf("err = %#v", err) | 430 | t.Errorf("err = %#v", err) | ||
| 431 | } | 431 | } | ||
M workflow/strategy.go +2 -2
| @@ -135,9 +135,9 @@ func (j *Job) EvaluateStrategy(ctx context.Context, env template.Env) (*Strategy | |||
| 135 | 135 | return nil, err | |
| 136 | 136 | } | |
| 137 | 137 | st, err := ParseStrategy(ctx, v) | |
| 138 | - | var limit *ConfigurationLimitError | |
| 138 | + | var limit *configurationLimitError | |
| 139 | 139 | if errors.As(err, &limit) { | |
| 140 | - | return nil, &ConfigurationLimitError{Job: j.ID, Count: limit.Count} | |
| 140 | + | return nil, &configurationLimitError{Job: j.ID, Count: limit.Count} | |
| 141 | 141 | } | |
| 142 | 142 | return st, err | |
| 143 | 143 | } | |
| @@ -135,9 +135,9 @@ func (j *Job) EvaluateStrategy(ctx context.Context, env template.Env) (*Strategy | |||||
| 135 | return nil, err | 135 | return nil, err | ||
| 136 | } | 136 | } | ||
| 137 | st, err := ParseStrategy(ctx, v) | 137 | st, err := ParseStrategy(ctx, v) | ||
| 138 | - | var limit *ConfigurationLimitError | 138 | + | var limit *configurationLimitError |
| 139 | if errors.As(err, &limit) { | 139 | if errors.As(err, &limit) { | ||
| 140 | - | return nil, &ConfigurationLimitError{Job: j.ID, Count: limit.Count} | 140 | + | return nil, &configurationLimitError{Job: j.ID, Count: limit.Count} |
| 141 | } | 141 | } | ||
| 142 | return st, err | 142 | return st, err | ||
| 143 | } | 143 | } | ||