Skip to content

Commit

Permalink
Merge fix-tests branch from fixtests remote
Browse files Browse the repository at this point in the history
Signed-off-by: Philip-21 <[email protected]>
  • Loading branch information
Philip-21 committed Feb 14, 2024
2 parents 45862d3 + 8f78516 commit 875c779
Show file tree
Hide file tree
Showing 104 changed files with 745 additions and 1,730 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: "1.21"
- name: Compile FireFly CLI
run: make
10 changes: 5 additions & 5 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ jobs:
fail-fast: false
steps:
- name: Checkout FireFly CLI
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: firefly-cli
fetch-depth: 0
- name: Checkout FireFly Core repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: hyperledger/firefly
path: firefly

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: "1.21"

- name: Compile FireFly CLI
working-directory: firefly-cli
Expand All @@ -63,7 +63,7 @@ jobs:
run: ./test/e2e/run.sh

- name: Archive container logs
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
if: always()
with:
name: container-logs-${{ matrix.test-suite }}-${{ matrix.blockchain-provider }}-${{ matrix.database-type }}-${{ matrix.token-provider }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: "1.21"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2021 Kaleido, Inc.
# Copyright © 2024 Kaleido, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
Expand All @@ -22,3 +22,4 @@ dist/
*.iml
.idea/
docs/command_docs
coverage.txt
66 changes: 66 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
run:
tests: false
skip-dirs:
- "mocks"
- "ffconfig"
- "test/e2e"
linters-settings:
golint: {}
gocritic:
enabled-checks: []
disabled-checks:
- regexpMust
revive:
rules:
- name: unused-parameter
disabled: true
gosec:
excludes:
- G306 # Needed file permission for local development
- G601 # Appears not to handle taking an address of a sub-structure, within a pointer to a structure within a loop. Which is valid and safe.
goheader:
values:
regexp:
COMPANY: .*
template: |-
Copyright © {{ YEAR }} {{ COMPANY }}
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
linters:
disable-all: false
disable:
- structcheck
enable:
- dogsled
- errcheck
- goconst
- gocritic
- gocyclo
- gofmt
- goheader
- goimports
- goprintffuncname
- gosec
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- revive
- staticcheck
- stylecheck
- typecheck
- unconvert
- unused
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2022 Kaleido, Inc.
# Copyright © 2024 Kaleido, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
Expand Down
14 changes: 9 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright © 2022 Kaleido, Inc.
# Copyright © 2024 Kaleido, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
Expand All @@ -20,7 +20,9 @@ GITREF := $(shell git rev-parse --short HEAD)
DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LINT := $(GOBIN)/golangci-lint

all: build
all: build lint test tidy
test: deps
$(VGO) test ./internal/... ./pkg/... ./cmd/... -cover -coverprofile=coverage.txt -covermode=atomic -timeout=30s ${TEST_ARGS}
build: ## Builds all go code
cd ff && go build -ldflags="-X 'github.com/hyperledger/firefly-cli/cmd.BuildDate=$(DATE)' -X 'github.com/hyperledger/firefly-cli/cmd.BuildCommit=$(GITREF)'"
install: ## Installs the package
Expand All @@ -31,10 +33,12 @@ lint: ${LINT} ## Checks and reports lint errors

${LINT}:
$(VGO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest


deps:
cd ff && $(VGO) get
help: ## Show this help
@echo 'usage: make [target] ...'
@echo ''
@echo 'targets:'
@egrep '^(.+)\:\ .*##\ (.+)' ${MAKEFILE_LIST} | sed 's/:.*##/#/' | column -t -c 2 -s '#'
@egrep '^(.+)\:\ .*##\ (.+)' ${MAKEFILE_LIST} | sed 's/:.*##/#/' | column -t -c 2 -s '#'
tidy:
$(VGO) mod tidy
2 changes: 1 addition & 1 deletion cmd/accounts.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022 Kaleido, Inc.
// Copyright © 2024 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
2 changes: 1 addition & 1 deletion cmd/accounts_create.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022 Kaleido, Inc.
// Copyright © 2024 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
2 changes: 1 addition & 1 deletion cmd/accounts_list.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022 Kaleido, Inc.
// Copyright © 2024 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
2 changes: 1 addition & 1 deletion cmd/deploy.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022 Kaleido, Inc.
// Copyright © 2024 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
2 changes: 1 addition & 1 deletion cmd/deploy_ethereum.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022 Kaleido, Inc.
// Copyright © 2024 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
2 changes: 1 addition & 1 deletion cmd/deploy_fabric.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022 Kaleido, Inc.
// Copyright © 2024 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
19 changes: 16 additions & 3 deletions cmd/docs.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
/*
Copyright © 2023 Giwa Oluwatobi <[email protected]>
*/
// Copyright © 2024 Giwa Oluwatobi <[email protected]>
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cmd

import (
Expand Down
2 changes: 1 addition & 1 deletion cmd/info.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2021 Kaleido, Inc.
// Copyright © 2024 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
19 changes: 13 additions & 6 deletions cmd/init.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 Kaleido, Inc.
// Copyright © 2024 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -55,7 +55,9 @@ var initCmd = &cobra.Command{
return err
}
if err := stackManager.InitStack(&initOptions); err != nil {
stackManager.RemoveStack()
if err := stackManager.RemoveStack(); err != nil {
return err
}
return err
}
fmt.Printf("Stack '%s' created!\nTo start your new stack run:\n\n%s start %s\n", initOptions.StackName, rootCmd.Use, initOptions.StackName)
Expand Down Expand Up @@ -119,7 +121,10 @@ func initCommon(args []string) error {
}
} else {
for i := 0; i < initOptions.MemberCount; i++ {
randomName := randomHexString(3)
randomName, err := randomHexString(3)
if err != nil {
return err
}
if len(initOptions.OrgNames) <= i || initOptions.OrgNames[i] == "" {
orgNames[i] = fmt.Sprintf("org_%s", randomName)
} else {
Expand Down Expand Up @@ -230,10 +235,12 @@ func validateIPFSMode(input string) error {
return err
}

func randomHexString(length int) string {
func randomHexString(length int) (string, error) {
bytes := make([]byte, length)
rand.Read(bytes)
return hex.EncodeToString(bytes)
if _, err := rand.Read(bytes); err != nil {
return "", err
}
return hex.EncodeToString(bytes), nil
}

func init() {
Expand Down
6 changes: 4 additions & 2 deletions cmd/init_ethereum.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 Kaleido, Inc.
// Copyright © 2024 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -42,7 +42,9 @@ var initEthereumCmd = &cobra.Command{
return err
}
if err := stackManager.InitStack(&initOptions); err != nil {
stackManager.RemoveStack()
if err := stackManager.RemoveStack(); err != nil {
return err
}
return err
}
fmt.Printf("Stack '%s' created!\nTo start your new stack run:\n\n%s start %s\n", initOptions.StackName, rootCmd.Use, initOptions.StackName)
Expand Down
6 changes: 4 additions & 2 deletions cmd/init_fabric.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 Kaleido, Inc.
// Copyright © 2024 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -46,7 +46,9 @@ var initFabricCmd = &cobra.Command{
return err
}
if err := stackManager.InitStack(&initOptions); err != nil {
stackManager.RemoveStack()
if err := stackManager.RemoveStack(); err != nil {
return err
}
return err
}
fmt.Printf("Stack '%s' created!\nTo start your new stack run:\n\n%s start %s\n", initOptions.StackName, rootCmd.Use, initOptions.StackName)
Expand Down
6 changes: 4 additions & 2 deletions cmd/init_tezos.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2023 Kaleido, Inc.
// Copyright © 2024 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -50,7 +50,9 @@ var initTezosCmd = &cobra.Command{
return err
}
if err := stackManager.InitStack(&initOptions); err != nil {
stackManager.RemoveStack()
if err := stackManager.RemoveStack(); err != nil {
return err
}
return err
}
fmt.Printf("Stack '%s' created!\nTo start your new stack run:\n\n%s start %s\n", initOptions.StackName, rootCmd.Use, initOptions.StackName)
Expand Down
2 changes: 1 addition & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2021 Kaleido, Inc.
// Copyright © 2024 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
9 changes: 6 additions & 3 deletions cmd/logs.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
// Copyright © 2021 Kaleido, Inc.
// Copyright © 2024 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package cmd

import (
Expand Down Expand Up @@ -72,7 +73,9 @@ output with the -f flag.`,
if follow {
commandLine = append(commandLine, "-f")
}
docker.RunDockerComposeCommand(ctx, stackManager.Stack.RuntimeDir, commandLine...)
if err := docker.RunDockerComposeCommand(ctx, stackManager.Stack.RuntimeDir, commandLine...); err != nil {
return err
}
} else {
fmt.Println("no logs found - stack has not been started")
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/prompt.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright © 2022 Kaleido, Inc.
// Copyright © 2024 Kaleido, Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
Loading

0 comments on commit 875c779

Please sign in to comment.