Skip to content

Commit

Permalink
Merge branch 'main' into hackathon/github_app
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper committed Jun 21, 2024
2 parents 9b9f1e2 + 35a80cf commit 9d91cee
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 30 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: install go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
Expand All @@ -47,7 +47,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8
uses: github/codeql-action/init@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -58,7 +58,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8
uses: github/codeql-action/autobuild@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -72,4 +72,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@2e230e8fe0ad3a14a340ad0815ddb96d599d2aff # v3.25.8
uses: github/codeql-action/analyze@23acc5c183826b7a8a97bce3cecc52db901f8251 # v3.25.10
4 changes: 2 additions & 2 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: clone
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: install go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
Expand All @@ -36,7 +36,7 @@ jobs:

steps:
- name: clone
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: install go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: clone
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: install go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

steps:
- name: clone
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: install go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
Expand All @@ -29,7 +29,7 @@ jobs:
go test -race -covermode=atomic -coverprofile=coverage.out ./...
- name: coverage
uses: codecov/codecov-action@125fc84a9a348dbcf27191600683ec096ec9021c # v4.4.1
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: coverage.out
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

steps:
- name: clone
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: install go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
Expand Down
5 changes: 4 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
# outputs it results from the linters it executes.
output:
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
format: colored-line-number
formats:
- format: json
path: stderr
- format: colored-line-number

# print lines of code with issue, default is true
print-issued-lines: true
Expand Down
27 changes: 8 additions & 19 deletions pipeline/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,32 +152,21 @@ func (c *Container) Execute(r *RuleData) (bool, error) {
if c == nil {
return false, nil
}
// skip evaluating path in ruleset
//
// the compiler is the component responsible for
// choosing whether a container will run based
// off the files changed for a build

// Skip evaluating path, comment, and label in ruleset,
// as the worker lacks necessary rule data.
//
// the worker doesn't have any record of
// what files changed for a build so we
// should "skip" evaluating what the
// user provided for the path element
// The compiler determines whether a container will run based on
// these rules.
c.Ruleset.If.Path = []string{}
c.Ruleset.Unless.Path = []string{}

// skip evaluating comment in ruleset
//
// the compiler is the component responsible for
// choosing whether a container will run based
// off the PR comment matching the pipeline comment
//
// the worker doesn't have any record of
// the PR comment so we
// should "skip" evaluating what the
// user provided for the PR comment
c.Ruleset.If.Comment = []string{}
c.Ruleset.Unless.Comment = []string{}

c.Ruleset.If.Label = []string{}
c.Ruleset.Unless.Label = []string{}

// check if the build is in a running state
if strings.EqualFold(r.Status, constants.StatusRunning) {
// treat the ruleset status as success
Expand Down
86 changes: 86 additions & 0 deletions pipeline/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,92 @@ func TestPipeline_Container_Execute(t *testing.T) {
},
want: true,
},
{ // pull request labeled success container with build success
container: &Container{
Name: "pull-request-labeled",
Image: "alpine:latest",
Commands: []string{"echo \"Hey Vela\""},
Ruleset: Ruleset{
If: Rules{
Branch: []string{"fix/1234"},
Event: []string{constants.EventPull + constants.ActionLabeled},
Label: []string{"enhancement", "documentation"},
},
Operator: "and",
},
},
ruleData: &RuleData{
Branch: "fix/1234",
Event: "pull_request:labeled",
Repo: "foo/bar",
Status: "success",
},
want: true,
},
{ // pull request unlabeled success container with build success
container: &Container{
Name: "pull-request-unlabeled",
Image: "alpine:latest",
Commands: []string{"echo \"Hey Vela\""},
Ruleset: Ruleset{
If: Rules{
Event: []string{constants.EventPull + constants.ActionUnlabeled},
Label: []string{"enhancement"},
},
Operator: "and",
},
},
ruleData: &RuleData{
Branch: "fix/1234",
Event: "pull_request:unlabeled",
Repo: "foo/bar",
Status: "success",
},
want: true,
},
{ // pull request labeled unless ruleset, success container with build success
container: &Container{
Name: "pull-request-labeled",
Image: "alpine:latest",
Commands: []string{"echo \"Hey Vela\""},
Ruleset: Ruleset{
Unless: Rules{
Branch: []string{"fix/1234"},
Event: []string{constants.EventPull + constants.ActionLabeled},
Label: []string{"enhancement", "documentation"},
},
Operator: "and",
},
},
ruleData: &RuleData{
Branch: "fix/1234",
Event: "pull_request:labeled",
Repo: "foo/bar",
Status: "success",
},
want: true,
},
{ // pull request unlabeled unless ruleset, success container with build success
container: &Container{
Name: "pull-request-unlabeled",
Image: "alpine:latest",
Commands: []string{"echo \"Hey Vela\""},
Ruleset: Ruleset{
Unless: Rules{
Event: []string{constants.EventPull + constants.ActionUnlabeled},
Label: []string{"enhancement"},
},
Operator: "and",
},
},
ruleData: &RuleData{
Branch: "fix/1234",
Event: "pull_request:unlabeled",
Repo: "foo/bar",
Status: "success",
},
want: true,
},
}

// run tests
Expand Down

0 comments on commit 9d91cee

Please sign in to comment.