Skip to content

Commit

Permalink
refactor codebase with urfave/cli (#120)
Browse files Browse the repository at this point in the history
* clean

* load datadir with resources and start compose

* start --liquid

* check if is running already

* Add rpc command

* Add logs and faucet commands

* Add mint command

* Add push command

* Move state into dedicated pkg

* less code for isRunning check

* Add --ci flag to start command

* Add NIGIRI_DATADIR env var

* add update command

* Update readme, makefile and goreleaser

* update test gh action

* skip tests

* print endpoint in start command

* Add a default network to docker compose file.

Containers started through this docker compose file will be in this isolated network.
Note: the minimum version for the docker compose file format is 3.5 which introduces `name` for networks. This file format requires a docker engine version of 17.12.0+.

* add prerelease: auto

* makefile: release commands

* go version

* use global flag --datadir for the folder

* wrap datadir in variable

* use single compose file & move state to internal

* remove unused state keys

* return err in test

* docker-compose: use latest version

* print endpoint of services based on --liquid flag

Co-authored-by: Philipp Hoenisch <[email protected]>
  • Loading branch information
tiero and bonomat authored Aug 6, 2021
1 parent e385558 commit 70e22ba
Show file tree
Hide file tree
Showing 55 changed files with 1,366 additions and 2,670 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/.git/
/.git/
32 changes: 0 additions & 32 deletions .drone.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15.x
go-version: 1.16.x

- name: Cache Go modules
uses: actions/cache@v1
Expand Down
20 changes: 15 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,23 @@ jobs:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.x
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v2
id: go
with:
go-version: 1.16.x

- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Cache Go modules
uses: actions/cache@v1
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Get dependencies
run: go get -v -t -d ./...
Expand All @@ -25,5 +36,4 @@ jobs:
run: |
make fmt
make install
sudo chmod -R 777 .
make test-ci
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

vendor/
build/
dist/
dist/
21 changes: 13 additions & 8 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
builds:
- main: ./cli/main.go
- main: ./cmd/nigiri
ldflags:
- -s -w -X github.com/vulpemventures/nigiri/cli/cmd.version={{.Version}} -X github.com/vulpemventures/nigiri/cli/cmd.commit={{.Commit}} -X github.com/vulpemventures/nigiri/cli/cmd.date={{.Date}}
- -s -X 'main.version={{.Version}}' -X 'main.commit={{.Commit}}' -X 'main.date={{.Date}}'
env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64

checksum:
name_template: 'checksums.txt'
name_template: "checksums.txt"

snapshot:
name_template: "{{ .Tag }}-next"

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- "^docs:"
- "^test:"
archives:
-
format: binary
name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
- format: binary
name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"

release:
prerelease: auto
26 changes: 12 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
.PHONY: install build release dry-release clean cov fmt help vet test
.PHONY: install clean build release dry-release cov fmt help vet test

## install: installs dependencies
install:
export GO111MODULE=on
chmod u+x ./scripts/install
./scripts/install
go mod download
go mod tidy

## build: build binary for ARM
## clean: cleans the binary
clean:
@echo "Cleaning..."
go clean

## build: build binary
build:
export GO111MODULE=on
chmod u+x ./scripts/build
./scripts/build

## release: build and upload binaries to Github Releases
release:
goreleaser

## dry-release: build and test goreleaser
dry-release:
goreleaser --snapshot --skip-publish --rm-dist

## clean: cleans the binary
clean:
@echo "Cleaning..."
export GO111MODULE=on
chmod u+x ./scripts/clean
./scripts/clean

## help: prints this help message
help:
@echo "Usage: \n"
Expand All @@ -46,7 +44,7 @@ test: clean install
go test -v -count=1 -race ./...

## test-ci: runs travis tests
test-ci:
test-ci: clean
@echo "Testing..."
go test -short -v ./...

Expand Down
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ It offers a [JSON HTTP proxy passtrough](https://github.com/vulpemventures/nigir

You can have Elements too with the `--liquid` flag.

Are you looking to spin-up Nigiri in Travis or Github Action? Look [here](https://github.com/vulpemventures/nigiri-travis)


# No time to make a Nigiri yourself?
## Pre-built binary
Expand Down Expand Up @@ -51,7 +49,6 @@ $ nigiri rpc --liquid getnewaddress "" "bech32"
el1qqwwx9gyrcrjrhgnrnjq9dq9t4hykmr6ela46ej63dnkdkcg8veadrvg5p0xg0zd6j3aug74cv9m4cf4jslwdqnha2w2nsg9x3
```


# Make from scratch
## Utensils

Expand Down Expand Up @@ -83,14 +80,11 @@ $ git clone https://github.com/vulpemventures/nigiri.git
$ make install
```

This will create `~/.nigiri` copying there the `{bitcoin|elements}.conf` you can modify.

* Build binary

```
# MacOSX
$ make build-mac
# Linux
$ make build-linux
$ make build
```

Done! You should be able to find the binary in the local `./build` folder. Give it permission to execute and move/rename into your PATH.
Expand Down Expand Up @@ -187,6 +181,21 @@ $ nigiri rpc --liquid getnewaddress "" "bech32"
el1qqwwx9gyrcrjrhgnrnjq9dq9t4hykmr6ela46ej63dnkdkcg8veadrvg5p0xg0zd6j3aug74cv9m4cf4jslwdqnha2w2nsg9x3
```

* Run in headless mode (without Esplora)
If you are looking to spin-up Nigiri in Travis or Github Action you can use the `--ci` flag.

```
$ nigiri start --ci [--liquid]
```


* Update the docker images

```
$ nigiri update
```




Nigiri uses the default directory `~/.nigiri` to store configuration files and docker-compose files.
Expand Down
120 changes: 0 additions & 120 deletions cli/cmd/faucet.go

This file was deleted.

Loading

0 comments on commit 70e22ba

Please sign in to comment.