зеркало из https://github.com/Azure/ARO-RP.git
`make ci` support for golang (RP) components (#3558)
* multi staged CI via make and docker build * Improving docker mobilty and performance - fixing file handles during build - removing vendor checks - allowing "dirty" builds - improving cache hits via multiple COPY operations - adding specific dockerignore - removing all makefile dependencies during docker build - adding docs for podman machine sizing - using most recent golang version * Add support for MacOS vendoring Co-authored-by: Kipp Morris <117932707+kimorris27@users.noreply.github.com> --------- Co-authored-by: tschneid <tschneid@redhat.com> Co-authored-by: Kipp Morris <117932707+kimorris27@users.noreply.github.com>
This commit is contained in:
Родитель
d2fd8cf31e
Коммит
50418b65a1
|
@ -0,0 +1,48 @@
|
|||
ARG REGISTRY
|
||||
ARG VERSION
|
||||
|
||||
###############################################################################
|
||||
# builder is responsible for all compilation and validation of the RP
|
||||
###############################################################################
|
||||
FROM ${REGISTRY}/ubi8/go-toolset:1.20.12-5 as builder
|
||||
USER root
|
||||
WORKDIR /app
|
||||
|
||||
# golang config
|
||||
ENV GOPATH=/root/go
|
||||
ENV GOFLAGS="-tags=containers_image_openpgp,exclude_graphdriver_btrfs,exclude_graphdriver_devicemapper"
|
||||
|
||||
# install general build tools
|
||||
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin v1.56.2
|
||||
|
||||
# copy from least changed -> most changed to improve cache hits
|
||||
COPY go.mod go.sum ./
|
||||
COPY vendor vendor
|
||||
COPY swagger swagger
|
||||
COPY .golangci.yml ./
|
||||
COPY hack hack
|
||||
COPY cmd cmd
|
||||
COPY pkg pkg
|
||||
COPY test test
|
||||
|
||||
# lint
|
||||
RUN golangci-lint run --verbose
|
||||
|
||||
# build
|
||||
RUN go generate ./...
|
||||
RUN go build -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=${VERSION}" ./cmd/aro
|
||||
RUN go test ./test/e2e/... -tags e2e,codec.safe -c -ldflags "-X github.com/Azure/ARO-RP/pkg/util/version.GitCommit=${VERSION}" -o e2e.test
|
||||
|
||||
# test
|
||||
RUN ARO_RUN_PKI_TESTS=nope go run gotest.tools/gotestsum@v1.11.0 --format pkgname --junitfile report.xml -- -coverprofile=cover.out ./...
|
||||
RUN hack/fips/validate-fips.sh ./aro
|
||||
|
||||
###############################################################################
|
||||
# final is our slim image with minimal layers and tools
|
||||
###############################################################################
|
||||
FROM ${REGISTRY}/ubi8/ubi-minimal AS final
|
||||
RUN microdnf update && microdnf clean all
|
||||
COPY --from=builder /app/aro /app/e2e.test /usr/local/bin/
|
||||
ENTRYPOINT ["aro"]
|
||||
EXPOSE 2222/tcp 8080/tcp 8443/tcp 8444/tcp 8445/tcp
|
||||
USER 1000
|
|
@ -0,0 +1,13 @@
|
|||
# ignore everything
|
||||
*
|
||||
|
||||
# ...except these
|
||||
!.golangci.yml
|
||||
!cmd
|
||||
!go.mod
|
||||
!go.sum
|
||||
!hack
|
||||
!pkg
|
||||
!swagger
|
||||
!test
|
||||
!vendor
|
10
Makefile
10
Makefile
|
@ -76,6 +76,9 @@ clean:
|
|||
client: generate
|
||||
hack/build-client.sh "${AUTOREST_IMAGE}" 2020-04-30 2021-09-01-preview 2022-04-01 2022-09-04 2023-04-01 2023-07-01-preview 2023-09-04 2023-11-22 2024-08-12-preview
|
||||
|
||||
ci-rp: fix-macos-vendor
|
||||
docker build . -f Dockerfile.ci-rp --ulimit=nofile=4096:4096 --build-arg REGISTRY=$(REGISTRY) --build-arg VERSION=$(VERSION) --no-cache=$(NO_CACHE)
|
||||
|
||||
ci-portal:
|
||||
docker build . -f Dockerfile.ci-portal --build-arg REGISTRY=$(REGISTRY) --no-cache=$(NO_CACHE)
|
||||
|
||||
|
@ -92,6 +95,11 @@ discoverycache:
|
|||
KUBECONFIG=admin.kubeconfig go run ./hack/gendiscoverycache
|
||||
$(MAKE) generate
|
||||
|
||||
fix-macos-vendor:
|
||||
ifeq ($(shell uname -s),Darwin)
|
||||
mv ./vendor/github.com/Microsoft ./vendor/github.com/temp-microsoft && mv ./vendor/github.com/temp-microsoft ./vendor/github.com/microsoft || true
|
||||
endif
|
||||
|
||||
generate:
|
||||
go generate ./...
|
||||
|
||||
|
@ -274,4 +282,4 @@ vendor:
|
|||
install-go-tools:
|
||||
go install ${GOTESTSUM}
|
||||
|
||||
.PHONY: admin.kubeconfig aks.kubeconfig aro az ci-portal clean client deploy dev-config.yaml discoverycache generate image-aro-multistage image-fluentbit image-proxy init-contrib lint-go runlocal-rp proxy publish-image-aro-multistage publish-image-fluentbit publish-image-proxy secrets secrets-update e2e.test tunnel test-e2e test-go test-python vendor build-all validate-go unit-test-go coverage-go validate-fips install-go-tools
|
||||
.PHONY: admin.kubeconfig aks.kubeconfig aro az ci-portal ci-rp clean client deploy dev-config.yaml discoverycache fix-macos-vendor generate image-aro-multistage image-fluentbit image-proxy init-contrib lint-go runlocal-rp proxy publish-image-aro-multistage publish-image-fluentbit publish-image-proxy secrets secrets-update e2e.test tunnel test-e2e test-go test-python vendor build-all validate-go unit-test-go coverage-go validate-fips install-go-tools
|
||||
|
|
|
@ -36,6 +36,15 @@ This document goes through the development dependencies one requires in order to
|
|||
```bash
|
||||
export ARO_PODMAN_SOCKET=unix:///$HOME/.local/share/containers/podman/machine/qemu/podman.sock
|
||||
```
|
||||
|
||||
You will also need to ensure that podman machine has enough resources::
|
||||
|
||||
```bash
|
||||
podman machine stop
|
||||
podman machine rm
|
||||
podman machine init --cpus 4 --memory 5000
|
||||
podman machine start
|
||||
```
|
||||
|
||||
> __NOTE:__ If using Fedora 37+ podman and podman-docker should already be installed and enabled.
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче