buildSkipAuthorAssociationsCondition returns a condition that evaluates to true when the workflow should continue, and false when the run should be skipped based on: on.skip-author-associations. containing the event-specific author_association field.
(skipAuthorAssociations map[string][]string)
| 227 | // workflow should continue, and false when the run should be skipped based on: |
| 228 | // on.skip-author-associations.<event> containing the event-specific author_association field. |
| 229 | func buildSkipAuthorAssociationsCondition(skipAuthorAssociations map[string][]string) ConditionNode { |
| 230 | var eventNames []string |
| 231 | for eventName, associations := range skipAuthorAssociations { |
| 232 | if len(associations) > 0 { |
| 233 | eventNames = append(eventNames, eventName) |
| 234 | } |
| 235 | } |
| 236 | sort.Strings(eventNames) |
| 237 | |
| 238 | var skipTerms []ConditionNode |
| 239 | for _, eventName := range eventNames { |
| 240 | associations := skipAuthorAssociations[eventName] |
| 241 | if len(associations) == 0 { |
| 242 | continue |
| 243 | } |
| 244 | |
| 245 | associationJSON, err := json.Marshal(associations) |
| 246 | if err != nil { |
| 247 | continue |
| 248 | } |
| 249 | |
| 250 | isConfiguredEvent := BuildEquals( |
| 251 | BuildPropertyAccess("github.event_name"), |
| 252 | BuildStringLiteral(eventName), |
| 253 | ) |
| 254 | associationIsSkipped := BuildFunctionCall( |
| 255 | "contains", |
| 256 | BuildFunctionCall("fromJSON", BuildStringLiteral(string(associationJSON))), |
| 257 | buildAuthorAssociationNodeForEvent(eventName), |
| 258 | ) |
| 259 | skipTerms = append(skipTerms, BuildAnd(isConfiguredEvent, associationIsSkipped)) |
| 260 | } |
| 261 | |
| 262 | if len(skipTerms) == 0 { |
| 263 | return BuildBooleanLiteral(true) |
| 264 | } |
| 265 | |
| 266 | return &NotNode{Child: BuildDisjunction(false, skipTerms...)} |
| 267 | } |
| 268 | |
| 269 | // buildDetectionSuccessCondition builds the condition to check if detection passed. |
| 270 | // Detection runs in a separate detection job that only succeeds (result == 'success') when |
no test coverage detected