Skip to content

Commit

Permalink
Refresh Go Version and Libraries (#21)
Browse files Browse the repository at this point in the history
* 1. update go from 1.17 to 1.22
2. update deprecated libs ioutils, updated to io
3. fix formatting/linter feedback by static check
4. change domain from wallet to bookkeeping, update all imports/names
5. added cron worker for possible routine backup
6. added firebase lib for possible backup to firebase
7. added db dump functionality to support no 5 and 6 above

* update go mod
* update base docker image
  • Loading branch information
sapiderman authored Mar 28, 2024
1 parent 06b9071 commit 2966f15
Show file tree
Hide file tree
Showing 24 changed files with 353 additions and 94 deletions.
10 changes: 5 additions & 5 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM golang:1.17-alpine as builder
LABEL maintainer="https://github.com/hyperjumptech/hyper-wallet"
FROM golang:1.22-alpine as builder
LABEL maintainer="https://github.com/hyperjumptech/bookkeeping"

ENV CGO_ENABLED=0 \
GOOS=linux \
Expand All @@ -22,7 +22,7 @@ RUN adduser \

COPY . .
RUN go mod tidy
RUN go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o wallet-go-img cmd/Main.go
RUN go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o bookkeeping-go-img cmd/Main.go


#############################
Expand All @@ -32,11 +32,11 @@ FROM scratch
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group

COPY --from=builder /build/wallet-go-img /app/
COPY --from=builder /build/bookkeeping-go-img /app/
WORKDIR /app

# Use an unprivileged user.
USER appuser:appuser
EXPOSE 7000

CMD ["/app/wallet-go-img"]
CMD ["/app/bookkeeping-go-img"]
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
db.host=localhost
db.port=3306
db.user=bookkeeping_user
db.password=bookkeeping
db.name=bookkeeping
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
run: go build -v cmd/Main.go

- name: Build docker
run: docker build . --file .docker/Dockerfile -t wallet-go-img:$(date +%s)
run: docker build . --file .docker/Dockerfile -t bookkeeping-go-img:$(date +%s)
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,11 @@ $RECYCLE.BIN/
### ignore images
*-go-img

### logs
bookkeeping*.log
logs/

# End of https://www.toptal.com/developers/gitignore/api/go,visualstudiocode,git

.env
mariadb/
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# hyper-wallet makefile
# bookkeeping makefile

CURRENT_PATH ?= $(shell pwd)
IMAGE_NAME ?= wallet-go-img
IMAGE_NAME ?= bookkeeping-go-img

.PHONY: all test clean build docker

Expand All @@ -14,7 +14,8 @@ clean:
rm -f $(IMAGE_NAME)

lint: build
golint -set_exit_status ./...
go install honnef.co/go/tools/cmd/staticcheck@latest
staticcheck -f stylish ./...

test-short: lint
go test ./... -v -covermode=count -coverprofile=coverage.out -short
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Hyperjump Bookkeeping

Bookkeeping is a generic double entry book keeping and journaling management service. It implements the [acccore](https://github.com/hyperjumptech/acccore) accounting library. The service is intended for any applications where double-entry bookkeeping is required, such as walletsand loyalty programs.
Bookkeeping is a generic double entry book keeping and journaling management service. It implements the [acccore](https://github.com/hyperjumptech/acccore) accounting library. The service is intended for any applications where double-entry bookkeeping is required, such as wallets and loyalty programs.

## building

This project is built on golang. You need golang installed on your system to run. Minimal version is **1.16** since this project uses `go mod` and resource `embedding`.
This project is built on golang. You need golang installed on your system to run. Minimal version is **1.22** since this project uses `go mod` and resource `embedding`.

You can click here for the [golang resource](https://golang.org) and for more information on go and installations.

Expand All @@ -22,7 +22,7 @@ or

## binary generation

`go build -a -o wallet-go-img cmd/Main.go`
`go build -a -o bookkeeping-go-img cmd/Main.go`

or

Expand All @@ -38,7 +38,7 @@ or

## api docs

Open API sepecificaations can be seen by hitting the `/docs` endpoint of the running instance.
Open API specifications can be seen by hitting the `/docs` endpoint of the running instance.
The file swagger.json can be found in `/static/api/spec`

## Admin Dashboard
Expand Down
2 changes: 1 addition & 1 deletion build/azure/doBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
parameters:
- name: imageName
type: string
default: 'wallet-go-img'
default: 'bookkeeping-go-img'
- name: path
type: string
default: './...'
Expand Down
19 changes: 9 additions & 10 deletions build/azure/doTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@ steps:
- script: |
set -ex
go version
go get github.com/jstemmer/go-junit-report
go get github.com/axw/gocov/gocov
go get github.com/AlekSi/gocov-xml
go get golang.org/x/lint/golint
go get github.com/t-yuki/gocover-cobertura
go install github.com/newm4n/goornogo
go install github.com/jstemmer/go-junit-report/v2@latest
go install github.com/axw/gocov/gocov@latest
go install github.com/AlekSi/gocov-xml@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
go install github.com/t-yuki/gocover-cobertura@latest
sudo timedatectl set-timezone Asia/Jakarta
workingDirectory: '$(System.DefaultWorkingDirectory)'
displayName: 'Fetch dependencies'
- script: |
set -ex
/home/vsts/go/bin/golint -set_exit_status ${{ parameters.testPath }}
go test ./... -cover -vet -all -v -short -covermode=count -coverprofile=coverage.out > test_results.txt
set -ex
/home/vsts/go/bin/staticcheck -version
/home/vsts/go/bin/staticcheck ${{ parameters.testPath }}
go test ./... -cover -v -short -covermode=count -coverprofile=coverage.out > test_results.txt
/home/vsts/go/bin/go-junit-report < test_results.txt > report.xml
/home/vsts/go/bin/gocover-cobertura < coverage.out > coverage.xml
/home/vsts/go/bin/goornogo -c 30 -i coverage.out
workingDirectory: '$(System.DefaultWorkingDirectory)'
displayName: 'Run unit test'
Expand Down
27 changes: 8 additions & 19 deletions cmd/Main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,25 @@ import (
"fmt"

"github.com/hyperjumptech/bookkeeping/internal"
log "github.com/sirupsen/logrus"
)

var (
splashScreen = `
███████████████████████████████████████████████████████████████████████████████████████████████████
█░░░░░░██████████░░░░░░█░░░░░░░░░░░░░░█░░░░░░█████████░░░░░░█████████░░░░░░░░░░░░░░█░░░░░░░░░░░░░░█
█░░▄▀░░██████████░░▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀░░█████████░░▄▀░░█████████░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░█
█░░▄▀░░██████████░░▄▀░░█░░▄▀░░░░░░▄▀░░█░░▄▀░░█████████░░▄▀░░█████████░░▄▀░░░░░░░░░░█░░░░░░▄▀░░░░░░█
█░░▄▀░░██████████░░▄▀░░█░░▄▀░░██░░▄▀░░█░░▄▀░░█████████░░▄▀░░█████████░░▄▀░░█████████████░░▄▀░░█████
█░░▄▀░░██░░░░░░██░░▄▀░░█░░▄▀░░░░░░▄▀░░█░░▄▀░░█████████░░▄▀░░█████████░░▄▀░░░░░░░░░░█████░░▄▀░░█████
█░░▄▀░░██░░▄▀░░██░░▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀░░█████████░░▄▀░░█████████░░▄▀▄▀▄▀▄▀▄▀░░█████░░▄▀░░█████
█░░▄▀░░██░░▄▀░░██░░▄▀░░█░░▄▀░░░░░░▄▀░░█░░▄▀░░█████████░░▄▀░░█████████░░▄▀░░░░░░░░░░█████░░▄▀░░█████
█░░▄▀░░░░░░▄▀░░░░░░▄▀░░█░░▄▀░░██░░▄▀░░█░░▄▀░░█████████░░▄▀░░█████████░░▄▀░░█████████████░░▄▀░░█████
█░░▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀▄▀░░█░░▄▀░░██░░▄▀░░█░░▄▀░░░░░░░░░░█░░▄▀░░░░░░░░░░█░░▄▀░░░░░░░░░░█████░░▄▀░░█████
█░░▄▀░░░░░░▄▀░░░░░░▄▀░░█░░▄▀░░██░░▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░█░░▄▀▄▀▄▀▄▀▄▀░░█████░░▄▀░░█████
█░░░░░░██░░░░░░██░░░░░░█░░░░░░██░░░░░░█░░░░░░░░░░░░░░█░░░░░░░░░░░░░░█░░░░░░░░░░░░░░█████░░░░░░█████
███████████████████████████████████████████████████████████████████████████████████████████████████
(c)2021 hyperjumptech wallet service
██████╗ ██████╗ ██████╗ ██╗ ██╗██╗ ██╗███████╗███████╗██████╗ ██╗███╗ ██╗ ██████╗
██╔══██╗██╔═══██╗██╔═══██╗██║ ██╔╝██║ ██╔╝██╔════╝██╔════╝██╔══██╗██║████╗ ██║ ██╔════╝
██████╔╝██║ ██║██║ ██║█████╔╝ █████╔╝ █████╗ █████╗ ██████╔╝██║██╔██╗ ██║ ██║ ███╗
██╔══██╗██║ ██║██║ ██║██╔═██╗ ██╔═██╗ ██╔══╝ ██╔══╝ ██╔═══╝ ██║██║╚██╗██║ ██║ ██║
██████╔╝╚██████╔╝╚██████╔╝██║ ██╗██║ ██╗███████╗███████╗██║ ██║██║ ╚████║ ╚██████╔╝
╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝
(c)2021-2024 hyperjumptech double bookkeeping service
https://github.com/hyperjumptech/bookkeeping/README.md
`
)

func init() {
fmt.Println(splashScreen)
log.Info("initialzing...")
}

// Main entry point
Expand Down
33 changes: 30 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/hyperjumptech/bookkeeping

go 1.17
go 1.22

require (
github.com/AppsFlyer/go-sundheit v0.4.0
Expand All @@ -14,17 +14,34 @@ require (
github.com/sirupsen/logrus v1.8.1
github.com/spf13/viper v1.8.0
github.com/stretchr/testify v1.7.0
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
)

require github.com/snowzach/rotatefilehook v0.0.0-20180327172521-2f64f265f58c
require (
firebase.google.com/go v3.13.0+incompatible
github.com/JamesStewy/go-mysqldump v0.2.2
github.com/mattn/go-colorable v0.1.13
github.com/robfig/cron/v3 v3.0.1
github.com/snowzach/rotatefilehook v0.0.0-20180327172521-2f64f265f58c
google.golang.org/api v0.44.0
)

require (
cloud.google.com/go v0.81.0 // indirect
cloud.google.com/go/firestore v1.1.0 // indirect
cloud.google.com/go/storage v1.10.0 // indirect
github.com/DATA-DOG/go-sqlmock v1.5.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.5 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/jstemmer/go-junit-report v0.9.1 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/pelletier/go-toml v1.9.3 // indirect
github.com/pkg/errors v0.8.1 // indirect
Expand All @@ -35,7 +52,17 @@ require (
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602 // indirect
golang.org/x/text v0.3.8 // indirect
golang.org/x/tools v0.1.12 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
google.golang.org/grpc v1.38.0 // indirect
google.golang.org/protobuf v1.26.0 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading

0 comments on commit 2966f15

Please sign in to comment.