Skip to content

Commit

Permalink
feat: add support for schedules (#479)
Browse files Browse the repository at this point in the history
* feat: add support for schedules

* chore: update go dependencies

* chore: update go deps
  • Loading branch information
jbrockopp committed May 26, 2023
1 parent 1ff33a7 commit 3c33452
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 6 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ require (
github.com/docker/docker v20.10.24+incompatible
github.com/docker/go-units v0.5.0
github.com/gin-gonic/gin v1.9.0
github.com/go-vela/sdk-go v0.19.2
github.com/go-vela/server v0.19.3-0.20230510141710-f99a894333d4
github.com/go-vela/sdk-go v0.19.3-0.20230525152744-4c6fc715258c
github.com/go-vela/server v0.19.3-0.20230523191014-5a9a92d279e0
github.com/go-vela/types v0.19.3-0.20230523200921-35a0d5fc088c
github.com/golang-jwt/jwt/v5 v5.0.0
github.com/google/go-cmp v0.5.9
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91
github.com/go-playground/validator/v10 v10.11.2 h1:q3SHpufmypg+erIExEKUmsgmhDTyhcJ38oeKGACXohU=
github.com/go-playground/validator/v10 v10.11.2/go.mod h1:NieE624vt4SCTJtD87arVLvdmjPAeV8BQlHtMnw9D7s=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I=
github.com/go-vela/sdk-go v0.19.2 h1:bEMnEnEZxI27ZCjFx5fNRFc0EYHr2NsR2jb//0J5SJk=
github.com/go-vela/sdk-go v0.19.2/go.mod h1:p0WwKyBLslyhPjSQnA78SVZpLDkOL/P030BtzdRDjtE=
github.com/go-vela/server v0.19.3-0.20230510141710-f99a894333d4 h1:hAj76WkNt+CZfkionu86xlpM3YpupZkX1OWHzWbeEpA=
github.com/go-vela/server v0.19.3-0.20230510141710-f99a894333d4/go.mod h1:N6ej04/c6kc/0sJK15jCLr3Au9L9Zs9TjcMtkJoyJx8=
github.com/go-vela/sdk-go v0.19.3-0.20230525152744-4c6fc715258c h1:2GV5t+AOyMYIoyFvzOFCT1dt08KROzaUozK1oW6Q4p0=
github.com/go-vela/sdk-go v0.19.3-0.20230525152744-4c6fc715258c/go.mod h1:0XTE3DHG5B872POEhKJ3kZzL8ZvR1jAJSeakeJgjfCM=
github.com/go-vela/server v0.19.3-0.20230523191014-5a9a92d279e0 h1:jyNJ1YdYj0YBRcwzyab8yZWBjGt543ATp/eftgPZBoA=
github.com/go-vela/server v0.19.3-0.20230523191014-5a9a92d279e0/go.mod h1:sjfqYOyuXG7uqgeQF03URz7GGNjVE+JNIhkGK00eT9o=
github.com/go-vela/types v0.19.3-0.20230523200921-35a0d5fc088c h1:eAApIK5e5MxFF8RzZAFsvTSdwq/AzdUrdhJHOGQ0ILc=
github.com/go-vela/types v0.19.3-0.20230523200921-35a0d5fc088c/go.mod h1:0lsuPfGyVyTWJSi2h3NS6uaEW6DgnFvIzaZu1sXYKrs=
github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA=
Expand Down
6 changes: 6 additions & 0 deletions internal/step/skip.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ func Skip(c *pipeline.Container, b *library.Build, r *library.Repo) bool {
ruledata.Target = b.GetDeploy()
}

// check if the build event is schedule
if strings.EqualFold(b.GetEvent(), constants.EventSchedule) {
// add schedule target information to ruledata
ruledata.Target = b.GetDeploy()
}

// return the inverse of container execute
//
// https://pkg.go.dev/github.com/go-vela/types/pipeline#Container.Execute
Expand Down
35 changes: 35 additions & 0 deletions internal/step/skip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,34 @@ func TestStep_Skip(t *testing.T) {
Distribution: vela.String("linux"),
}

_schedule := &library.Build{
ID: vela.Int64(1),
Number: vela.Int(1),
Parent: vela.Int(1),
Event: vela.String("schedule"),
EventAction: vela.String(""),
Status: vela.String("success"),
Error: vela.String(""),
Enqueued: vela.Int64(1563474077),
Created: vela.Int64(1563474076),
Started: vela.Int64(1563474077),
Finished: vela.Int64(0),
Deploy: vela.String(""),
Clone: vela.String("https://github.com/github/octocat.git"),
Source: vela.String("https://github.com/github/octocat/abcdefghi123456789"),
Title: vela.String("push received from https://github.com/github/octocat"),
Message: vela.String("First commit..."),
Commit: vela.String("48afb5bdc41ad69bf22588491333f7cf71135163"),
Sender: vela.String("OctoKitty"),
Author: vela.String("OctoKitty"),
Branch: vela.String("master"),
Ref: vela.String("refs/heads/master"),
BaseRef: vela.String(""),
Host: vela.String("example.company.com"),
Runtime: vela.String("docker"),
Distribution: vela.String("linux"),
}

_tag := &library.Build{
ID: vela.Int64(1),
Number: vela.Int(1),
Expand Down Expand Up @@ -218,6 +246,13 @@ func TestStep_Skip(t *testing.T) {
repo: _repo,
want: false,
},
{
name: "schedule",
build: _schedule,
container: _container,
repo: _repo,
want: false,
},
{
name: "tag",
build: _tag,
Expand Down

0 comments on commit 3c33452

Please sign in to comment.