Skip to content

Commit e4dd168

Browse files
Initial Github Action Changes
Signed-off-by: Muthu <muthu.sundaravadivel@in.ibm.com>
1 parent 8d4401c commit e4dd168

File tree

3 files changed

+153
-0
lines changed

3 files changed

+153
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#
2+
# Copyright contributors to the Hyperledger Fabric Operator project
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at:
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
name: Chaincode Builder Image Build and Checks
20+
21+
on:
22+
push:
23+
branches: [main]
24+
pull_request:
25+
branches: [main]
26+
workflow_dispatch:
27+
28+
env:
29+
GO_VER: "1.24"
30+
GOPROXY: "https://proxy.golang.org,direct" # Bypass all proxies to avoid TLS issues
31+
GO111MODULE: on # Ensure module-aware mode
32+
jobs:
33+
build-image:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- uses: actions/checkout@v4
37+
- name: Set up go
38+
uses: actions/setup-go@v5
39+
with:
40+
go-version: ${{ env.GO_VER }}
41+
- name: Ensure Go is in PATH
42+
run: |
43+
echo "GOPATH: $GOPATH"
44+
echo "PATH: $PATH"
45+
- name: Check Go version
46+
run: |
47+
echo "*********************Go version:***************************"
48+
go version
49+
echo "************************************************************"
50+
- name: unit-tests
51+
run: go test `go list ./... | grep -v integration`
52+
- name: checks
53+
run: make checks
54+
- name: gosec
55+
run: make go-sec
56+
- name: build
57+
run: make image
58+

.github/workflows/image.build.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build and Push Chaincode Builder image
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
jobs:
9+
image:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
14+
- name: Build
15+
run: |
16+
scripts/install-tools.sh
17+
make image
18+
- name: Push
19+
run: |
20+
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
21+
make image-push image-push-latest

Makefile

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#
2+
# Copyright contributors to the Hyperledger Fabric Operator project
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at:
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
20+
IMAGE ?= ghcr.io/hyperledger-labs/chaincode-builder
21+
TAG ?= $(shell git rev-parse --short HEAD)
22+
ARCH ?= $(shell go env GOARCH)
23+
BRANCH ?= $(shell git branch --show-current)
24+
DOCKER_IMAGE_REPO ?= ghcr.io
25+
REGISTRY ?= $(DOCKER_IMAGE_REPO)/ibp-golang
26+
GO_VER ?= 1.24.3
27+
BUILD_DATE = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
28+
GOOS ?= $(shell go env GOOS)
29+
30+
31+
BUILD_ARGS=--build-arg ARCH=$(ARCH)
32+
BUILD_ARGS+=--build-arg REGISTRY=$(REGISTRY)
33+
BUILD_ARGS+=--build-arg BUILD_ID=$(TAG)
34+
BUILD_ARGS+=--build-arg BUILD_DATE=$(BUILD_DATE)
35+
BUILD_ARGS+=--build-arg GO_VER=$(GO_VER)
36+
37+
38+
.PHONY: build login
39+
40+
int-tests:
41+
@ginkgo -v ./integration
42+
43+
build:
44+
GOOS=$(GOOS) GOARCH=$(ARCH) go build -o build/chaincode-builder ./cmd/ibp-builder
45+
GOOS=$(GOOS) GOARCH=$(ARCH) go build -o build/chaincode-builder-client ./cmd/ibp-builder-client
46+
47+
image: login
48+
@go mod vendor
49+
docker build --rm . -f Dockerfile $(BUILD_ARGS) -t $(IMAGE):$(TAG)-$(ARCH)
50+
docker tag $(IMAGE):$(TAG)-$(ARCH) $(IMAGE):latest-$(ARCH)
51+
52+
image-nologin:
53+
@go mod vendor
54+
docker build --rm . -f Dockerfile $(BUILD_ARGS) -t $(IMAGE):$(TAG)-$(ARCH)
55+
docker tag $(IMAGE):$(TAG)-$(ARCH) $(IMAGE):latest-$(ARCH)
56+
57+
login:
58+
echo $(DOCKER_PASSWORD) | docker login -u $(DOCKER_USERNAME) --password-stdin $(DOCKER_IMAGE_REPO)
59+
60+
image-push: login
61+
docker push $(IMAGE):$(TAG)-$(ARCH)
62+
63+
unit-tests:
64+
go test `go list ./... | grep -v integration`
65+
66+
gosec:
67+
@scripts/go-sec.sh
68+
69+
checks: license
70+
@scripts/checks
71+
72+
.PHONY: license
73+
license:
74+
@scripts/check-license.sh

0 commit comments

Comments
 (0)