Skip to content

Commit

Permalink
Add tests for documentation and contributing info
Browse files Browse the repository at this point in the history
- Added tests in CI for testing the documentation changes not committed

  Closes #14

- Add details for contributing to the project CONTRIBUTING.md

Signed-off-by: Kairo Araujo <kairo@kairo.eti.br>
  • Loading branch information
kairoaraujo committed Sep 28, 2022
1 parent e887bda commit a0599c9
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 20 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/goca-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,3 @@ jobs:

- name: Test
run: make test

# TODO: Implement a more consistent test for the docs issue #14
# - name: Check if API Docs are updated
# run: |
# export PATH=$PATH:$(go env GOPATH)/bin
# cd rest-api
# make doc
# api_docs=$(git diff --name-only | grep ^docs || true )
# if [[ $api_docs != "" ]]; then echo $api_docs; exit 1; fi
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ bin/
count.out
coverage.out
DoNotUseThisCAPATHTestOnly/
docs-test/
38 changes: 38 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
## How to contribute to GoCA

#### **Did you find a bug?**

* **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/kairoaraujo/goca/issues).

* If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/kairoaraujo/goca/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.


#### **Did you write a patch that fixes a bug?**

* Update the documentation and run tests

- Update the documentation

```shell
make docs
```

- Run the tests

```shell
make docs
```

* Open a new GitHub pull request with the patch.

* Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.


#### **Do you intend to add a new feature or change an existing one?**

* Suggest your change in the opening a [new issue](https://github.com/kairoaraujo/goca/issues/new) to discuss the details.


Thanks! :heart:

GoCA Team
23 changes: 15 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
lint:
if [ ! -f ./bin/golangci-lint ] ; \
then \
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.32.2; \
fi;
./bin/golangci-lint run -e gosec
.PHONY: test docs docker-image

test:
go test -covermode=count -coverprofile=count.out -v ./...
go test -covermode=count -coverprofile=count.out -v $(go list ./... | grep -v /docs-test/)

export PATH=$$PATH:`go env GOPATH`/bin; make -C rest-api test-doc
diff docs-test/swagger.json docs/swagger.json
diff docs-test/swagger.yaml docs/swagger.yaml

docs:
export PATH=$$PATH:`go env GOPATH`/bin; make -C rest-api doc

docker-image:
docker build -t goca-rest-api:latest .

.PHONY: lint test mock
lint:
if [ ! -f ./bin/golangci-lint ] ; \
then \
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.49.0; \
fi;
./bin/golangci-lint run -e gosec
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ Certificates Request List (CRL).

**Content**:

- [GoCA Docker Container](#GoCA-Docker-Container)
- [GoCA Package](#GoCA-Package)
- [GoCA HTTP REST API package](#GoCA-HTTP-REST-API)
- [Go Certificate Authority management package](#go-certificate-authority-management-package)
- [GoCA Package](#goca-package)
- [GoCA HTTP REST API](#goca-http-rest-api)
- [GoCA Docker Container](#goca-docker-container)
- [Contributing](#contributing)

## GoCA Package

Expand Down Expand Up @@ -133,3 +135,7 @@ The API Documentation is online available at http://kairoaraujo.github.io/goca/.
More details in [Docker README](DOCKER_README.md).

GoCA Docker Image is available at https://hub.docker.com/r/kairoaraujo/goca/

# Contributing

See [CONTRIBUTING](CONTRIBUTING.md).
5 changes: 5 additions & 0 deletions rest-api/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
.PHONY: check_swag doc test-doc run build

check_swag:
which swag || GO111MODULE=off go get -u github.com/swaggo/swag/cmd/swag

doc: check_swag
swag init --output ../docs/ -parseDependency=true

test-doc:
swag init --output ../docs-test/ -parseDependency=true

run:
go run main.go

Expand Down

0 comments on commit a0599c9

Please sign in to comment.