Skip to content

Commit

Permalink
initial work for sandbox plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
edaniszewski committed Jun 21, 2018
1 parent 0b0c71e commit 8f98289
Show file tree
Hide file tree
Showing 14 changed files with 640 additions and 2 deletions.
128 changes: 128 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Defaults for our CircleCI jobs.
defaults: &defaults
working_directory: /go/src/github.com/vapor-ware/sandbox-plugin
docker:
- image: circleci/golang:latest
environment:
IMAGE_NAME: "vaporio/sandbox-plugin"


# Common config for tag-triggered workflows
tag-filters: &tag-filters
filters:
branches:
ignore: /.*/
tags:
only: /^[0-9]*(\.[0-9]*)*(-(\S)*)?$/


# CircleCI Config
version: 2
jobs:

# build
#
# This job is run for all commits. It makes sure that: the source code
# is properly linted, the source code is properly formatted, the source
# can be compiled and built successfully, and the Docker image can be
# built successfully.
#
# This job does not publish any build artifacts.
build:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- v1-vendor-{{ checksum "Gopkg.toml" }}-{{ checksum "Gopkg.lock" }}
- v1-vendor-{{ checksum "Gopkg.toml" }}
- run:
name: Install Vendored Dependencies
command: make dep
- run:
name: Lint
command: make lint
- run:
name: Format
command: |
fmt="$(find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do goimports -d "$file"; done)"
if [ "$fmt" != "" ]; then
echo "$fmt"
exit 1
fi
- run:
name: Build Binary
command: make build
- setup_remote_docker:
docker_layer_caching: true
- run:
name: Build Docker Image
command: make docker
- save_cache:
when: on_success
key: v1-vendor-{{ checksum "Gopkg.toml" }}-{{ checksum "Gopkg.lock" }}
paths:
- vendor/

# release
#
# This job creates a GitHub release draft for the tag that was pushed.
# It generates a changelog for the release and attaches build artifacts
# to the release as well. The release should be manually published on GitHub.
release:
<<: *defaults
steps:
- checkout
- setup_remote_docker:
docker_layer_caching: true
- run:
name: Check Version matches Tag
command: |
v=$(make version)
if [ "$v" != "$CIRCLE_TAG" ]; then
echo "Versions do not match: $v != $CIRCLE_TAG"
exit 1
fi
- run:
name: Install Vendored Dependencies
command: make dep
- run:
name: Building Artifacts
command: make ci-build
- run:
name: Generate Changelog
command: |
tag=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1` || true)
since_tag=$(if [ "${tag}" ]; then echo "--since-tag ${tag}"; fi)
docker pull timfallmk/github-changelog-generator
docker run --name changelog timfallmk/github-changelog-generator \
-u ${CIRCLE_PROJECT_USERNAME} \
-p ${CIRCLE_PROJECT_REPONAME} \
-t ${GITHUB_TOKEN} \
${since_tag}
docker cp changelog:/usr/local/src/your-app/CHANGELOG.md ./
- run:
name: Create Release
command: |
go get -v github.com/tcnksm/ghr
if git describe --exact-match --tags HEAD; then
CIRCLE_TAG=$(git describe --exact-match --tags HEAD)
fi
ghr \
-u ${GITHUB_USER} \
-t ${GITHUB_TOKEN} \
-b "$(cat ./CHANGELOG.md)" \
-replace \
-draft \
${CIRCLE_TAG} build/
workflows:
version: 2
build:
jobs:
- build
- release:
context: vapor-auto
<<: *tag-filters
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
*.dll
*.so
*.dylib
build/

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Vendored Dependencies
vendor/

# IDE files
.idea
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM iron/go:dev as builder
WORKDIR /go/src/github.com/vapor-ware/sandbox-plugin
COPY . .
RUN make build CGO_ENABLED=0


FROM scratch
LABEL maintainer="[email protected]"
COPY --from=builder /go/src/github.com/vapor-ware/sandbox-plugin/build/plugin ./plugin
COPY config/plugin/config.yml /etc/synse/plugin/config/config.yml
COPY config/device/devices.yml /etc/synse/plugin/config/device/devices.yml
EXPOSE 5002
ENTRYPOINT ["./plugin"]
162 changes: 162 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Gopkg.toml example
#
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true


[[constraint]]
name = "github.com/vapor-ware/synse-sdk"
branch = "v1.0"

[prune]
go-tests = true
unused-packages = true
Loading

0 comments on commit 8f98289

Please sign in to comment.