Skip to content

Commit

Permalink
Merge pull request #58 from kameshsampath/inline-exec
Browse files Browse the repository at this point in the history
Using inline Drone Exec and other Improvements
  • Loading branch information
kameshsampath committed Oct 30, 2022
2 parents 1143785 + 889fdcc commit 685fa96
Show file tree
Hide file tree
Showing 2,248 changed files with 1,137 additions and 4,718,888 deletions.
3 changes: 2 additions & 1 deletion .drone.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ steps:
CGO_ENABLED: "0"
commands:
- cd backend
- goreleaser build --snapshot --rm-dist --debug
- goreleaser build --snapshot --rm-dist

- name: ui-build
image: node:17.7-buster
Expand All @@ -25,6 +25,7 @@ steps:
# static files from extension path on the Host
PUBLIC_URL: .
BROWSER: none
CI: false
commands:
- cd ui
- curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@7
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ You can remove one or more Drone pipelines, removing does not physically delete

![Remove Pipelines](./docs/images/drone_desktop_feature_remove_pipelines.gif)

### Stop Pipelines

You can now stop any running pipeline, this operation will basically kill the associated drone process.

![Stop Pipelines](../docs/images/drone_desktop_feature_stop_pipelines.gif)

## Install Extension

```shell
Expand Down
20 changes: 16 additions & 4 deletions backend/.goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,22 @@ builds:
- windows
asmflags:
- all=-trimpath={{.Env.GOPATH}}
flags:
- -mod=vendor
ldflags:
- -s -w -X main.build={{.Version}}
goarch:
- amd64
- arm64
- id: drone
main: cmd/drone/main.go
binary: drone
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
asmflags:
- all=-trimpath={{.Env.GOPATH}}
ldflags:
- -s -w -X main.build={{.Version}}
goarch:
Expand All @@ -28,8 +42,6 @@ builds:
- windows
asmflags:
- all=-trimpath={{.Env.GOPATH}}
flags:
- -mod=vendor
ldflags:
- -s -w -X main.build={{.Version}}
goarch:
Expand Down
30 changes: 30 additions & 0 deletions backend/cmd/drone/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package main

import (
"fmt"
"os"

"github.com/harness/drone-ci-docker-extension/pkg/drone"
"github.com/urfave/cli/v2"
)

// drone version number
var version string

func main() {
app := cli.NewApp()
app.Name = "drone"
app.Version = version
app.Usage = "command line utility to run drone pipelines locally"
app.EnableBashCompletion = true

app.Commands = []*cli.Command{
drone.Command,
}

if err := app.Run(os.Args); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}

}
37 changes: 31 additions & 6 deletions backend/cmd/pipelines-finder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,37 @@ import (
"io"
"os"
"path/filepath"
"sort"
"strings"

"github.com/harness/drone-ci-docker-extension/pkg/db"
"github.com/harness/drone-ci-docker-extension/pkg/ignore"
log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v3"
)

type Stage struct {
PipelineFile string `json:"pipelineFile"`
PipelinePath string `json:"pipelinePath"`
Name string `json:"name"`
Steps []Step `json:"steps"`
Services []Service `json:"-"`
}

type Step struct {
Name string `json:"name"`
Image string `json:"image"`
Service int `json:"isService"`
}

type Service struct {
Name string `json:"name"`
Image string `json:"image"`
}

type Stages []*Stage

func main() {
var directory string
var stages db.Stages
var stages Stages

flag.StringVar(&directory, "path", "", "Root Path to discover drone pipelines")
flag.Parse()
Expand Down Expand Up @@ -68,10 +87,9 @@ func main() {

decoder := yaml.NewDecoder(file)
for {
stage := new(db.Stage)
stage := new(Stage)
stage.PipelineFile = path
stage.PipelinePath = filepath.Dir(path)
stage.Logs = []byte("")
err := decoder.Decode(stage)
if stage == nil {
continue
Expand All @@ -82,6 +100,13 @@ func main() {
if err != nil {
log.Fatal(err)
}
for _, svc := range stage.Services {
stage.Steps = append(stage.Steps, Step{
Name: svc.Name,
Image: svc.Image,
Service: 1,
})
}
stages = append(stages, stage)
}
}
Expand All @@ -92,7 +117,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
sort.Sort(stages)
//sort.Sort(stages)
b, err := json.Marshal(stages)
if err != nil {
log.Fatal(err)
Expand Down
32 changes: 30 additions & 2 deletions backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,71 @@ module github.com/harness/drone-ci-docker-extension

go 1.18

replace github.com/docker/docker => github.com/docker/engine v17.12.0-ce-rc1.0.20200309214505-aa6a9891b09c+incompatible

require (
github.com/labstack/echo/v4 v4.7.2
github.com/sirupsen/logrus v1.8.1
)

require (
github.com/docker/docker v0.0.0-00010101000000-000000000000
github.com/drone-runners/drone-runner-docker v1.8.2
github.com/drone/drone-go v1.7.1
github.com/drone/envsubst v1.0.3
github.com/drone/runner-go v1.12.0
github.com/drone/signal v1.0.0
github.com/google/go-cmp v0.5.8
github.com/joho/godotenv v1.3.0
github.com/stretchr/testify v1.8.0
github.com/uptrace/bun v1.1.8
github.com/uptrace/bun/dbfixture v1.1.8
github.com/uptrace/bun/dialect/sqlitedialect v1.1.8
github.com/uptrace/bun/driver/sqliteshim v1.1.8
github.com/uptrace/bun/extra/bundebug v1.1.8
github.com/urfave/cli/v2 v2.20.3
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/99designs/httpsignatures-go v0.0.0-20170731043157-88528bf4ca7e // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/bmatcuk/doublestar v1.1.1 // indirect
github.com/buildkite/yaml v2.1.0+incompatible // indirect
github.com/containerd/containerd v1.3.4 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v20.10.18+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.0.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/mattn/go-sqlite3 v1.14.15 // indirect
github.com/natessilva/dag v0.0.0-20180124060714-7194b8dcc5c4 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/tools v0.1.12 // indirect
google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154 // indirect
google.golang.org/grpc v1.29.1 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
lukechampine.com/uint128 v1.2.0 // indirect
modernc.org/cc/v3 v3.36.3 // indirect
modernc.org/ccgo/v3 v3.16.9 // indirect
Expand All @@ -53,7 +81,7 @@ require (

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/labstack/gommon v0.3.1 // indirect
github.com/labstack/gommon v0.3.1
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand Down

0 comments on commit 685fa96

Please sign in to comment.