Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for schedules #479

Merged
merged 5 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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