Skip to content

Commit

Permalink
CONTRIBUTING, DEVELOPING, README.md: better document developing process
Browse files Browse the repository at this point in the history
This patch adds a few notes on how to contribute and develop
for vidx2pidx. It also changes makefile to add the `config`
target that helps configuring local environment.

Signed-off-by: Charles Oliveira <charles.oliveira@linaro.org>
  • Loading branch information
chaws committed Jun 23, 2021
1 parent 628d48f commit fe6e847
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 15 deletions.
25 changes: 25 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
run:
timeout: 10m

# Run linters over integration tests
build-tags:
- integration

linters:
disable-all: true # Disable defaults, then enable the ones we want
enable:
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- bodyclose
- stylecheck
- gosec
- goimports
- gci
37 changes: 37 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Contributing to vidx2pidx
We want to make contributing to this project as easy and transparent as possible, whether it's:

- Reporting a bug
- Discussing the current state of the code
- Submitting a fix
- Proposing new features

## We develop with Github
We use Github to host code, track issues and feature requests, as well as accept pull requests.

## We use [Github flow](https://guides.github.com/introduction/flow/index.html), so all code changes happen through Pull Requests
Pull requests are the best way to propose changes to the codebase (we use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We actively welcome your pull requests:

1. Fork the repo and create your branch from `main`.
2. If you've added code that should be tested, add [tests](https://golang.org/pkg/testing/).
3. If you've changed APIs, update the documentation.
4. Ensure the `make coverage-check` passes, we keep code coverage at 100%.
5. Make sure your code lints.
6. Open a [pull request](https://github.com/Open-CMSIS-Pack/vidx2pidx/pulls)!

## Report bugs using Github's [issues](https://github.com/Open-CMSIS-Pack/vidx2pidx/issues)
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/Open-CMSIS-Pack/vidx2pidx/issues/new).

## Write bug reports with detail, background, and sample code
**Great Bug Reports** tend to have:

- A quick summary and/or background
- Steps to reproduce
- Be specific!
- Give sample code if you can
- What you expected would happen
- What actually happens
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)

## Any contributions you make will be under the Apache 2.0 Software License
In short, when you submit code changes, your submissions are understood to be under the same [Apache 2.0 License](https://choosealicense.com/licenses/apache-2.0/) that covers the project. Feel free to contact the maintainers if that's a concern.
32 changes: 32 additions & 0 deletions DEVELOPING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Developing vidx2pidx

Follow steps below to start developing for `vidx2pidx`:
1. Requirements:
- [Install Make](https://www.gnu.org/software/make/)
- [Install Golang](https://golang.org/doc/install)
- [Install GolangCI-Lint](https://golangci-lint.run/usage/install/#local-installation)

2. Clone the repo:
`$ git clone https://github.com/open-cmsis-pack/vidx2pidx.git`

3. Enter the checked source
`cd vidx2pidx`

4. Configure your local environment
`make config`

5. Make sure all tests are passing
`make test-all`

6. Make sure it builds
`make build/vidx2pidx`

7. Done! You can now start changing the source code, please refer to [contributing guide](CONTRIBUTING.md) to start contributing to the project

# Releasing

If you have rights to push to the `main` branch of this repo, you might be entitled to
make releases. Do that by running:
`make release`

*NOTE*: We use [Semantic Versioning](https://semver.org/) for versioning vidx2pidx.
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,3 @@ Options:
-c, --cachedir specify directory where downloaded pidx and pdsc files are stored (default ./.idxcache)
-f, --force force update – ignore timestamp information
```

## Developing

Make sure to have Go [installed](https://golang.org/doc/install) in your environment.

```bash
$ git clone https://github.com/open-cmsis-pack/vidx2pidx
$ cd vidx2pidx
$ make
```
31 changes: 26 additions & 5 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,27 @@ all:
@echo $$ make $(PROG)
@echo $$ make run
@echo $$ make clean
@echo $$ make config
@echo $$ make release
@echo
@echo Build for different OS's and ARCH's by defining these variables. Ex:
@echo $$ make OS=windows ARCH=amd64 build/$(BIN_NAME).exe \# build for windows 64bits
@echo $$ make OS=darwin ARCH=amd64 build/$(BIN_NAME) \# build for MacOS 64bits
@echo $$ make OS=darwin ARCH=amd64 build/$(BIN_NAME) \# build for MacOS 64bits
@echo
@echo Run tests
@echo $$ make test ARGS="<test args>"
@echo
@echo Release a new version of $(BIN_NAME)
@echo $$ make release
@echo
@echo Clean everything
@echo $$ make clean
@echo
@echo Configure local environment
@echo $$ make config
@echo
@echo Generate a report on code-coverage
@echo $$ make coverage-report

$(PROG): $(SOURCES)
@echo Building project
Expand All @@ -36,7 +50,7 @@ run: $(PROG)
@./$(PROG) $(ARGS) || true

lint:
$(GOLINTER) run
$(GOLINTER) run --config=.golangci.yml

format:
$(GOFORMATTER) -s -w .
Expand All @@ -45,7 +59,7 @@ format-check:
$(GOFORMATTER) -d . | tee format-check.out
test ! -s format-check.out

.PHONY: test release
.PHONY: test release config
test:
TESTING=1 go test $(ARGS)

Expand All @@ -60,8 +74,15 @@ coverage-check:
tail -n +2 cover.out | grep -v -e " 1$$" | grep -v main.go | tee coverage-check.out
test ! -s coverage-check.out

release: # test-all build/vidx2pidx build/vidx2pidx.exe
release: test-all build/vidx2pidx
@./scripts/release


config:
@echo "Configuring local environment"
@go version 2>/dev/null || echo "Need Golang: https://golang.org/doc/install"
@golangci-lint version 2>/dev/null || echo "Need GolangCi-Lint: https://golangci-lint.run/usage/install/#local-installation"

# Install pre-commit hooks
cp scripts/pre-commit .git/hooks/pre-commit
clean:
rm -rf build/*
4 changes: 4 additions & 0 deletions scripts/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

make lint
make format-check

0 comments on commit fe6e847

Please sign in to comment.