From 3f42d3db63859026154be3f9f4d3c489a6e8b550 Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Wed, 2 Jun 2021 11:29:12 +0800 Subject: [PATCH] init --- .drone.yml | 25 +++++++++++++++++++++++++ Dockerfile | 3 +++ README.md | 2 ++ go.mod | 3 +++ main.go | 12 ++++++++++++ main_test.go | 16 ++++++++++++++++ 6 files changed, 61 insertions(+) create mode 100644 .drone.yml create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 go.mod create mode 100644 main.go create mode 100644 main_test.go diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..3d06487 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,25 @@ +kind: pipeline +type: docker +name: default +platform: + arch: amd64 + os: linux +steps: + - name: test + image: golang:1.16.4 + commands: + - go test + - name: build + image: golang:1.16.4 + commands: + - go build -ldflags "-X main.version=${DRONE_COMMIT_SHA:0:8}" + - name: publish + image: plugins/docker:19.03.8 + environment: + PLUGIN_REGISTRY: 10.10.14.176:5000 + PLUGIN_REPO: 10.10.14.176:5000/go/example + settings: + insecure: true + tags: + - latest + - ${DRONE_STAGE_OS}-${DRONE_STAGE_ARCH}-${DRONE_REPO_BRANCH}-${DRONE_COMMIT_SHA:0:8} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..890b64f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,3 @@ +FROM scratch +ADD example / +ENTRYPOINT ["/example"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..fe1ef12 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# example + diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..ebe89e0 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module example + +go 1.14 \ No newline at end of file diff --git a/main.go b/main.go new file mode 100644 index 0000000..b12f3b4 --- /dev/null +++ b/main.go @@ -0,0 +1,12 @@ +package main + +import "fmt" + +func main() { + fmt.Println(HelloWorld()) +} + +// HelloWorld is a function that returns a string containing "hello world". +func HelloWorld() string { + return "hello world" +} \ No newline at end of file diff --git a/main_test.go b/main_test.go new file mode 100644 index 0000000..e9b0e55 --- /dev/null +++ b/main_test.go @@ -0,0 +1,16 @@ +package main + +import ( + "os" + "testing" +) + +func TestMain(m *testing.M) { + os.Exit(m.Run()) +} + +func TestHelloWorld(t *testing.T) { + if HelloWorld() != "hello world" { + t.Errorf("got %s expected %s", HelloWorld(), "hello world") + } +} \ No newline at end of file