Skip to content

Commit

Permalink
update build docker to hub
Browse files Browse the repository at this point in the history
  • Loading branch information
NortonBen committed Oct 23, 2022
1 parent 12c6047 commit 720a780
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
# list of Docker images to use as base name for tags
images: |
name/app
dipperhub/dipper-engine
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
Expand Down
21 changes: 11 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
FROM golang:1.19-alpine as builder
FROM alpine:3.12.1 as builder

ENV GO111MODULE=on
ENV GOFLAGS=" -ldflags '-w'"
ENV GOPROXY=direct
ENV GOSUMDB=off

COPY . .
COPY --from=golang:1.19-alpine /usr/local/go/ /usr/local/go/
ENV PATH="/usr/local/go/bin:${PATH}"
RUN apk --no-cache add make git gcc libtool musl-dev

COPY go.mod .
COPY go.sum .
RUN go mod download
RUN GOOS=linux GOARCH=amd64 go build
COPY . /
RUN make build; rm -rf $GOPATH/pkg/mod


FROM alpine:3.14 as run
FROM alpine:3.12.1
RUN apk add --no-progress --no-cache ca-certificates
COPY --from=builder dipper-engine /dipper-engine
COPY --from=builder /dipper-engine /dipper-engine
ADD config.json /config.json
ENTRYPOINT [ "/dipper-engine" ]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GO111MODULE=on

build:
go build
go build -ldflags "-s"

test: build
go test -cover ./... -covermode=count -coverprofile=coverage.out
Expand Down
97 changes: 97 additions & 0 deletions rules/conditional/conditional_rule_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package conditional

import (
"context"
"github.com/dipper-iot/dipper-engine/data"
"github.com/dipper-iot/dipper-engine/queue"
"testing"
)

func TestConditionalRule_Run(t *testing.T) {
a := ConditionalRule{}
a.Initialize(context.TODO(), map[string]interface{}{})
qsub := queue.NewDefaultQueue[*data.InputEngine]("qsub")
qpub := queue.NewDefaultQueue[*data.OutputEngine]("qpub")

qsub.Publish(context.TODO(), &data.InputEngine{
SessionId: 1,
ChanId: "1",
IdNode: "noed1",
FromEngine: "test",
ToEngine: "test",
Node: &data.NodeRule{
Option: map[string]interface{}{
"operator": map[string]interface{}{
"right": map[string]interface{}{
"value": "default.a",
"type": "val",
},
"left": map[string]interface{}{
"type": "val",
"value": "default.b",
},
"operator": "<>",
"type": "operator",
},
"set_param_result_to": "default.cond_a_b",
"next_error": "4",
"next_true": "4",
"next_false": "4",
},
End: false,
Infinite: false,
Debug: false,
RuleId: "1",
NodeId: "1",
},
Data: map[string]interface{}{
"default": map[string]interface{}{
"a": 2,
"b": 2,
"x": 3,
},
},
BranchMain: "default",
})
qsub.Publish(context.TODO(), &data.InputEngine{
SessionId: 1,
ChanId: "1",
IdNode: "noed1",
FromEngine: "test",
ToEngine: "test",
Node: &data.NodeRule{
Option: map[string]interface{}{
"operator": map[string]interface{}{
"right": map[string]interface{}{
"value": "default.f",
"type": "val",
},
"left": map[string]interface{}{
"type": "val",
"value": "default.b",
},
"operator": "<>",
"type": "operator",
},
"set_param_result_to": "default.cond_a_b",
"next_error": "4",
"next_true": "4",
"next_false": "4",
},
End: false,
Infinite: false,
Debug: false,
RuleId: "1",
NodeId: "1",
},
Data: map[string]interface{}{
"default": map[string]interface{}{
"a": 2,
"b": 2,
"x": 3,
},
},
BranchMain: "default",
})
a.Run(context.TODO(), qsub.Subscribe, qpub.Publish)
}

0 comments on commit 720a780

Please sign in to comment.