Skip to content

Commit

Permalink
Update setup instructions and remove some unused files and instructio…
Browse files Browse the repository at this point in the history
…ns (#2685)

* Update setup instructions

- Update minimum Go version (all setups require at least 1.22)
- `go get` is no longer supported outside a module, update to `go install`
- Update outdated path for payments in README and remove superfluous redirection character
- Update a couple of oudated paths in the `services/skus/README.md` file

* Remove unused docker-refresh-skus and docker compose files

- The Makefile was referencing a yml file that didn't exist.
- The skus README was specifying a command which was previously renamed.

I removed the Makefile entry and instead specify to run `make docker-dev`
and speicfy to run `cd main && go run main.go serve grant` in the
services/sku readme.

* Remove unused docker-refresh-dev and docker compose file

* Add typical development steps

Credit: Kit
  • Loading branch information
bbondy authored Nov 11, 2024
1 parent 890d6f9 commit b2a2a8f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 196 deletions.
8 changes: 0 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,6 @@ docker-dev:
$(eval VAULT_TOKEN = $(shell docker logs grant-vault 2>&1 | grep "Root Token" | tail -1 | cut -d ' ' -f 3 ))
VAULT_TOKEN=$(VAULT_TOKEN) docker compose -f docker-compose.yml -f docker-compose.dev.yml run --rm -p 3333:3333 dev /bin/bash

docker-refresh-dev:
$(eval VAULT_TOKEN = $(shell docker logs grant-vault 2>&1 | grep "Root Token" | tail -1 | cut -d ' ' -f 3 ))
VAULT_TOKEN=$(VAULT_TOKEN) docker compose -f docker-compose.yml -f docker-compose.dev-refresh.yml up -d dev-refresh

docker-refresh-skus:
$(eval VAULT_TOKEN = $(shell docker logs grant-vault 2>&1 | grep "Root Token" | tail -1 | cut -d ' ' -f 3 ))
VAULT_TOKEN=$(VAULT_TOKEN) docker compose -f docker-compose.yml -f docker-compose.skus-refresh.yml up -d skus-refresh

settlement-tools:
$(eval GOOS?=darwin)
$(eval GOARCH?=amd64)
Expand Down
21 changes: 3 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

## Developer Setup

1. [Install Go 1.12](https://golang.org/doc/install) (NOTE: Go 1.10 and earlier will not work!)
1. [Install Go](https://golang.org/doc/install) (Go 1.22 or later)

2. [Install GolangCI-Lint](https://github.com/golangci/golangci-lint#install)

3. `go get -u github.com/hexdigest/gowrap/cmd/gowrap`
3. `go install github.com/hexdigest/gowrap/cmd/gowrap@latest`

4. Clone this repo via `git clone https://github.com/brave-intl/bat-go`

Expand Down Expand Up @@ -54,25 +54,10 @@ You can run all the unit and integration tests by setting the env `TEST_TAGS=int
`make docker-dev`

Services are split up for testing:
`cd /src/grant-server/payment ; > go test --tags=integration -v`
`cd /src/services/payments ; go test --tags=integration -v`

For example in `promotion` you can run specific tests by running a command similar to `go test --tags=integration -run TestControllersTestSuite/TestCreateOrder`.

### Rapid Iteration dev Environment

On occasion it is desirable to re-run the development environment at will quickly. To this
end you can run `make docker-refresh-dev` which will spin up the bat-go services including a
container named `grant-refresh-dev`. If you want to recompile this service you merely need to
perform a `docker restart grant-refresh-dev` and it will recompile and run the service.

A particularly interesting use case is marrying this with utilities such as `fswatch` to watch
for file changes. There is an example below which will restart this `grant-refresh-dev` container
on any file change in the source directory:

```bash
fswatch . | xargs -I {} sh -c '$(docker ps -f "name=grant-refresh-dev" --format "docker restart {{.ID}}")'
```

## Building a prod image using docker

You can build a docker image without installing the go toolchain. Ensure docker
Expand Down
60 changes: 0 additions & 60 deletions docker-compose.dev-refresh.yml

This file was deleted.

24 changes: 18 additions & 6 deletions services/skus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,31 @@

1. Begin with development setup steps 1 through 4 from the [bat-go readme](https://github.com/brave-intl/bat-go/blob/master/README.md)

2. Bring up the SKUs containers locally with ```make docker-refresh-payment```
2. To bring up an environment to exercise the API run `make docker-up-dev`. Once the containers have started, the API will be available at `localhost:3333`. `curl localhost:3333/health-check` will provide a health check

3. View container logs with ```docker logs grant-payment-refresh```

4. SKUs API will be available at localhost:3335
### Development cycle

1. Optionally once the steps are complete run `export TEST_TAGS=integration; make docker-test` to make sure everything builds and all the tests pass

2. Write code and run unit tests locally, no need to bring up the environment for example, to run a unit test in SKUs navigate to the skus directory and run `go test -run TestService_uniqBatchesTxTime`

3. Write integration tests then bring up environment using `make docker-dev` at the command prompt run the specific test you have written for example,

```
cd services && export GODEBUG=x509ignoreCN=0; go test -count=1 -tags integration -timeout 1m -v -run ControllersTestSuite/TestWebhook_Radom ./skus/...
```
4. Optionally before pushing code for review run `export TEST_TAGS=integration; make docker-test` with all new code and make sure it will pass when it hits CI
5. Commit and push
5. Commit code and refresh the containers with ```docker restart grant-payment-refresh```!
### SKU Tokens
SKU Tokens represent cookie-like objects with domain specific caveats, new tokens can be created following the instructions in [this readme](https://github.com/brave-intl/bat-go/tree/master/cmd#create-a-macaroon)
SKU Tokens represent cookie-like objects with domain specific caveats, new tokens can be created following the instructions in [this readme](https://github.com/brave-intl/bat-go/tree/master/tools/macaroon/cmd/README.md)
This is an example of one possible [SKU token](https://github.com/brave-intl/bat-go/blob/brave-together-dev/cmd/macaroon/brave-together/brave_together_paid_dev.yaml):
This is an example of one possible [SKU token](https://github.com/brave-intl/bat-go/blob/master/tools/macaroon/cmd/brave-together/brave_together_paid_dev.yaml)
```
tokens:
Expand Down
59 changes: 0 additions & 59 deletions services/skus/docker-compose.payment-refresh.yml

This file was deleted.

45 changes: 0 additions & 45 deletions services/skus/docker-compose.yml

This file was deleted.

0 comments on commit b2a2a8f

Please sign in to comment.