mirror of
https://codeberg.org/woodpecker-plugins/go-plugin
synced 2026-06-16 14:49:10 +08:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 00a58f4a06 | |||
| 1d5ccf599c | |||
| 26cc02d9d9 | |||
| b43eefd089 | |||
| 3cf11a328e | |||
| dc21eb0c71 | |||
| 06e90d56f8 | |||
| 33cbc07540 | |||
| cac90b61b0 | |||
| 2b59a3028d | |||
| 2b17135e0c | |||
| c79c27bb51 | |||
| 5859397549 | |||
| b9a4363bd9 | |||
| 81050b18f0 |
@@ -6,8 +6,8 @@ when:
|
||||
- 'renovate/*'
|
||||
|
||||
variables:
|
||||
- &golang "golang:1.22"
|
||||
- &golangci-lint "golangci/golangci-lint:v1.59-alpine"
|
||||
- &golang "golang:1.23"
|
||||
- &golangci-lint "golangci/golangci-lint:v1.61-alpine"
|
||||
- &reviewdog-golangci-lint "woodpeckerci/plugin-reviewdog-golangci-lint:1.59"
|
||||
|
||||
steps:
|
||||
@@ -0,0 +1,14 @@
|
||||
when:
|
||||
- event: push
|
||||
branch:
|
||||
- ${CI_REPO_DEFAULT_BRANCH}
|
||||
- release/*
|
||||
|
||||
steps:
|
||||
- name: release-helper
|
||||
image: docker.io/woodpeckerci/plugin-ready-release-go:2.1.1
|
||||
settings:
|
||||
release_branch: ${CI_COMMIT_BRANCH}
|
||||
git_email: woodpecker-bot@obermui.de
|
||||
forge_token:
|
||||
from_secret: gitea_token
|
||||
@@ -0,0 +1,19 @@
|
||||
# Changelog
|
||||
|
||||
## [0.7.0](https://codeberg.org/woodpecker-plugins/go-plugin/releases/tag/v0.7.0) - 2024-11-13
|
||||
|
||||
### ❤️ Thanks to all contributors! ❤️
|
||||
|
||||
@6543, @woodpecker-bot
|
||||
|
||||
### 📈 Enhancement
|
||||
|
||||
- Add support for CI_PIPELINE_FILES [[#33](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/33)]
|
||||
|
||||
### 📦️ Dependency
|
||||
|
||||
- fix(deps): update github.com/urfave/cli/v3 digest to cd7d34a [[#32](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/32)]
|
||||
|
||||
### Misc
|
||||
|
||||
- Use ready-release-go plugin [[#34](https://codeberg.org/woodpecker-plugins/go-plugin/pulls/34)]
|
||||
@@ -6,8 +6,8 @@ require (
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/rs/zerolog v1.33.0
|
||||
github.com/stretchr/testify v1.9.0
|
||||
github.com/urfave/cli/v3 v3.0.0-alpha9.0.20240717192922-127cf54fac9f
|
||||
golang.org/x/net v0.27.0
|
||||
github.com/urfave/cli/v3 v3.0.0-alpha9.1
|
||||
golang.org/x/net v0.30.0
|
||||
)
|
||||
|
||||
require (
|
||||
@@ -15,6 +15,6 @@ require (
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
golang.org/x/sys v0.22.0 // indirect
|
||||
golang.org/x/sys v0.26.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
||||
@@ -17,15 +17,15 @@ github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
|
||||
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/urfave/cli/v3 v3.0.0-alpha9.0.20240717192922-127cf54fac9f h1:yCJ90PBe7+45EQSF3qJXyAGW5rkE65lE8huv5pM0HY8=
|
||||
github.com/urfave/cli/v3 v3.0.0-alpha9.0.20240717192922-127cf54fac9f/go.mod h1:Z1ItyMma7t6I7zHG9OpbExhHQOSkFf/96n+mAZ9MtVI=
|
||||
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
|
||||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
|
||||
github.com/urfave/cli/v3 v3.0.0-alpha9.1 h1:1fJU+bltkwN8lF4Sni/X0i1d8XwPIrS82ivZ8qsp/q4=
|
||||
github.com/urfave/cli/v3 v3.0.0-alpha9.1/go.mod h1:FnIeEMYu+ko8zP1F9Ypr3xkZMIDqW3DR92yUtY39q1Y=
|
||||
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
|
||||
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
|
||||
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
|
||||
@@ -53,6 +53,7 @@ func testMetadata() map[string]string {
|
||||
"CI_PIPELINE_STATUS": "running",
|
||||
"CI_PIPELINE_CREATED": "1611234567",
|
||||
"CI_PIPELINE_STARTED": "1611234567",
|
||||
"CI_PIPELINE_FILES": `["README.md", "main.go"]`,
|
||||
// Step
|
||||
"CI_STEP_NUMBER": "1",
|
||||
"CI_STEP_NAME": "test",
|
||||
@@ -107,6 +108,7 @@ func TestMetadata(t *testing.T) {
|
||||
assert.Equal(t, "running", plugin.Metadata.Pipeline.Status)
|
||||
assert.Equal(t, time.Unix(1611234567, 0), plugin.Metadata.Pipeline.Created)
|
||||
assert.Equal(t, time.Unix(1611234567, 0), plugin.Metadata.Pipeline.Started)
|
||||
assert.Equal(t, []string{"README.md", "main.go"}, plugin.Metadata.Pipeline.ChangedFiles)
|
||||
|
||||
// Step
|
||||
assert.Equal(t, 1, plugin.Metadata.Step.Number)
|
||||
|
||||
+21
@@ -15,8 +15,11 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
@@ -40,6 +43,7 @@ type Pipeline struct {
|
||||
Started time.Time `json:"started,omitempty"`
|
||||
Finished time.Time `json:"finished,omitempty"`
|
||||
Parent int64 `json:"parent,omitempty"`
|
||||
ChangedFiles []string `json:"files,omitempty"`
|
||||
|
||||
// Deprecated: Please use URL instead.
|
||||
Link string `json:"link,omitempty"`
|
||||
@@ -121,10 +125,26 @@ func pipelineFlags() []cli.Flag {
|
||||
"DRONE_BUILD_PARENT",
|
||||
),
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "pipeline.files",
|
||||
Usage: "pipeline changed files (string list as json)",
|
||||
Sources: cli.EnvVars(
|
||||
"CI_PIPELINE_FILES",
|
||||
),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func pipelineFromContext(c *cli.Command) Pipeline {
|
||||
var changedFiles []string
|
||||
|
||||
if files := c.String("pipeline.files"); files != "" {
|
||||
if err := json.Unmarshal([]byte(files), &changedFiles); err != nil {
|
||||
log.Error().Err(err).Msg("parse \"CI_PIPELINE_FILES\" failed")
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
return Pipeline{
|
||||
Number: c.Int("pipeline.number"),
|
||||
Status: c.String("pipeline.status"),
|
||||
@@ -136,5 +156,6 @@ func pipelineFromContext(c *cli.Command) Pipeline {
|
||||
Started: time.Unix(c.Int("pipeline.started"), 0),
|
||||
Finished: time.Unix(c.Int("pipeline.finished"), 0),
|
||||
Parent: c.Int("pipeline.parent"),
|
||||
ChangedFiles: changedFiles,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user