diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index caea89c..6330b61 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: go-version: 1.15 - name: Build - run: go build -v ./... + run: ./scripts/build - name: Test - run: go test -v ./... + run: ./scripts/test diff --git a/internal/pkg/config/schema.go b/internal/pkg/config/schema.go index bec3b3b..8e571b8 100644 --- a/internal/pkg/config/schema.go +++ b/internal/pkg/config/schema.go @@ -20,7 +20,7 @@ import ( func bindataRead(data []byte, name string) ([]byte, error) { gz, err := gzip.NewReader(bytes.NewBuffer(data)) if err != nil { - return nil, fmt.Errorf("read %q: %v", name, err) + return nil, fmt.Errorf("read %q: %w", name, err) } var buf bytes.Buffer @@ -28,7 +28,7 @@ func bindataRead(data []byte, name string) ([]byte, error) { clErr := gz.Close() if err != nil { - return nil, fmt.Errorf("read %q: %v", name, err) + return nil, fmt.Errorf("read %q: %w", name, err) } if clErr != nil { return nil, err @@ -183,6 +183,9 @@ var _bindata = map[string]func() (*asset, error){ "schemas/manifest.json": schemasManifestJson, } +// AssetDebug is true if the assets were built with the debug flag enabled. +const AssetDebug = false + // AssetDir returns the file names below a certain // directory embedded in the file by go-bindata. // For example if you run go-bindata on data/... and data contains the @@ -224,8 +227,8 @@ type bintree struct { } var _bintree = &bintree{nil, map[string]*bintree{ - "schemas": &bintree{nil, map[string]*bintree{ - "manifest.json": &bintree{schemasManifestJson, map[string]*bintree{}}, + "schemas": {nil, map[string]*bintree{ + "manifest.json": {schemasManifestJson, map[string]*bintree{}}, }}, }} diff --git a/scripts/build b/scripts/build new file mode 100755 index 0000000..7bf10c0 --- /dev/null +++ b/scripts/build @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -euo pipefail + +scripts/make-schema +go build -v ./... diff --git a/scripts/make-schema b/scripts/make-schema index 85c768e..e81f5ef 100755 --- a/scripts/make-schema +++ b/scripts/make-schema @@ -1,3 +1,12 @@ #!/usr/bin/env bash -go-bindata -pkg config -o internal/pkg/config/schema.go schemas/manifest.json +declare gobindata +gobindata="$(which go-bindata)" + +if ! "${gobindata}" -v &>/dev/null; then + gobindata='./go-bindata' + curl --silent --location --output "${gobindata:?}" https://github.com/kevinburke/go-bindata/releases/download/v3.22.0/go-bindata-linux-amd64 + chmod 755 "${gobindata:?}" +fi + +"${gobindata:?}" -pkg config -o internal/pkg/config/schema.go schemas/manifest.json diff --git a/scripts/test b/scripts/test index 7e3fee7..4475af8 100755 --- a/scripts/test +++ b/scripts/test @@ -1,4 +1,5 @@ #!/usr/bin/env bash +set -euo pipefail scripts/make-schema -go test ./... +go test -v ./...