From 6333a57611803d8a2362718b2c7a01f012b00d45 Mon Sep 17 00:00:00 2001 From: Emmanuel Date: Fri, 2 Feb 2024 14:18:32 -0300 Subject: [PATCH] fix makefile (#10) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix makefile * attempt to fix ci workflow * export nats port on docker compose * attempt to fix tests * merge * upgrade deps * move to new runners * minor fix * Install docker compose * Install other version of docker-compose * fix ci * fix ci2 * Update go version * Add submodules check * fix ci * fix dependencies * fix go mod tidy * fix ci2 * fix ci * split unit test in checks ci * fix name tests * fix name tests * add more time to initialize nats * debug * Debug * debug * add nats.conf * debug * add nats cli * debug * debug100 * test * test * debug1023 * debug * Debug * debug * debug * debug * debug12313 * FIX * delete debug code * delete unnecessary config --------- Co-authored-by: Lucas Francisco López Co-authored-by: Juan Leni --- .github/workflows/checks.golang.yml | 24 ++++++-------- .github/workflows/tests.golang.yml | 50 +++++++++++++++++++++++++++++ Makefile | 4 +-- docker-compose.yml | 5 ++- go.mod | 2 -- go.sum | 26 +-------------- nats_config.yaml | 0 znats/common_test.go | 2 +- znats/kv_test.go | 1 - 9 files changed, 67 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/tests.golang.yml create mode 100644 nats_config.yaml diff --git a/.github/workflows/checks.golang.yml b/.github/workflows/checks.golang.yml index b2a9ace..04b3e8f 100644 --- a/.github/workflows/checks.golang.yml +++ b/.github/workflows/checks.golang.yml @@ -13,19 +13,21 @@ jobs: checks: runs-on: zondax-runners container: - image: golang:1.20 + image: golang:1.21 options: --tty - services: - nats: - image: nats:2.9.16 - ports: - - "4222:4222" - - "5530:5530" + steps: - name: Checkout uses: actions/checkout@v3 with: submodules: true + + - name: Install dependencies + run: | + apt-get update + apt-get install -y git build-essential wget curl + apt-get install -y gettext-base + - name: Build run: | git config --global --add safe.directory "*" @@ -36,11 +38,3 @@ jobs: run: | make install-lint make lint - - name: Build - run: make build - - name: Nats server - run: | - docker compose run -T nats& - sleep 5 - - name: Unit tests - run: make test diff --git a/.github/workflows/tests.golang.yml b/.github/workflows/tests.golang.yml new file mode 100644 index 0000000..8ee93e2 --- /dev/null +++ b/.github/workflows/tests.golang.yml @@ -0,0 +1,50 @@ +# +# Generated by @zondax/cli +# +name: Tests + +on: + push: + branches: [main, master, dev] + pull_request: + branches: [main, master, dev] + +jobs: + tests: + runs-on: zondax-runners + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: actions/setup-go@v3 + with: + go-version: "1.20" + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y git build-essential wget curl + sudo apt-get install -y gettext-base + sudo curl -L "https://github.com/docker/compose/releases/download/v2.6.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + + - name: Build + run: | + make build + + - name: Nats server + run: | + docker-compose up -d nats + sleep 10 + + - name: Check nats ports + run: | + sudo apt-get install -y net-tools + netstat -nap | grep 4222 || echo "Nothing on 4222" + + - name: List Docker containers + run: docker ps + + - name: Unit tests + run: make test \ No newline at end of file diff --git a/Makefile b/Makefile index 88e8cf3..f7df434 100644 --- a/Makefile +++ b/Makefile @@ -28,10 +28,10 @@ gitclean: git clean -xfd git submodule foreach --recursive git clean -xfd -install_lint: +install-lint: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin latest -check-modtidy: +mod-tidy-check: go mod tidy git diff --exit-code -- go.mod go.sum diff --git a/docker-compose.yml b/docker-compose.yml index 48b91f4..19e1d8b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,6 +3,9 @@ version: '3.0' services: nats: image: nats:latest + ports: + - "4222:4222" + - "5530:5530" command: "-js -m 5530" volumes: - - ./nats_config.yaml:/root/config.yaml \ No newline at end of file + - ./nats_config.yaml:/root/config.yaml diff --git a/go.mod b/go.mod index 9dcbb30..445fd5b 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,6 @@ require ( ) require ( - github.com/benbjohnson/clock v1.3.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/hashicorp/hcl v1.0.0 // indirect @@ -28,7 +27,6 @@ require ( github.com/spf13/cast v1.6.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/subosito/gotenv v1.6.0 // indirect - go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.18.0 // indirect golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect diff --git a/go.sum b/go.sum index 0ef81c0..6ee48a3 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= -github.com/benbjohnson/clock v1.3.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= @@ -10,8 +8,6 @@ github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM= -github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4= github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -20,18 +16,12 @@ github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0V github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/nats-io/nats.go v1.31.0 h1:/WFBHEc/dOKBF6qf1TZhrdEfTmOZ5JzdJ+Y3m6Y/p7E= -github.com/nats-io/nats.go v1.31.0/go.mod h1:di3Bm5MLsoB4Bx61CBTsxuarI36WbhAwOm8QrW39+i8= github.com/nats-io/nats.go v1.32.0 h1:Bx9BZS+aXYlxW08k8Gd3yR2s73pV5XSoAQUyp1Kwvp0= github.com/nats-io/nats.go v1.32.0/go.mod h1:Ubdu4Nh9exXdSz0RVWRFBbRfrbSxOYd26oF0wkWclB8= -github.com/nats-io/nkeys v0.4.6 h1:IzVe95ru2CT6ta874rt9saQRkWfe2nFj1NtvYSLqMzY= -github.com/nats-io/nkeys v0.4.6/go.mod h1:4DxZNzenSVd1cYQoAa8948QY3QDjrHfcfVADymtkpts= github.com/nats-io/nkeys v0.4.7 h1:RwNJbbIdYCoClSDNY7QVKZlyb/wfT6ugvFCiKy6vDvI= github.com/nats-io/nkeys v0.4.7/go.mod h1:kqXRgRDPlGy7nGaEDMuYzmiJCIAAWDK0IMBtDmGD0nc= github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= -github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pelletier/go-toml/v2 v2.1.1 h1:LWAJwfNvjQZCFIDKWYQaM62NcYeYViCmWIwmOStowAI= github.com/pelletier/go-toml/v2 v2.1.1/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -51,8 +41,6 @@ github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.18.1 h1:rmuU42rScKWlhhJDyXZRKJQHXFX02chSVW1IvkPGiVM= -github.com/spf13/viper v1.18.1/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ= github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -64,27 +52,15 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= -go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= -go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= -go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= -golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= -golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc= golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= -golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA= golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= diff --git a/nats_config.yaml b/nats_config.yaml new file mode 100644 index 0000000..e69de29 diff --git a/znats/common_test.go b/znats/common_test.go index f3191a1..2d6b0a0 100644 --- a/znats/common_test.go +++ b/znats/common_test.go @@ -15,7 +15,7 @@ func setup() { fmt.Println("Setting up nats component ...") var err error natsComponent, err = NewNatsComponent(ConfigNats{ - ServerUrl: "http://0.0.0.0:4222", + ServerUrl: "nats://localhost:4222", CredentialJWT: "", CredentialSeed: "", ResourcePrefixes: prefixes, diff --git a/znats/kv_test.go b/znats/kv_test.go index 6f29527..d681a8c 100644 --- a/znats/kv_test.go +++ b/znats/kv_test.go @@ -25,7 +25,6 @@ func TestCreateKVStore(t *testing.T) { fullBucketName := natsComponent.MapKVStore[bucketNameHandle].fullName want := "data_TST_testnet_testKVStore" assert.Equal(t, fullBucketName, want) - // check if the store exists in nats component if _, ok := natsComponent.MapKVStore[bucketNameHandle]; !ok { t.Fatalf("kv store '%s' no added in natscomponent", bucketNameHandle)