Skip to content

Commit

Permalink
Move v2 implementation to repository root
Browse files Browse the repository at this point in the history
If any further v1 releases are required, they will be made from a
maintenance branch taken from the previous commit.

Signed-off-by: Mark S. Lewis <[email protected]>
  • Loading branch information
bestbeforetoday authored and denyeart committed Jul 22, 2024
1 parent 9fb8918 commit fa18bb8
Show file tree
Hide file tree
Showing 71 changed files with 513 additions and 8,107 deletions.
46 changes: 0 additions & 46 deletions .github/workflows/build.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright the Hyperledger Fabric contributors. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

name: Pull request

on:
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
uses: ./.github/workflows/test.yml

pull-request:
needs: build
name: Pull request success
runs-on: ubuntu-latest
steps:
- run: "true"
2 changes: 1 addition & 1 deletion .github/workflows/schedule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ on:

jobs:
main:
uses: ./.github/workflows/build.yml
uses: ./.github/workflows/test.yml
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright the Hyperledger Fabric contributors. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

name: Test

on:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
- name: Staticcheck
run: make staticcheck
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
- name: Unit test
run: make unit-test
8 changes: 1 addition & 7 deletions .github/workflows/vulnerability-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ on:
jobs:
scan:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target:
- v1
- v2
steps:
- uses: actions/checkout@v4
- name: Set up Go
Expand All @@ -22,4 +16,4 @@ jobs:
go-version: stable
check-latest: true
- name: Scan
run: make scan-${{ matrix.target }}
run: make scan
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
.#*
.*.sw*
/build
cover.out
25 changes: 10 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@

base_dir := $(patsubst %/,%,$(dir $(realpath $(lastword $(MAKEFILE_LIST)))))

v2_dir := $(base_dir)/v2

go_bin_dir := $(shell go env GOPATH)/bin

.PHONY: test
test: lint unit-test

.PHONY: unit-test
unit-test:
cd '$(v2_dir)' && \
go test -timeout 10s -race -coverprofile=cover.out ./...
cd '$(base_dir)' && \
go test -timeout 30s -race -coverprofile=cover.out ./...

.PHONY: generate
generate:
go install github.com/maxbrunsfeld/counterfeiter/v6@latest
cd '$(v2_dir)' && \
cd '$(base_dir)' && \
go generate ./...

.PHONY: lint
Expand All @@ -25,7 +26,7 @@ lint: staticcheck golangci-lint
.PHONY: staticcheck
staticcheck:
go install honnef.co/go/tools/cmd/staticcheck@latest
cd '$(v2_dir)' && \
cd '$(base_dir)' && \
staticcheck -f stylish ./...

.PHONY: install-golangci-lint
Expand All @@ -37,17 +38,11 @@ $(go_bin_dir)/golangci-lint:

.PHONY: golangci-lint
golangci-lint: $(go_bin_dir)/golangci-lint
cd '$(v2_dir)' && \
cd '$(base_dir)' && \
golangci-lint run

.PHONY: scan-v2
scan-v2:
go install golang.org/x/vuln/cmd/govulncheck@latest
cd '$(v2_dir)' && \
govulncheck ./...

.PHONY: scan-v1
scan-v1:
.PHONY: scan
scan:
go install golang.org/x/vuln/cmd/govulncheck@latest
cd '$(base_dir)' && \
govulncheck ./...
11 changes: 0 additions & 11 deletions ci/scripts/install_tools.sh

This file was deleted.

35 changes: 0 additions & 35 deletions ci/scripts/lint.sh

This file was deleted.

8 changes: 0 additions & 8 deletions ci/tools/go.mod

This file was deleted.

24 changes: 0 additions & 24 deletions ci/tools/go.sum

This file was deleted.

13 changes: 0 additions & 13 deletions ci/tools/tools.go

This file was deleted.

9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
module github.com/hyperledger/fabric-chaincode-go
module github.com/hyperledger/fabric-chaincode-go/v2

go 1.21.0

require (
github.com/golang/protobuf v1.5.4
github.com/hyperledger/fabric-protos-go v0.3.3
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.3
github.com/stretchr/testify v1.9.0
google.golang.org/grpc v1.65.0
google.golang.org/protobuf v1.34.1
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
14 changes: 3 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/hyperledger/fabric-protos-go v0.3.3 h1:0nssqz8QWJNVNBVQz+IIfAd2j1ku7QPKFSM/1anKizI=
github.com/hyperledger/fabric-protos-go v0.3.3/go.mod h1:BPXse9gIOQwyAePQrwQVUcc44bTW4bB5V3tujuvyArk=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.3 h1:Xpd6fzG/KjAOHJsq7EQXY2l+qi/y8muxBaY7R6QWABk=
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.3/go.mod h1:2pq0ui6ZWA0cC8J+eCErgnMDCS1kPOEYVY+06ZAK0qE=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
Expand All @@ -34,9 +28,7 @@ google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjr
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
4 changes: 2 additions & 2 deletions pkg/attrmgr/attrmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"errors"
"fmt"

"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-protos-go/msp"
"github.com/hyperledger/fabric-protos-go-apiv2/msp"
"google.golang.org/protobuf/proto"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion pkg/attrmgr/attrmgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"encoding/base64"
"testing"

"github.com/hyperledger/fabric-chaincode-go/pkg/attrmgr"
"github.com/hyperledger/fabric-chaincode-go/v2/pkg/attrmgr"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -78,6 +78,7 @@ func TestIdemixAttrs(t *testing.T) {
assert.NoError(t, err, "Failed to base64 decode creator string")

attrs, err := mgr.GetAttributesFromIdemix(creatorBytes)
assert.NoError(t, err, "GetAttributesFromIdemix")
numAttrs := len(attrs.Names())
assert.True(t, numAttrs == 2, "expecting 2 attributes but found %d", numAttrs)
checkAttr(t, "ou", "org1.department1", attrs)
Expand Down
2 changes: 1 addition & 1 deletion pkg/cid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ All code samples below assume two things:
2. You have added the following import statement to your chaincode.

```golang
import "github.com/hyperledger/fabric-chaincode-go/pkg/cid"
import "github.com/hyperledger/fabric-chaincode-go/v2/pkg/cid"
```

### Getting the client's ID
Expand Down
Loading

0 comments on commit fa18bb8

Please sign in to comment.