diff --git a/.drone.yml b/.drone.yml index 82b45498..8165d460 100644 --- a/.drone.yml +++ b/.drone.yml @@ -9,12 +9,12 @@ platform: steps: - name: test - image: golang:1.13.0 + image: golang:1.14.4 commands: - go test ./... - name: build - image: golang:1.13.0 + image: golang:1.14.4 commands: - sh scripts/build.sh environment: @@ -48,7 +48,7 @@ platform: steps: - name: build - image: golang:1.13.0 + image: golang:1.14.4 commands: - sh scripts/build.sh environment: @@ -86,7 +86,7 @@ platform: steps: - name: build - image: golang:1.13.0 + image: golang:1.14.4 commands: - sh scripts/build.sh environment: diff --git a/CHANGELOG.md b/CHANGELOG.md index 497b805c..a2ab5dd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased +### Added +- re-assigned repository ownership when deactivating a user. +- re-assigned repository ownership when deleting a user. +- de-activate a repository when deleting a user if re-assignment fails. +- de-activate a repository when deactivating a user if re-assignment fails. +- routine to cleanup builds stuck in a pending state. +- routine to cleanup builds stuck in a running state. +- private mode setting requires authentication to view public repositories. + +### Fixed +- issue with sq.ErrNoRows error when canceling a build. + +### Changed +- upgraded Go toolchain to version 1.14.4. + ## [1.7.0] - 2020-03-27 ### Added - endpoint to display the latest build by branch. [#2940](https://github.com/drone/drone/pull/2940). diff --git a/core/build.go b/core/build.go index 77b34d0e..28b092bd 100644 --- a/core/build.go +++ b/core/build.go @@ -115,3 +115,28 @@ type BuildStore interface { // Count returns a count of builds. Count(context.Context) (int64, error) } + +// IsDone returns true if the build has a completed state. +func (b *Build) IsDone() bool { + switch b.Status { + case StatusWaiting, + StatusPending, + StatusRunning, + StatusBlocked: + return false + default: + return true + } +} + +// IsFailed returns true if the build has failed +func (b *Build) IsFailed() bool { + switch b.Status { + case StatusFailing, + StatusKilled, + StatusError: + return true + default: + return false + } +} diff --git a/operator/manager/manager.go b/operator/manager/manager.go index 07caaa74..d8ed9849 100644 --- a/operator/manager/manager.go +++ b/operator/manager/manager.go @@ -473,21 +473,33 @@ func (m *Manager) Netrc(ctx context.Context, id int64) (*core.Netrc, error) { // Watch watches for build cancellation requests. func (m *Manager) Watch(ctx context.Context, id int64) (bool, error) { ok, err := m.Scheduler.Cancelled(ctx, id) + // we expect a context cancel error here which + // indicates a polling timeout. The subscribing + // client should look for the context cancel error + // and resume polling. if err != nil { return ok, err } - // if a not found error is returned we should check - // the database to see if the stage is complete. If + // // TODO (bradrydzewski) we should be able to return + // // immediately if Cancelled returns true. This requires + // // some more testing but would avoid the extra database + // // call. + // if ok { + // return ok, err + // } + + // if no error is returned we should check + // the database to see if the build is complete. If // complete, return true. - stage, err := m.Stages.Find(ctx, id) + build, err := m.Builds.Find(ctx, id) if err != nil { logger := logrus.WithError(err) - logger = logger.WithField("step-id", id) - logger.Warnln("manager: cannot find stage") + logger = logger.WithField("build-id", id) + logger.Warnln("manager: cannot find build") return ok, err } - return stage.IsDone(), nil + return build.IsDone(), nil } // Write writes a line to the build logs. diff --git a/version/version.go b/version/version.go index c63498a3..85e81b2d 100644 --- a/version/version.go +++ b/version/version.go @@ -25,7 +25,7 @@ var ( // VersionMajor is for an API incompatible changes. VersionMajor int64 = 1 // VersionMinor is for functionality in a backwards-compatible manner. - VersionMinor int64 = 7 + VersionMinor int64 = 8 // VersionPatch is for backwards-compatible bug fixes. VersionPatch int64 // VersionPre indicates prerelease. diff --git a/version/version_test.go b/version/version_test.go index 5966233f..ed93397d 100644 --- a/version/version_test.go +++ b/version/version_test.go @@ -9,7 +9,7 @@ package version import "testing" func TestVersion(t *testing.T) { - if got, want := Version.String(), "1.7.0"; got != want { + if got, want := Version.String(), "1.8.0"; got != want { t.Errorf("Want version %s, got %s", want, got) } }