Codebase list golang-github-awalterschulze-gographviz / upstream/2.0.3
Import upstream version 2.0.3 Debian Janitor 1 year, 6 months ago
10 changed file(s) with 161 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
0 name: build
1
2 on: [push, pull_request]
3
4 jobs:
5 build:
6 runs-on: ubuntu-latest
7 env:
8 working-directory: ./src/github.com/awalterschulze/gographviz
9
10 steps:
11 - name: Set GOPATH
12 run: |
13 echo "##[set-env name=GOPATH;]$(dirname $GITHUB_WORKSPACE)/gographviz"
14 echo "##[add-path]$(dirname $GITHUB_WORKSPACE)/gographviz/bin"
15 shell: bash
16
17 - name: Setup Go
18 uses: actions/setup-go@v2
19 with:
20 go-version: '1.14'
21
22 - name: Checkout
23 uses: actions/checkout@v2
24 with:
25 fetch-depth: 1
26 path: src/github.com/awalterschulze/gographviz
27
28 - name: Install dependencies
29 run: make dependencies
30 working-directory: ${{env.working-directory}}
31
32 - name: Run regenerate
33 run: make regenerate
34 working-directory: ${{env.working-directory}}
35
36 - name: Run build
37 run: make build
38 working-directory: ${{env.working-directory}}
39
40 - name: Run checkers
41 run: make checkers
42 working-directory: ${{env.working-directory}}
43
44 - name: Run testing
45 run: make test
46 working-directory: ${{env.working-directory}}
+0
-10
.travis.yml less more
0 before_install:
1 - ./install-godeps.sh
2
3 script:
4 - make travis
5
6 language: go
7
8 go:
9 - 1.x
0 regenerate:
0 .PHONY: help regenerate test dependencies build checkers action
1
2 # Prefer tools that we've installed
3 export PATH := $(HOME)/go/bin:$(PATH)
4
5 help:
6 @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
7
8 regenerate: ## Re-generate lexers and parsers and pass through goimports
9 go get github.com/goccmack/gocc
110 go install github.com/goccmack/gocc
2 gocc -zip -o ./internal/ dot.bnf
11 gocc -zip -o ./internal/ dot.bnf
312 find . -type f -name '*.go' | xargs goimports -w
413
5 test:
14 test: ## Perform package tests
615 go test ./...
716
8 travis:
9 make regenerate
10 go build ./...
11 go test ./...
17 dependencies: ## Grab necessary dependencies for checkers
18 go version
19 go get golang.org/x/tools/cmd/goimports
20 go get github.com/kisielk/errcheck
21 go get -u golang.org/x/lint/golint
22
23 build: ## Perform build process
24 go build .
25
26 checkers: ## Run all checkers (errcheck, gofmt and golint)
1227 errcheck -ignore 'fmt:[FS]?[Pp]rint*' ./...
1328 gofmt -l -s -w .
1429 golint -set_exit_status
1530 git diff --exit-code
31
32 action: dependencies regenerate build test checkers ## Run steps of github action
1717
1818 ### Documentation ###
1919
20 The [godoc](https://godoc.org/github.com/awalterschulze/gographviz) includes some more examples.
20 - The [godoc](https://godoc.org/github.com/awalterschulze/gographviz) includes some more examples.
21 - [How to implement an anonymous subgraph](https://github.com/awalterschulze/gographviz/issues/59)
2122
2223 ### Installation ###
2324 go get github.com/awalterschulze/gographviz
2425
25 ### Tests ###
26 ### Build and Tests ###
2627
27 [![Build Status](https://travis-ci.org/awalterschulze/gographviz.svg?branch=master)](https://travis-ci.org/awalterschulze/gographviz)
28 [![Build Status](https://github.com/awalterschulze/gographviz/workflows/build/badge.svg)](https://github.com/awalterschulze/gographviz/actions)
29
2830
2931 ### Users ###
3032
3335 - [imagemonkey](https://imagemonkey.io/graph?editor=true) - Let's create our own image dataset
3436 - [depviz](https://github.com/moul/depviz) - GitHub dependency visualizer (auto-roadmap)
3537 - [kustomize-graph](https://github.com/jpreese/kustomize-graph) - A tool to visualize Kustomize dependencies
38 - [inframap](https://github.com/cycloidio/inframap) - Read your tfstate or HCL to generate a graph specific for each Terraform provider
39 - [Antrea Traceflow](https://github.com/vmware-tanzu/antrea/blob/master/docs/traceflow-guide.md) supports using Traceflow for network diagnosis for Antrea, a Kubernetes networking solution intended to be Kubernetes native
3640
3741 ### Mentions ###
3842
103103 func TestString(t *testing.T) {
104104 anal(t,
105105 `digraph finite_state { rankdir = "LR" }`)
106 }
107
108 func TestAttrImgPos(t *testing.T) {
109 anal(t,
110 "digraph finite_state { imagepos = tc }")
106111 }
107112
108113 func TestAttrList(t *testing.T) {
140140 Image Attr = "image"
141141 // ImagePath http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:imagepath
142142 ImagePath Attr = "imagepath"
143 // ImagePos https://graphviz.org/doc/info/attrs.html#d:imagepos
144 ImagePos Attr = "imagepos"
143145 // ImageScale http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:imagescale
144146 ImageScale Attr = "imagescale"
145147 // InputScale http://graphviz.gitlab.io/_pages/doc/info/attrs.html#d:inputscale
436438 string(ID): ID,
437439 string(Image): Image,
438440 string(ImagePath): ImagePath,
441 string(ImagePos): ImagePos,
439442 string(ImageScale): ImageScale,
440443 string(InputScale): InputScale,
441444 string(Label): Label,
7575 return false
7676 }
7777 if c == '/' {
78 return false
79 }
80 if c == '.' {
7881 return false
7982 }
8083 i++
4545 if err := g.AddNode("asdf asdf", "a/b", nil); err != nil {
4646 t.Fatal(err)
4747 }
48 if err := g.AddNode("asdf asdf", "c.d", nil); err != nil {
49 t.Fatal(err)
50 }
51 if err := g.AddNode("asdf asdf", "e-f", nil); err != nil {
52 t.Fatal(err)
53 }
54 if err := g.AddNode("asdf asdf", "12_34", nil); err != nil {
55 t.Fatal(err)
56 }
4857 s := g.String()
4958 if !strings.HasPrefix(s, `digraph "asdf adsf" {
5059 "kasdf99 99"->7;
60 "12_34";
5161 "a << b";
5262 "a/b";
63 "c.d";
64 "e-f";
5365 "kasdf99 99" [ URL="<a" ];
5466 7 [ URL="<a" ];
5567
+0
-7
install-godeps.sh less more
0 #!/usr/bin/env bash
1 set -xe
2 mkdir -p $GOPATH/src/githbub.com/goccmack
3 git clone https://github.com/goccmack/gocc $GOPATH/src/github.com/goccmack/gocc
4 go get golang.org/x/tools/cmd/goimports
5 go get github.com/kisielk/errcheck
6 go get -u golang.org/x/lint/golint
33
44 import (
55 "fmt"
6 "strconv"
7 "unicode/utf8"
68 )
79
810 type Token struct {
5658 return fmt.Sprintf("%s(%d)", m.Id(typ), typ)
5759 }
5860
61 // CharLiteralValue returns the string value of the char literal.
62 func (t *Token) CharLiteralValue() string {
63 return string(t.Lit[1 : len(t.Lit)-1])
64 }
65
66 // Float32Value returns the float32 value of the token or an error if the token literal does not
67 // denote a valid float32.
68 func (t *Token) Float32Value() (float32, error) {
69 if v, err := strconv.ParseFloat(string(t.Lit), 32); err != nil {
70 return 0, err
71 } else {
72 return float32(v), nil
73 }
74 }
75
76 // Float64Value returns the float64 value of the token or an error if the token literal does not
77 // denote a valid float64.
78 func (t *Token) Float64Value() (float64, error) {
79 return strconv.ParseFloat(string(t.Lit), 64)
80 }
81
82 // IDValue returns the string representation of an identifier token.
83 func (t *Token) IDValue() string {
84 return string(t.Lit)
85 }
86
87 // Int32Value returns the int32 value of the token or an error if the token literal does not
88 // denote a valid float64.
89 func (t *Token) Int32Value() (int32, error) {
90 if v, err := strconv.ParseInt(string(t.Lit), 10, 64); err != nil {
91 return 0, err
92 } else {
93 return int32(v), nil
94 }
95 }
96
97 // Int64Value returns the int64 value of the token or an error if the token literal does not
98 // denote a valid float64.
99 func (t *Token) Int64Value() (int64, error) {
100 return strconv.ParseInt(string(t.Lit), 10, 64)
101 }
102
103 // UTF8Rune decodes the UTF8 rune in the token literal. It returns utf8.RuneError if
104 // the token literal contains an invalid rune.
105 func (t *Token) UTF8Rune() (rune, error) {
106 r, _ := utf8.DecodeRune(t.Lit)
107 if r == utf8.RuneError {
108 err := fmt.Errorf("Invalid rune")
109 return r, err
110 }
111 return r, nil
112 }
113
114 // StringValue returns the string value of the token literal.
115 func (t *Token) StringValue() string {
116 return string(t.Lit[1 : len(t.Lit)-1])
117 }
118
59119 var TokMap = TokenMap{
60120 typeMap: []string{
61121 "INVALID",