Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup repo for Prow builds of golang cli #274

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .ci-operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build_root_image:
name: release
namespace: openshift
tag: golang-1.22
13 changes: 13 additions & 0 deletions Containerfile-ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM registry.ci.openshift.org/openshift/release:golang-1.22

WORKDIR /src
COPY . .
RUN make ci-go_build

FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
LABEL io.openshift.managed.name="ocm-container" \
io.openshift.managed.description="OSD related command line utilities"

COPY --from=0 /src/dist/ocm-container_linux_amd64_v1/ocm-container /bin/ocm-container

ENTRYPOINT ["bin/ocm-container"]
27 changes: 17 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export CGO_ENABLED=0

GOLANGCI_LINT_VERSION=v1.51.2
GORELEASER_VERSION=v1.24.0
.PHONY: download-goreleaser
download-goreleaser:
GOBIN=${BASE_DIR}/bin/ go install github.com/goreleaser/goreleaser@${GORELEASER_VERSION}

# TODO: Setup token for goreleaser
export GITHUB_TOKEN?=

Expand All @@ -47,10 +51,6 @@ checkEnv:
@test "${CONTAINER_ENGINE}" != "" || (echo "CONTAINER_ENGINE must be defined" && exit 1)
@${CONTAINER_ENGINE} version || (echo "CONTAINER_ENGINE must be installed and in PATH" && exit 1)

.PHONY: init
init:
bash init.sh

.PHONY: build
build:
@${CONTAINER_ENGINE} build $(BUILD_ARGS) -t $(IMAGE_NAME):$(TAG) .
Expand Down Expand Up @@ -106,8 +106,12 @@ tag-n-push: registry-login tag push

# Golang-related
.PHONY: go_build
go_build:
mod fmt lint test build_snapshot
go_build: mod fmt lint test build-snapshot

# CI build containers don't include goreleaser by default,
# so they need to get it first, and then run the build
.PHONY: ci-go_build
ci-build: download-goreleaser go_build

.PHONY: build_binary
build_binary:
Expand All @@ -116,6 +120,7 @@ build_binary:
.PHONY: mod
mod:
go mod tidy
@git diff --exit-code -- go.mod

.PHONY: test
test:
Expand All @@ -127,11 +132,11 @@ coverage:
hack/codecov.sh

.PHONY: lint
lint:
$(GOPATH)/bin/golangci-lint run --timeout 5m
lint:
golangci-lint run --timeout 5m

.PHONY: release
release:
release:
goreleaser release --clean

.PHONY: build-snapshot
Expand All @@ -140,7 +145,9 @@ build-snapshot:

.PHONY: fmt
fmt:
gofmt -s -l -w cmd pkg tests
@echo "gofmt"
@gofmt -w -s .
@git diff --exit-code .

.PHONY: clean
clean:
Expand Down