Skip to content
This repository was archived by the owner on Aug 4, 2023. It is now read-only.

Adding linter, .gitignore, godeps, etc #1

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 171 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

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

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

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

9 changes: 9 additions & 0 deletions Godeps/Godeps.json

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

5 changes: 5 additions & 0 deletions Godeps/Readme

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

191 changes: 179 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,185 @@
BINARY_NAME=fedrampup
SHELL := /bin/bash

all: test
REV := $(shell git rev-parse HEAD)
CHANGES := $(shell test -n "$$(git status --porcelain)" && echo '+CHANGES' || true)

fmt:
go fmt
TARGET := fedrampup
VERSION := $(shell cat VERSION)

OS := darwin freebsd linux openbsd
ARCH := 386 amd64
LDFLAGS := -X github.com/ScaleSec/$(TARGET)/local.Revision=$(REV)$(CHANGES)

GPG_SIGNING_KEY :=

.PHONY: \
help \
default \
clean \
clean-artifacts \
clean-releases \
clean-vendor \
tools \
deps \
test \
coverage \
vet \
lint \
imports \
fmt \
env \
build \
build-all \
doc \
release \
package-release \
sign-release \
check \
vendor \
version

all: imports fmt lint vet build

help:
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
@echo ''
@echo 'Available targets are:'
@echo ''
@echo ' help Show this help screen.'
@echo ' clean Remove binaries, artifacts and releases.'
@echo ' clean-artifacts Remove build artifacts only.'
@echo ' clean-releases Remove releases only.'
@echo ' clean-vendor Remove content of the vendor directory.'
@echo ' tools Install tools needed by the project.'
@echo ' deps Download and install build time dependencies.'
@echo ' test Run unit tests.'
@echo ' coverage Report code tests coverage.'
@echo ' vet Run go vet.'
@echo ' lint Run golint.'
@echo ' imports Run goimports.'
@echo ' fmt Run go fmt.'
@echo ' env Display Go environment.'
@echo ' build Build project for current platform.'
@echo ' build-all Build project for all supported platforms.'
@echo ' doc Start Go documentation server on port 8080.'
@echo ' release Package and sing project for release.'
@echo ' package-release Package release and compress artifacts.'
@echo ' sign-release Sign release and generate checksums.'
@echo ' check Verify compiled binary.'
@echo ' vendor Update and save project build time dependencies.'
@echo ' version Display Go version.'
@echo ''
@echo 'Targets run by default are: imports, fmt, lint, vet, and build.'
@echo ''

print-%:
@echo $* = $($*)

clean: clean-artifacts clean-releases
go clean -i ./...
rm -vf \
$(CURDIR)/coverage.* \

build: fmt
go build -o $(BINARY_NAME) -v
clean-artifacts:
rm -Rf artifacts/*

test: fmt
clean-releases:
rm -Rf releases/*

clean-vendor:
find $(CURDIR)/vendor -type d -print0 2>/dev/null | xargs -0 rm -Rf

clean-all: clean clean-artifacts clean-vendor

tools:
go get golang.org/x/tools/cmd/goimports
go get github.com/golang/lint/golint
go get github.com/axw/gocov/gocov
go get github.com/matm/gocov-html
go get github.com/tools/godep
go get github.com/mitchellh/gox

deps:
godep restore

test: deps
go test -v ./...

run: fmt
go build -o $(BINARY_NAME) -v ./...
./$(BINARY_NAME)
go clean
rm -f $(BINARY_NAME)
coverage: deps
gocov test ./... > $(CURDIR)/coverage.out 2>/dev/null
gocov report $(CURDIR)/coverage.out
if test -z "$$CI"; then \
gocov-html $(CURDIR)/coverage.out > $(CURDIR)/coverage.html; \
if which open &>/dev/null; then \
open $(CURDIR)/coverage.html; \
fi; \
fi

vet:
go vet -v ./...

lint:
golint ./...

imports:
goimports -l -w .

fmt:
go fmt ./...

env:
@go env

build: deps
go build -v \
-ldflags "$(LDFLAGS)" \
-o "$(TARGET)" .

build-all: deps
mkdir -v -p $(CURDIR)/artifacts/$(VERSION)
gox -verbose \
-os "$(OS)" -arch "$(ARCH)" \
-ldflags "$(LDFLAGS)" \
-output "$(CURDIR)/artifacts/$(VERSION)/{{.OS}}_{{.Arch}}/$(TARGET)" .
cp -v -f \
$(CURDIR)/artifacts/$(VERSION)/$$(go env GOOS)_$$(go env GOARCH)/$(TARGET) .

doc:
godoc -http=:8080 -index

release: package-release sign-release

package-release:
@test -x $(CURDIR)/artifacts/$(VERSION) || exit 1
mkdir -v -p $(CURDIR)/releases/$(VERSION)
for release in $$(find $(CURDIR)/artifacts/$(VERSION) -mindepth 1 -maxdepth 1 -type d 2>/dev/null); do \
platform=$$(basename $$release); \
pushd $$release &>/dev/null; \
zip $(CURDIR)/releases/$(VERSION)/$(TARGET)_$${platform}.zip $(TARGET); \
popd &>/dev/null; \
done

sign-release:
@test -x $(CURDIR)/releases/$(VERSION) || exit 1
pushd $(CURDIR)/releases/$(VERSION) &>/dev/null; \
shasum -a 256 -b $(TARGET)_* > SHA256SUMS; \
if test -n "$(GPG_SIGNING_KEY)"; then \
gpg --default-key $(GPG_SIGNING_KEY) -a \
-o SHA256SUMS.sign -b SHA256SUMS; \
fi; \
popd &>/dev/null

check:
@test -x $(CURDIR)/$(TARGET) || exit 1
if $(CURDIR)/$(TARGET) --version | grep -qF '$(VERSION)'; then \
echo "$(CURDIR)/$(TARGET): OK"; \
else \
exit 1; \
fi

vendor: deps
godep save

version:
@go version

1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0
7 changes: 0 additions & 7 deletions bin/run

This file was deleted.

Binary file removed fedrampup
Binary file not shown.
Loading