Skip to content

Commit

Permalink
setup: health CRM library setup
Browse files Browse the repository at this point in the history
- feat: add create facility feature

Signed-off-by: Kathurima Kimathi <kathurimakimathi415@gmail.com>
  • Loading branch information
KathurimaKimathi committed Oct 6, 2023
1 parent 12bd8fb commit e309f48
Show file tree
Hide file tree
Showing 17 changed files with 1,862 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .gitguardian.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
all-policies: false
api-url: https://api.gitguardian.com
exit-zero: false
paths-ignore:
- '**/README.md'
- doc/*
- LICENSE
- .gitignore
show-secrets: false
verbose: false
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Update Github actions in workflows
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
34 changes: 34 additions & 0 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Issue/Bug/Feature Request

#### Summary

- [ ] fix: Bug fix for `Add the items tackled here as checklists`
- [x] feat: Completed task
- [ ] chore: Incomplete task
- [ ] test: Sub-task 1

#### What is the current behaviour

- `Describe the current behaviour`

#### What is the expected (Ideal)

- `Describe the current behaviour`


#### Sample logs and/or screenshots

- (Paste any relevant logs - please use code blocks (```) to format console output,
logs, and code as it's very hard to read otherwise.)

#### Steps to reproduce

- (Minimal reproducible test case)

#### Possible fixes

- (If you can, link to the line of code that might be responsible for the problem)

/label ~bug ~reproduced ~needs-investigation
/cc @project-manager
/assign @qa-tester
44 changes: 44 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Review Checklist

[![Bugs](https://img.shields.io/badge/BugFixes-0-red.svg?style=for-the-badge)](https://shields.io/)
[![Features](https://img.shields.io/badge/Features-0-orange?style=for-the-badge)](https://shields.io/)
[![Tests](https://img.shields.io/badge/Tests-0-success.svg?style=for-the-badge)](https://shields.io/)

#### Summary*

- [ ] fix: Bug fix for `Add the items tackled here as checklists`
- [x] feat: Completed task
- [ ] chore: Incomplete task
- [ ] test: Sub-task 1


#### Structure*

- [ ] The Pull Request has a `proper` title that conforms to our [MR title standards](https://gist.github.com/mikepea/863f63d6e37281e329f8)
- [ ] The Pull Request has one commit, and if there are more than one, they should be squashed
- [ ] The commit should have a proper title and a short description
- [ ] The commit must be signed off
- [ ] Unused imports are not present
- [ ] Dead code is not present
- [ ] Ensure dry running library to confirm changes

#### Tests

- [ ] Proper and high quality unit, integration and acceptance(if applicable) tests have been written
- [ ] The coverage threshold should not be lowered

### Sign off*

- [ ] All comments have been resolved by the reviewers
- [ ] Approved by Czar {replace_with_czar_name}
- [ ] Signed off by second reviewer {replace_with_name}
- [ ] Ensure all checks are done before merging :warning:
- [ ] All PRs needs to be signed before merging :warning:

#### N/B:

- Add a checklist if more than one item is done.
- Add screenshots and/or images where necessary
- Indicate any breakages caused in the UI :exclamation:
- Where necessary, indicate which issue the Pull Request solves (Closes #)
- Any new files are updated in the folder structure in the [README](../../README.md)
61 changes: 61 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Test

on: [push]

env:
HEALTH_CRM_AUTH_SERVER_ENDPOINT: ${{ secrets.HEALTH_CRM_AUTH_SERVER_ENDPOINT }}
HEALTH_CRM_CLIENT_ID: ${{ secrets.HEALTH_CRM_CLIENT_ID }}
HEALTH_CRM_CLIENT_SECRET: ${{ secrets.HEALTH_CRM_CLIENT_SECRET }}
HEALTH_CRM_GRANT_TYPE: ${{ secrets.HEALTH_CRM_GRANT_TYPE }}
HEALTH_CRM_USERNAME: ${{ secrets.HEALTH_CRM_USERNAME }}
HEALTH_CRM_PASSWORD: ${{ secrets.HEALTH_CRM_PASSWORD }}
HEALTH_CRM_BASE_URL: ${{ secrets.HEALTH_CRM_BASE_URL }}

jobs:
lint_and_test:
strategy:
fail-fast: true
matrix:
go-version: [1.18.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3.1.0
- name: Install Go
uses: actions/setup-go@v3.3.1
with:
go-version: ${{ matrix.go-version }}

- name: Install Go dependencies
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.37.1
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.13.1
go install honnef.co/go/tools/cmd/staticcheck@2022.1
go install github.com/ory/go-acc@latest
go install github.com/axw/gocov/gocov@latest
go install github.com/kisielk/errcheck@latest
- name: Run lint and test
run: |
staticcheck ./...
go fmt $(go list ./... | grep -v /vendor/)
go vet $(go list ./... | grep -v /vendor/)
errcheck -ignore 'os:.*,' $(go list ./... | grep -v /vendor/)
gosec -exclude=G304,G101 ./...
go-acc -o coverage.txt --ignore generated,cmd ./... -- -timeout 60m
grep -v "generated.go" coverage.txt > coverage.out
go tool cover -html=coverage.out -o coverage.html
gocov convert coverage.out > coverage.json
gocov report coverage.json > coverage_report.txt
tail coverage_report.txt
- name: Install goveralls
env:
GO111MODULE: off
run: go get github.com/mattn/goveralls

- name: Send coverage
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: goveralls -coverprofile=coverage.out -service=github
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.sh
coverage.txt
coverage.out
.gitmessage.txt
.idea/
test_output.txt
coverage.html
coverage.json
coverage_report.txt
.vscode/
venv
44 changes: 44 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Options for analysis running.
run:
skip-dirs:
- pkg/mycarehub/presentation/graph/
linters:
disable-all: true
enable:
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- asciicheck
- bodyclose
- dogsled
- exhaustive
- exportloopref
- gocognit
- goconst
- gofmt
- goheader
- goimports
- gosec
- misspell
- nakedret
- nestif
- noctx
- rowserrcheck
- sqlclosecheck
- unconvert
- unparam
- whitespace
- gocyclo
- golint


linters-settings:
staticcheck:
checks: ["all"]
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: https://github.com/gitguardian/ggshield
rev: v1.11.0
hooks:
- id: ggshield
stages: [commit]
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.0
hooks:
- id: golangci-lint # install https://golangci-lint.run/usage/install/#local-installation
92 changes: 91 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,91 @@
# healthcrm
# healthcrm

![Linting and Tests](https://github.com/savannahghi/healthcrm/actions/workflows/ci.yaml/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/savannahghi/healthcrm/badge.svg?branch=main)](https://coveralls.io/github/savannahghi/healthcrm?branch=main)

# healthcrm Library
healthcrm is a library that abstracts the interaction with SIL's health CRM service.

### Installing it
healthcrm is compatible with modern Go releases in module mode, with Go installed:

```bash
go get -u github.com/savannahghi/healthcrm

```
will resolve and add the package to the current development module, along with its dependencies.

Alternatively the same can be achieved if you use import in a package:

```go
import "github.com/savannahghi/healthcrm"

```
and run `go get` without parameters.

The package name is `healthcrm`


### Developing

The default branch library is `main`

We try to follow semantic versioning ( <https://semver.org/> ). For that reason,
every major, minor and point release should be _tagged_.

```
git tag -m "v0.0.1" "v0.0.1"
git push --tags
```

Continuous integration tests *must* pass on Github CI. Our coverage threshold
is >=80% i.e you *must* keep coverage above 80%.


## Environment variables

In order to run tests, you need to have an `env.sh` file similar to this one:

```bash
# Application settings
export HEALTH_CRM_AUTH_SERVER_ENDPOINT=""
export HEALTH_CRM_CLIENT_ID=""
export HEALTH_CRM_CLIENT_SECRET=""
export HEALTH_CRM_GRANT_TYPE=""
export HEALTH_CRM_USERNAME=""
export HEALTH_CRM_PASSWORD=""
```

This file *must not* be committed to version control.

It is important to _export_ the environment variables. If they are not exported,
they will not be visible to child processes e.g `go test ./...`.

These environment variables should also be set up on github CI environment variable section.

## Contributing ##
I would like to cover the entire GitHub API and contributions are of course always welcome. The
calling pattern is pretty well established, so adding new methods is relatively
straightforward. See [`CONTRIBUTING.md`](CONTRIBUTING.md) for details.

## Versioning ##

In general, enumutils follows [semver](https://semver.org/) as closely as we
can for tagging releases of the package. For self-contained libraries, the
application of semantic versioning is relatively straightforward and generally
understood. We've adopted the following
versioning policy:

* We increment the **major version** with any incompatible change to
non-preview functionality, including changes to the exported Go API surface
or behavior of the API.
* We increment the **minor version** with any backwards-compatible changes to
functionality, as well as any changes to preview functionality in the GitHub
API. GitHub makes no guarantee about the stability of preview functionality,
so neither do we consider it a stable part of the go-github API.
* We increment the **patch version** with any backwards-compatible bug fixes.

## License ##

This library is distributed under the MIT license found in the [LICENSE](./LICENSE)
file.
Loading

0 comments on commit e309f48

Please sign in to comment.