mirror of
https://github.com/nektos/act.git
synced 2026-04-26 09:25:54 +03:00
[PR #1709] [CLOSED] feature: reference workflowpattern package to add workflow filtering #2085
Labels
No labels
area/action
area/cli
area/docs
area/image
area/runner
area/workflow
backlog
confirmed/not-planned
kind/bug
kind/discussion
kind/external
kind/feature-request
kind/question
meta/duplicate
meta/invalid
meta/need-more-info
meta/resolved
meta/wontfix
meta/workaround
needs-work
pull-request
review/not-planned
size/M
size/XL
size/XXL
stale
stale-exempt
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/act#2085
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/nektos/act/pull/1709
Author: @ae-ou
Created: 4/2/2023
Status: ❌ Closed
Base:
master← Head:feature-reference-workflow-pattern-package📝 Commits (7)
9d94a76Get filter patterns nested within the the On attribute of the workflow.2a582fdAdd a ShouldFilterWorkflow() function. Testing is still needed for this function, and we need to determine a way to pass the payload down to the function in order to check it using filters.@5f88d0aSwitch to FilterStructe7702b9Handle the '*-ignore' filter paths, and return a log.Fatal() if a filter and the *ignore variant (e.g. 'paths' and 'paths-ignore') are both set. Define the function signature in workflow_pattern so that I can easily reference the signature for Skip()/Filter(). Add TODOs.9d7a369Merge branch 'master' into feature-reference-workflow-pattern-package772062eMerge branch 'nektos:master' into feature-reference-workflow-pattern-package64bef7aMerge branch 'nektos:master' into feature-reference-workflow-pattern-package📊 Changes
4 files changed (+546 additions, -0 deletions)
View changed files
📝
pkg/model/planner.go(+7 -0)📝
pkg/model/workflow.go(+139 -0)📝
pkg/model/workflow_test.go(+397 -0)📝
pkg/workflowpattern/workflow_pattern.go(+3 -0)📄 Description
Description
This is a followup to https://github.com/nektos/act/pull/1618 by @ChristopherHX - which added in a package to accommodate filtering. This PR works to invoke the filtering when the
actcommand is executed.This PR is in a draft state - there are a number of questions that I'm not in a position to answer (which are outlined in the "Questions" section below), and I can't complete this PR without these questions being answered. Feedback/answers to my questions are much appreciated.
Changes Thusfar
FindFilterPatterns()function to theWorkflowstruct.pull_requestorpush), it then traverses the nodes inWorkFlow.RawOnand builds up a struct (FilterPatterns) containing slices of filters.ShouldFilterWorkflow()function to theWorkflowstruct.FindFilterPatterns()to get the filters patterns (relating to the specified event) on the workflow, it then compiles these patterns into Regex, and compares the provided event against the patterns (to determine whether the workflow should be added to the plan).workflowpattern.FilterInputsFunc)workflowpattern.Skip()andworkflowpattern.Filter()implement.Notes
RawOnto a struct, so that we could directly unmarshal any filters found in the workflow into this struct.RawOn.TODOcomments in my code - some of these are the basis for questions below.Questions
eventto theShouldFilterWorkflow()function? Since I will probably callShouldFilterWorkflow()within the functions onmodel.workflowPlannerstruct, should I store a copy of theeventon this struct?runner.runnerImpl.configure()function builds up aneventJsonattribute, but none of these functions/structs are exported.cmd.newRunCommand()), we haven't calledr, err := runner.New(config), so this structure wouldn't be available to theplanner- even if the attribute was exported.model.GithubContextstruct appears to relate to the Github event, but there's no function to unmarshal a JSON file into the struct.workflowPlanner.PlanJob()? Filters are a workflow-level attribute (and a Job exists as a component of a workflow file) but some users may wish to invoke a job without the context of its wider workflow.FindFilterPatterns()andShouldFilterWorkflow()) to return errors instead of callinglog.Fatal()?log.Fatal()in line with the other functions in themodelpackage, as I saw very fewerrorreturn values on function signatures.log.Fatal()-eflag) that don't satisfy the conditions on their workflow file, the addition of filtering may break the workflows for those users. Is there a preferred way to communicate this change to those users?🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.