Skip to content

Commit

Permalink
Merge pull request #30 from moul/dev/moul/new-style
Browse files Browse the repository at this point in the history
chore: update repo style to match golang-repo-template
  • Loading branch information
moul authored Aug 26, 2019
2 parents 9ab1188 + c78cc14 commit f2cc0ff
Show file tree
Hide file tree
Showing 8 changed files with 622 additions and 25 deletions.
55 changes: 46 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,52 @@
version: 2
jobs:
build:
version: 2.1

executors:
golang:
working_directory: /go/src/moul.io/graphman
docker:
- image: circleci/golang:1.12
working_directory: /go/src/moul.io/graphman
environment:
GO111MODULE: "on"

docker:
docker:
- image: docker:18.06.3-ce-git

orbs:
codecov: codecov/codecov@1.0.5
moul: moul/build@1.5.0
retry: moul/retry@0.6.0
docker: circleci/docker@0.5.13
#dl: moul/dl@1.7.0
tools: gotest/tools@0.0.10

jobs:
go-build:
executor: golang
steps:
- checkout
- retry/install
- tools/mod-download
- tools/mod-tidy-check
- run: retry -m 3 make install
- run: retry -m 3 make unittest
- moul/install_golangci-lint
- run: PATH=$PATH:$(pwd)/bin retry -m 3 make lint
- codecov/upload:
file: coverage.txt

docker-build:
executor: docker
steps:
- checkout
- run: go mod download
- run: make install
- run: make test
- run: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.15.0
- run: PATH=$PATH:$(pwd)/bin make lint
- setup_remote_docker:
docker_layer_caching: true
- docker/build:
image: moul/graphman
#- docker/dockerlint

workflows:
main:
jobs:
- go-build
- docker-build
35 changes: 35 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
##
## Specific to .dockerignore
##

.git/
Dockerfile
contrib/

##
## Common with .gitignore
##

# Temporary files
*~
*#
.#*

# Vendors
node_modules/
vendor/

# Binaries for programs and plugins
dist/
gin-bin
*.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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ web/pertify/examples.js
*~
*#
.#*
covrage.txt

# Vendors
node_modules/
Expand Down
76 changes: 76 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at m+coc-report@42.am. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org

For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
58 changes: 43 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,24 +1,44 @@
.PHONY: test
test:
set -e; for dir in `find . -type f -name "go.mod" | sed -r 's@/[^/]+$$@@' | sort | uniq`; do \
(set -xe; cd $$dir; go test -v -cover -race ./...); \
done

.PHONY: tidy-all
tidy-all:
for file in `find . -name go.mod`; do (dir=`dirname $$file`; set -xe; cd $$dir && go mod tidy); done

web/pertify/examples.js: $(wildcard ./examples/pertify/*.yml)
@# go get moul.io/fs-bundler
cd examples/pertify; fs-bundler --format=js --callback=examples *.yml > ../../$@
GO ?= go
DOCKER_IMAGE ?= moul/graphman

.PHONY: install
install:
cd cmd/pertify; go install
cd cmd/pertify; $(GO) install .

.PHONY: test
test: unittest lint tidy

.PHONY: unittest
unittest:
echo "" > /tmp/coverage.txt
set -e; for dir in `find . -type f -name "go.mod" | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \
cd $$dir; \
$(GO) test -mod=readonly -v -cover -coverprofile=/tmp/profile.out -covermode=atomic -race ./...; \
if [ -f /tmp/profile.out ]; then \
cat /tmp/profile.out >> /tmp/coverage.txt; \
rm -f /tmp/profile.out; \
fi); done
mv /tmp/coverage.txt .

.PHONY: lint
lint:
golangci-lint run --verbose ./...
set -e; for dir in `find . -type f -name "go.mod" | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \
cd $$dir; \
golangci-lint run --verbose ./...; \
); done

.PHONY: tidy
tidy:
set -e; for dir in `find . -type f -name "go.mod" | sed 's@/[^/]*$$@@' | sort | uniq`; do ( set -xe; \
cd $$dir; \
$(GO) mod tidy; \
); done



web/pertify/examples.js: $(wildcard ./examples/pertify/*.yml)
@# go get moul.io/fs-bundler
cd examples/pertify; fs-bundler --format=js --callback=examples *.yml > ../../$@

.PHONY: release
release:
Expand All @@ -45,3 +65,11 @@ sam-local: lambda-build
.PHONY: _netlify-deps
_netlify_deps:
cd; go get moul.io/fs-bundler

.PHONY: docker
docker:
docker build \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
--build-arg VERSION=`git describe --tags --always` \
-t $(DOCKER_IMAGE) .
Loading

0 comments on commit f2cc0ff

Please sign in to comment.