Merge branch 'master' into rm-basic-auth-gitea

This commit is contained in:
techknowlogick 2019-08-29 18:09:04 -04:00 committed by GitHub
commit bca2fa460f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 100 additions and 6 deletions

View file

@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed
- Support for basic auth as an option for Gitea, by [@techknowlogick](https://giteahub.com/techknowlogick). [#2721](https://github.com/drone/drone/issues/2721)
## [1.3.1] - 2019-08-26
### Added
- support for the GitHub deployment status API, by [@bradrydzewski](https://github.com/bradrydzewski).
## [1.3.0] - 2019-08-20
### Added
- support for storing logs in Azure Cloud Storage, by [@Lucretius](https://github.com/Lucretius). [#2788](https://github.com/drone/drone/pull/2788)

View file

@ -45,6 +45,7 @@ type Build struct {
Params map[string]string `db:"build_params" json:"params,omitempty"`
Cron string `db:"build_cron" json:"cron,omitempty"`
Deploy string `db:"build_deploy" json:"deploy_to,omitempty"`
DeployID int64 `db:"build_deploy_id" json:"deploy_id,omitempty"`
Started int64 `db:"build_started" json:"started"`
Finished int64 `db:"build_finished" json:"finished"`
Created int64 `db:"build_created" json:"created"`

View file

@ -48,6 +48,7 @@ type Hook struct {
AuthorEmail string `json:"author_email"`
AuthorAvatar string `json:"author_avatar"`
Deployment string `json:"deploy_to"`
DeploymentID int64 `json:"deploy_id"`
Cron string `json:"cron"`
Sender string `json:"sender"`
Params map[string]string `json:"params"`

7
go.mod
View file

@ -19,12 +19,12 @@ require (
github.com/docker/go-units v0.3.3
github.com/drone/drone-go v1.0.5
github.com/drone/drone-runtime v1.1.0
github.com/drone/drone-ui v0.0.0-20190821232913-65807c0b23a3
github.com/drone/drone-ui v0.0.0-20190826173727-43d81f243ef3
github.com/drone/drone-yaml v1.2.3-0.20190807054305-a4a63fe917cb
github.com/drone/envsubst v1.0.1
github.com/drone/go-license v1.0.2
github.com/drone/go-login v1.0.4-0.20190311170324-2a4df4f242a2
github.com/drone/go-scm v1.5.1-0.20190820185953-16026ee6136f
github.com/drone/go-scm v1.5.1-0.20190826160521-fda52b1e0829
github.com/drone/signal v1.0.0
github.com/dustin/go-humanize v1.0.0
github.com/ghodss/yaml v1.0.0
@ -49,6 +49,7 @@ require (
github.com/hashicorp/go-cleanhttp v0.5.0
github.com/hashicorp/go-multierror v1.0.0
github.com/hashicorp/go-retryablehttp v0.0.0-20180718195005-e651d75abec6
github.com/hashicorp/go-rootcerts v1.0.1 // indirect
github.com/hashicorp/golang-lru v0.5.0
github.com/hashicorp/nomad v0.0.0-20190125003214-134391155854
github.com/imdario/mergo v0.3.6
@ -61,7 +62,7 @@ require (
github.com/lib/pq v1.0.0
github.com/mattn/go-sqlite3 v1.9.0
github.com/matttproud/golang_protobuf_extensions v1.0.1
github.com/mitchellh/go-homedir v1.0.0
github.com/mitchellh/go-homedir v1.1.0
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742
github.com/natessilva/dag v0.0.0-20180124060714-7194b8dcc5c4

9
go.sum
View file

@ -75,6 +75,8 @@ github.com/drone/drone-ui v0.0.0-20190820205843-4794a1d4ea32 h1:C9ndP76/qb8m/7jD
github.com/drone/drone-ui v0.0.0-20190820205843-4794a1d4ea32/go.mod h1:NBtVWW7NNJpD9+huMD/5TAE1db2nrEh0i35/9Rf1MPI=
github.com/drone/drone-ui v0.0.0-20190821232913-65807c0b23a3 h1:imiIbuxHbMjvN1r2MrpP0NXHyPMPxWKxV0xqK/Fx0z8=
github.com/drone/drone-ui v0.0.0-20190821232913-65807c0b23a3/go.mod h1:NBtVWW7NNJpD9+huMD/5TAE1db2nrEh0i35/9Rf1MPI=
github.com/drone/drone-ui v0.0.0-20190826173727-43d81f243ef3 h1:HZl9aANRu3LqhO5Adm2kaccMUH8yvbNP+0fd0mXR5YI=
github.com/drone/drone-ui v0.0.0-20190826173727-43d81f243ef3/go.mod h1:NBtVWW7NNJpD9+huMD/5TAE1db2nrEh0i35/9Rf1MPI=
github.com/drone/drone-ui v0.8.1 h1:I4WBAlnk/YQzCggQy/Qegb8Nu2T2R9KVzxso/lL98so=
github.com/drone/drone-yaml v1.0.4 h1:NYTEGhf/XJMiJT8CwGy+pMOxWC8C2vhhzEo6/gbT4tU=
github.com/drone/drone-yaml v1.0.4/go.mod h1:eM365p3g9M5sroFBTR/najiGrZnd/GiIpWHC2UW8PoI=
@ -138,6 +140,8 @@ github.com/drone/go-scm v1.5.1-0.20190718235211-75d6480d5332 h1:QdYrRquj9e0sidvg
github.com/drone/go-scm v1.5.1-0.20190718235211-75d6480d5332/go.mod h1:YT4FxQ3U/ltdCrBJR9B0tRpJ1bYA/PM3NyaLE/rYIvw=
github.com/drone/go-scm v1.5.1-0.20190820185953-16026ee6136f h1:9XvpwHypYIs/6G2ptztTJhllO7t+siuGacN7GkXUtS0=
github.com/drone/go-scm v1.5.1-0.20190820185953-16026ee6136f/go.mod h1:YT4FxQ3U/ltdCrBJR9B0tRpJ1bYA/PM3NyaLE/rYIvw=
github.com/drone/go-scm v1.5.1-0.20190826160521-fda52b1e0829 h1:aCxLIAH07bdq1+ftSxrj743yYt9h/JBd8GV9ZSBeTaQ=
github.com/drone/go-scm v1.5.1-0.20190826160521-fda52b1e0829/go.mod h1:YT4FxQ3U/ltdCrBJR9B0tRpJ1bYA/PM3NyaLE/rYIvw=
github.com/drone/signal v1.0.0 h1:NrnM2M/4yAuU/tXs6RP1a1ZfxnaHwYkd0kJurA1p6uI=
github.com/drone/signal v1.0.0/go.mod h1:S8t92eFT0g4WUgEc/LxG+LCuiskpMNsG0ajAMGnyZpc=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
@ -164,6 +168,7 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c h1:964Od4U6p2jUkFxvCy
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-jsonnet v0.12.1 h1:v0iUm/b4SBz7lR/diMoz9tLAz8lqtnNRKIwMrmU2HEU=
github.com/google/go-jsonnet v0.12.1/go.mod h1:gVu3UVSfOt5fRFq+dh9duBqXa5905QY8S1QvMNcEIVs=
@ -192,6 +197,8 @@ github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uP
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/go-retryablehttp v0.0.0-20180718195005-e651d75abec6 h1:qCv4319q2q7XKn0MQbi8p37hsJ+9Xo8e6yojA73JVxk=
github.com/hashicorp/go-retryablehttp v0.0.0-20180718195005-e651d75abec6/go.mod h1:fXcdFsQoipQa7mwORhKad5jmDCeSy/RCGzWA08PO0lM=
github.com/hashicorp/go-rootcerts v1.0.1 h1:DMo4fmknnz0E0evoNYnV48RjWndOsmd6OW+09R3cEP8=
github.com/hashicorp/go-rootcerts v1.0.1/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/nomad v0.0.0-20190125003214-134391155854 h1:L7WhLZt2ory/kQWxqkMwOiBpIoa4BWoadN7yx8LHEtk=
@ -224,6 +231,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0j
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=

View file

@ -81,6 +81,8 @@ func HandleRetry(
AuthorName: prev.AuthorName,
AuthorEmail: prev.AuthorEmail,
AuthorAvatar: prev.AuthorAvatar,
Deployment: prev.Deploy,
DeploymentID: prev.DeployID,
Sender: prev.Sender,
Params: map[string]string{},
}

View file

@ -335,6 +335,7 @@ func (p *parser) Parse(req *http.Request, secretFunc func(string) string) (*core
AuthorAvatar: v.Sender.Avatar,
Sender: v.Sender.Login,
Deployment: v.Target,
DeploymentID: v.Number,
Params: toMap(v.Data),
}
repo = &core.Repository{

View file

@ -50,7 +50,7 @@ func Trial(provider string) *core.License {
Kind: core.LicenseTrial,
Repos: 0,
Users: 0,
Builds: 10000,
Builds: 5000,
Nodes: 0,
}
}

View file

@ -20,6 +20,7 @@ import (
"github.com/drone/drone/core"
"github.com/drone/go-scm/scm"
"github.com/drone/go-scm/scm/driver/github"
)
// Config configures the Status service.
@ -63,6 +64,23 @@ func (s *service) Send(ctx context.Context, user *core.User, req *core.StatusInp
Refresh: user.Refresh,
})
// HACK(bradrydzewski) provides support for the github deployment API
if req.Build.DeployID != 0 && s.client.Driver == scm.DriverGithub {
// TODO(bradrydzewski) only update the deployment status when the
// build completes.
if req.Build.Finished == 0 {
return nil
}
_, _, err = s.client.Repositories.(*github.RepositoryService).CreateDeployStatus(ctx, req.Repo.Slug, &scm.DeployStatus{
Number: req.Build.DeployID,
Desc: createDesc(req.Build.Status),
State: convertStatus(req.Build.Status),
Target: fmt.Sprintf("%s/%s/%d", s.base, req.Repo.Slug, req.Build.Number),
Environment: req.Build.Target,
})
return err
}
_, _, err = s.client.Repositories.CreateStatus(ctx, req.Repo.Slug, req.Build.After, &scm.StatusInput{
Desc: createDesc(req.Build.Status),
Label: createLabel(s.name, req.Build.Event),

View file

@ -327,6 +327,7 @@ SELECT
,build_params
,build_cron
,build_deploy
,build_deploy_id
,build_started
,build_finished
,build_created
@ -463,6 +464,7 @@ INSERT INTO builds (
,build_params
,build_cron
,build_deploy
,build_deploy_id
,build_started
,build_finished
,build_created
@ -495,6 +497,7 @@ INSERT INTO builds (
,:build_params
,:build_cron
,:build_deploy
,:build_deploy_id
,:build_started
,:build_finished
,:build_created

View file

@ -55,6 +55,7 @@ func toParams(build *core.Build) map[string]interface{} {
"build_params": encodeParams(build.Params),
"build_cron": build.Cron,
"build_deploy": build.Deploy,
"build_deploy_id": build.DeployID,
"build_started": build.Started,
"build_finished": build.Finished,
"build_created": build.Created,
@ -138,6 +139,7 @@ func scanRow(scanner db.Scanner, dest *core.Build) error {
&paramsJSON,
&dest.Cron,
&dest.Deploy,
&dest.DeployID,
&dest.Started,
&dest.Finished,
&dest.Created,

View file

@ -302,6 +302,7 @@ const queryColsBulds = queryCols + `
,build_params
,build_cron
,build_deploy
,build_deploy_id
,build_started
,build_finished
,build_created

View file

@ -166,6 +166,7 @@ func scanRowBuild(scanner db.Scanner, dest *core.Repository) error {
&build.Params,
&build.Cron,
&build.Deploy,
&build.DeployID,
&build.Started,
&build.Finished,
&build.Created,

View file

@ -52,6 +52,7 @@ type nullBuild struct {
Params types.JSONText
Cron sql.NullString
Deploy sql.NullString
DeployID sql.NullInt64
Started sql.NullInt64
Finished sql.NullInt64
Created sql.NullInt64
@ -91,6 +92,7 @@ func (b *nullBuild) value() *core.Build {
Params: params,
Cron: b.Cron.String,
Deploy: b.Deploy.String,
DeployID: b.DeployID.Int64,
Started: b.Started.Int64,
Finished: b.Finished.Int64,
Created: b.Created.Int64,

View file

@ -124,6 +124,10 @@ var migrations = []struct {
name: "create-table-org-secrets",
stmt: createTableOrgSecrets,
},
{
name: "alter-table-builds-add-column-deploy-id",
stmt: alterTableBuildsAddColumnDeployId,
},
}
// Migrate performs the database migration. If the migration fails
@ -577,3 +581,11 @@ CREATE TABLE IF NOT EXISTS orgsecrets (
,UNIQUE(secret_namespace, secret_name)
);
`
//
// 013_add_column_builds_deploy_id.sql
//
var alterTableBuildsAddColumnDeployId = `
ALTER TABLE builds ADD COLUMN build_deploy_id INTEGER NOT NULL DEFAULT 0;
`

View file

@ -0,0 +1,3 @@
-- name: alter-table-builds-add-column-deploy-id
ALTER TABLE builds ADD COLUMN build_deploy_id INTEGER NOT NULL DEFAULT 0;

View file

@ -120,6 +120,10 @@ var migrations = []struct {
name: "create-table-org-secrets",
stmt: createTableOrgSecrets,
},
{
name: "alter-table-builds-add-column-deploy-id",
stmt: alterTableBuildsAddColumnDeployId,
},
}
// Migrate performs the database migration. If the migration fails
@ -555,3 +559,11 @@ CREATE TABLE IF NOT EXISTS orgsecrets (
,UNIQUE(secret_namespace, secret_name)
);
`
//
// 013_add_column_builds_deploy_id.sql
//
var alterTableBuildsAddColumnDeployId = `
ALTER TABLE builds ADD COLUMN build_deploy_id INTEGER NOT NULL DEFAULT 0;
`

View file

@ -0,0 +1,3 @@
-- name: alter-table-builds-add-column-deploy-id
ALTER TABLE builds ADD COLUMN build_deploy_id INTEGER NOT NULL DEFAULT 0;

View file

@ -120,6 +120,10 @@ var migrations = []struct {
name: "create-table-org-secrets",
stmt: createTableOrgSecrets,
},
{
name: "alter-table-builds-add-column-deploy-id",
stmt: alterTableBuildsAddColumnDeployId,
},
}
// Migrate performs the database migration. If the migration fails
@ -557,3 +561,11 @@ CREATE TABLE IF NOT EXISTS orgsecrets (
,UNIQUE(secret_namespace, secret_name)
);
`
//
// 013_add_column_builds_deploy_id.sql
//
var alterTableBuildsAddColumnDeployId = `
ALTER TABLE builds ADD COLUMN build_deploy_id NUMBER NOT NULL DEFAULT 0;
`

View file

@ -0,0 +1,3 @@
-- name: alter-table-builds-add-column-deploy-id
ALTER TABLE builds ADD COLUMN build_deploy_id NUMBER NOT NULL DEFAULT 0;

View file

@ -181,6 +181,7 @@ func (t *triggerer) Trigger(ctx context.Context, repo *core.Repository, base *co
Params: base.Params,
Cron: base.Cron,
Deploy: base.Deployment,
DeployID: base.DeploymentID,
Sender: base.Sender,
Created: time.Now().Unix(),
Updated: time.Now().Unix(),
@ -320,6 +321,7 @@ func (t *triggerer) Trigger(ctx context.Context, repo *core.Repository, base *co
AuthorAvatar: base.AuthorAvatar,
Params: base.Params,
Deploy: base.Deployment,
DeployID: base.DeploymentID,
Sender: base.Sender,
Created: time.Now().Unix(),
Updated: time.Now().Unix(),
@ -486,6 +488,7 @@ func (t *triggerer) createBuildError(ctx context.Context, repo *core.Repository,
AuthorEmail: base.AuthorEmail,
AuthorAvatar: base.AuthorAvatar,
Deploy: base.Deployment,
DeployID: base.DeploymentID,
Sender: base.Sender,
Created: time.Now().Unix(),
Updated: time.Now().Unix(),

View file

@ -27,7 +27,7 @@ var (
// VersionMinor is for functionality in a backwards-compatible manner.
VersionMinor int64 = 3
// VersionPatch is for backwards-compatible bug fixes.
VersionPatch int64
VersionPatch int64 = 1
// VersionPre indicates prerelease.
VersionPre = ""
// VersionDev indicates development branch. Releases will be empty string.

View file

@ -9,7 +9,7 @@ package version
import "testing"
func TestVersion(t *testing.T) {
if got, want := Version.String(), "1.3.0"; got != want {
if got, want := Version.String(), "1.3.1"; got != want {
t.Errorf("Want version %s, got %s", want, got)
}
}