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

refactor: rename release action #5825

Merged
merged 3 commits into from
May 25, 2021
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
2 changes: 1 addition & 1 deletion docs/content/docs/concepts/files/application-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ vcs_ssh_key: proj-ssh-key
vcs_pgp_key: proj-pgp-key
```

Now with this setup you will be able to use the actions [CheckoutApplication]({{< relref "../../actions/builtin-checkoutapplication/" >}}) and [Release]({{< relref "../../actions/builtin-release/" >}}) in your pipelines.
Now with this setup you will be able to use the actions [CheckoutApplication]({{< relref "../../actions/builtin-checkoutapplication/" >}}) and [Release]({{< relref "../../actions/builtin-releasevcs/" >}}) in your pipelines.

## Deployment

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Tag is created on GitHub.

## 9 - Release Action

[Release action]({{< relref "/docs/actions/builtin-release.md" >}}) action is implemented for GitHub only.
[Release action]({{< relref "/docs/actions/builtin-releasevcs.md" >}}) action is implemented for GitHub only.
You can use it to create a release from a tag and push some artifacts on it.

{{%expand "view screenshots..." %}}
Expand Down
8 changes: 8 additions & 0 deletions engine/sql/api/223_rename_release_action.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- +migrate Up
UPDATE action SET name = 'ReleaseVCS' WHERE name = 'Release' and type = 'Builtin'

-- +migrate Down
UPDATE action SET name = 'Release' WHERE name = 'ReleaseVCS' and type = 'Builtin'



2 changes: 1 addition & 1 deletion engine/worker/internal/action/builtin_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/ovh/cds/sdk"
)

func RunRelease(ctx context.Context, wk workerruntime.Runtime, a sdk.Action, secrets []sdk.Variable) (sdk.Result, error) {
func RunReleaseVCS(ctx context.Context, wk workerruntime.Runtime, a sdk.Action, secrets []sdk.Variable) (sdk.Result, error) {
var res sdk.Result
res.Status = sdk.StatusFail
jobID, err := workerruntime.JobID(ctx)
Expand Down
14 changes: 7 additions & 7 deletions engine/worker/internal/action/builtin_release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestRunRelease(t *testing.T) {
Value: "999",
},
}...)
res, err := RunRelease(ctx, wk,
res, err := RunReleaseVCS(ctx, wk,
sdk.Action{
Parameters: []sdk.Parameter{
{
Expand Down Expand Up @@ -110,7 +110,7 @@ func TestRunReleaseMissingTag(t *testing.T) {
Value: "999",
},
}...)
res, err := RunRelease(ctx, wk,
res, err := RunReleaseVCS(ctx, wk,
sdk.Action{
Parameters: []sdk.Parameter{
{
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestRunReleaseMissingTitle(t *testing.T) {
Value: "999",
},
}...)
res, err := RunRelease(ctx, wk,
res, err := RunReleaseVCS(ctx, wk,
sdk.Action{
Parameters: []sdk.Parameter{
{
Expand Down Expand Up @@ -190,7 +190,7 @@ func TestRunReleaseMissingReleaseNote(t *testing.T) {
Value: "999",
},
}...)
res, err := RunRelease(ctx, wk,
res, err := RunReleaseVCS(ctx, wk,
sdk.Action{
Parameters: []sdk.Parameter{
{
Expand Down Expand Up @@ -226,7 +226,7 @@ func TestRunReleaseMissingProjectKey(t *testing.T) {
Value: "999",
},
}...)
res, err := RunRelease(ctx, wk,
res, err := RunReleaseVCS(ctx, wk,
sdk.Action{
Parameters: []sdk.Parameter{
{
Expand Down Expand Up @@ -266,7 +266,7 @@ func TestRunReleaseMissingWorkflowName(t *testing.T) {
Value: "999",
},
}...)
res, err := RunRelease(ctx, wk,
res, err := RunReleaseVCS(ctx, wk,
sdk.Action{
Parameters: []sdk.Parameter{
{
Expand Down Expand Up @@ -306,7 +306,7 @@ func TestRunReleaseMissingWorkflowRunNumber(t *testing.T) {
Value: "workflow Name",
},
}...)
res, err := RunRelease(ctx, wk,
res, err := RunReleaseVCS(ctx, wk,
sdk.Action{
Parameters: []sdk.Parameter{
{
Expand Down
2 changes: 1 addition & 1 deletion engine/worker/internal/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func init() {
mapBuiltinActions[sdk.JUnitAction] = action.RunParseJunitTestResultAction
mapBuiltinActions[sdk.GitCloneAction] = action.RunGitClone
mapBuiltinActions[sdk.GitTagAction] = action.RunGitTag
mapBuiltinActions[sdk.ReleaseAction] = action.RunRelease
mapBuiltinActions[sdk.ReleaseVCSAction] = action.RunReleaseVCS
mapBuiltinActions[sdk.CheckoutApplicationAction] = action.RunCheckoutApplication
mapBuiltinActions[sdk.DeployApplicationAction] = action.RunDeployApplication
mapBuiltinActions[sdk.CoverageAction] = action.RunParseCoverageResultAction
Expand Down
2 changes: 1 addition & 1 deletion sdk/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const (
CoverageAction = "Coverage"
GitCloneAction = "GitClone"
GitTagAction = "GitTag"
ReleaseAction = "Release"
ReleaseVCSAction = "ReleaseVCS"
CheckoutApplicationAction = "CheckoutApplication"
DeployApplicationAction = "DeployApplication"
InstallKeyAction = "InstallKey"
Expand Down
2 changes: 1 addition & 1 deletion sdk/action/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var List = []Manifest{
GitTag,
InstallKey,
JUnit,
Release,
ReleaseVCS,
Script,
ServeStaticFiles,
}
Expand Down
8 changes: 4 additions & 4 deletions sdk/action/release.go → sdk/action/release-vcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"github.com/ovh/cds/sdk/exportentities"
)

// Release action definition.
var Release = Manifest{
// ReleaseVCS action definition.
var ReleaseVCS = Manifest{
Action: sdk.Action{
Name: sdk.ReleaseAction,
Name: sdk.ReleaseVCSAction,
Description: "This action creates a release on the git repository linked to the application, if repository manager implements it.",
Parameters: []sdk.Parameter{
{
Expand Down Expand Up @@ -68,7 +68,7 @@ var Release = Manifest{
},
},
{
Release: &exportentities.StepRelease{
ReleaseVCS: &exportentities.StepReleaseVCS{
Artifacts: "{{.cds.workspace}}/myFile",
Title: "{{.cds.build.tag}}",
ReleaseNote: "My release {{.cds.build.tag}}",
Expand Down
36 changes: 18 additions & 18 deletions sdk/exportentities/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,23 @@ func newStep(act sdk.Action) Step {
if prefix != nil {
s.GitTag.Prefix = prefix.Value
}
case sdk.ReleaseAction:
s.Release = &StepRelease{}
case sdk.ReleaseVCSAction:
s.ReleaseVCS = &StepReleaseVCS{}
artifacts := sdk.ParameterFind(act.Parameters, "artifacts")
if artifacts != nil {
s.Release.Artifacts = artifacts.Value
s.ReleaseVCS.Artifacts = artifacts.Value
}
releaseNote := sdk.ParameterFind(act.Parameters, "releaseNote")
if releaseNote != nil {
s.Release.ReleaseNote = releaseNote.Value
s.ReleaseVCS.ReleaseNote = releaseNote.Value
}
tag := sdk.ParameterFind(act.Parameters, "tag")
if tag != nil {
s.Release.Tag = tag.Value
s.ReleaseVCS.Tag = tag.Value
}
title := sdk.ParameterFind(act.Parameters, "title")
if title != nil {
s.Release.Title = title.Value
s.ReleaseVCS.Title = title.Value
}
case sdk.JUnitAction:
var step StepJUnitReport
Expand Down Expand Up @@ -289,8 +289,8 @@ type StepGitClone struct {
User string `json:"user,omitempty" yaml:"user,omitempty"`
}

// StepRelease represents exported release step.
type StepRelease struct {
// StepReleaseVCS represents exported release step.
type StepReleaseVCS struct {
Artifacts string `json:"artifacts,omitempty" yaml:"artifacts,omitempty"`
ReleaseNote string `json:"releaseNote,omitempty" yaml:"releaseNote,omitempty"`
Tag string `json:"tag,omitempty" yaml:"tag,omitempty" jsonschema:"required"`
Expand Down Expand Up @@ -335,7 +335,7 @@ type Step struct {
ServeStaticFiles *StepServeStaticFiles `json:"serveStaticFiles,omitempty" yaml:"serveStaticFiles,omitempty" jsonschema:"oneof_required=actionServeStaticFiles" jsonschema_description:"Serve static files.\nhttps://ovh.github.io/cds/docs/actions/builtin-serve-static-files"`
GitClone *StepGitClone `json:"gitClone,omitempty" yaml:"gitClone,omitempty" jsonschema:"oneof_required=actionGitClone" jsonschema_description:"Clone a git repository.\nhttps://ovh.github.io/cds/docs/actions/builtin-gitclone"`
GitTag *StepGitTag `json:"gitTag,omitempty" yaml:"gitTag,omitempty" jsonschema:"oneof_required=actionGitTag" jsonschema_description:"Create a git tag.\nhttps://ovh.github.io/cds/docs/actions/builtin-gittag"`
Release *StepRelease `json:"release,omitempty" yaml:"release,omitempty" jsonschema:"oneof_required=actionRelease" jsonschema_description:"Release an application.\nhttps://ovh.github.io/cds/docs/actions/builtin-release"`
ReleaseVCS *StepReleaseVCS `json:"releaseVCS,omitempty" yaml:"releaseVCS,omitempty" jsonschema:"oneof_required=actionReleaseVCS" jsonschema_description:"Release an application.\nhttps://ovh.github.io/cds/docs/actions/builtin-releasevcs"`
JUnitReport *StepJUnitReport `json:"jUnitReport,omitempty" yaml:"jUnitReport,omitempty" jsonschema:"oneof_required=actionJUNit" jsonschema_description:"Parse JUnit report.\nhttps://ovh.github.io/cds/docs/actions/builtin-junit"`
Checkout *StepCheckout `json:"checkout,omitempty" yaml:"checkout,omitempty" jsonschema:"oneof_required=actionCheckout" jsonschema_description:"Checkout repository for an application.\nhttps://ovh.github.io/cds/docs/actions/builtin-checkoutapplication"`
InstallKey *StepInstallKey `json:"installKey,omitempty" yaml:"installKey,omitempty" jsonschema:"oneof_required=actionInstallKey" jsonschema_description:"Install a key (GPG, SSH) in your current workspace.\nhttps://ovh.github.io/cds/docs/actions/builtin-installkey"`
Expand Down Expand Up @@ -441,7 +441,7 @@ func (s Step) IsValid() bool {
if s.isGitTag() {
count++
}
if s.isRelease() {
if s.isReleaseVCS() {
count++
}
if s.isCheckout() {
Expand Down Expand Up @@ -483,8 +483,8 @@ func (s Step) toAction() (*sdk.Action, error) {
a, err = s.asGitClone()
} else if s.isGitTag() {
a, err = s.asGitTag()
} else if s.isRelease() {
a, err = s.asRelease()
} else if s.isReleaseVCS() {
a, err = s.asReleaseVCS()
} else if s.isCheckout() {
a = s.asCheckoutApplication()
} else if s.isInstallKey() {
Expand Down Expand Up @@ -711,16 +711,16 @@ func (s Step) asGitTag() (sdk.Action, error) {
return a, nil
}

func (s Step) isRelease() bool { return s.Release != nil }
func (s Step) isReleaseVCS() bool { return s.ReleaseVCS != nil }

func (s Step) asRelease() (sdk.Action, error) {
func (s Step) asReleaseVCS() (sdk.Action, error) {
var a sdk.Action
m, err := stepToMap(s.Release)
m, err := stepToMap(s.ReleaseVCS)
if err != nil {
return a, err
}
a = sdk.Action{
Name: sdk.ReleaseAction,
Name: sdk.ReleaseVCSAction,
Type: sdk.BuiltinAction,
Parameters: sdk.ParametersFromMap(m),
}
Expand Down Expand Up @@ -780,7 +780,7 @@ func stepToMap(i interface{}) (map[string]string, error) {

func (s Step) String() string {
buf := new(bytes.Buffer)
dump := dump.NewEncoder(buf)
_ = dump.Fdump(s)
dp := dump.NewEncoder(buf)
_ = dp.Fdump(s)
return buf.String()
}