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

Tag calico/go-build with compiler versions #5

Merged
merged 1 commit into from
Dec 3, 2024
Merged
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
38 changes: 38 additions & 0 deletions .github/workflows/create-branch-on-merge.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Create new branch on pull request merge

on:
pull_request:
types:
- closed

jobs:
create-branch:
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'master'
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Generate branch name
id: generate-branch-name
run: |
BRANCH_NAME=$(./generate-version-tag.sh)
echo "Branch name: $BRANCH_NAME"
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT

- name: Create and push new branch (if not exists)
run: |
BRANCH_NAME=${{ steps.generate-branch-name.outputs.branch_name }}
if git ls-remote --heads origin "$BRANCH_NAME" | grep -q "$BRANCH_NAME"; then
echo "Branch $BRANCH_NAME already exists"
else
echo "Create branch $BRANCH_NAME"
git config user.name marvin-tigera
git config user.email marvin@projectcalico.io
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git checkout -b "$BRANCH_NAME"
git push origin "$BRANCH_NAME"
fi
65 changes: 35 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,10 @@ FROM registry.access.redhat.com/ubi8/ubi:latest AS ubi

ARG TARGETARCH

ARG GOLANG_VERSION=1.23.3
ARG GOLANG_SHA256_AMD64=a0afb9744c00648bafb1b90b4aba5bdb86f424f02f9275399ce0c20b93a2c3a8
ARG GOLANG_SHA256_ARM64=1f7cbd7f668ea32a107ecd41b6488aaee1f5d77a66efd885b175494439d4e1ce
ARG GOLANG_SHA256_PPC64LE=e3b926c81e8099d3cee6e6e270b85b39c3bd44263f8d3df29aacb4d7e00507c8
ARG GOLANG_SHA256_S390X=6bd72fcef72b046b6282c2d1f2c38f31600e4fe9361fcd8341500c754fb09c38

ARG CLANG_VERSION=18.1.8
ARG CONTAINERREGISTRY_VERSION=v0.20.2
ARG GO_LINT_VERSION=v1.61.0
ARG K8S_VERSION=v1.30.5
ARG K8S_LIBS_VERSION=v0.30.5
ARG MOCKERY_VERSION=2.46.3
ARG YQ_VERSION=v4.44.5

ARG CALICO_CONTROLLER_TOOLS_VERSION=calico-0.1

Expand Down Expand Up @@ -50,17 +42,24 @@ RUN dnf upgrade -y && dnf install -y \
xz \
zip

# Install yq and copy versions.yaml
RUN curl -sfL https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${TARGETARCH} -o /usr/local/bin/yq && chmod +x /usr/local/bin/yq

COPY versions.yaml /etc/versions.yaml

# Install system dependencies that are not in UBI repos
COPY almalinux/RPM-GPG-KEY-AlmaLinux /etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux
COPY almalinux/almalinux*.repo /etc/yum.repos.d/

RUN dnf --enablerepo=baseos,powertools,appstream install -y \
clang-${CLANG_VERSION} \
RUN set -eux; \
llvm_version=$(yq -r .llvm.version /etc/versions.yaml); \
dnf --enablerepo=baseos,powertools,appstream install -y \
clang-${llvm_version} \
elfutils-libelf-devel \
iproute-devel \
iproute-tc \
libbpf-devel \
llvm-${CLANG_VERSION}
llvm-${llvm_version}

RUN set -eux; \
if [ "${TARGETARCH}" = "amd64" ]; then \
Expand All @@ -72,23 +71,25 @@ RUN dnf clean all

# Install Go official release
RUN set -eux; \
golang_version=$(yq -r .golang.version /etc/versions.yaml); \
golang_checksum=$(yq -r .golang.checksum.sha256.${TARGETARCH} /etc/versions.yaml); \
url=; \
case "${TARGETARCH}" in \
'amd64') \
url="https://dl.google.com/go/go${GOLANG_VERSION}.linux-amd64.tar.gz"; \
sha256="${GOLANG_SHA256_AMD64}"; \
url="https://dl.google.com/go/go${golang_version}.linux-amd64.tar.gz"; \
sha256="${golang_checksum}"; \
;; \
'arm64') \
url="https://dl.google.com/go/go${GOLANG_VERSION}.linux-arm64.tar.gz"; \
sha256="${GOLANG_SHA256_ARM64}"; \
url="https://dl.google.com/go/go${golang_version}.linux-arm64.tar.gz"; \
sha256="${golang_checksum}"; \
;; \
'ppc64le') \
url="https://dl.google.com/go/go${GOLANG_VERSION}.linux-ppc64le.tar.gz"; \
sha256="${GOLANG_SHA256_PPC64LE}"; \
url="https://dl.google.com/go/go${golang_version}.linux-ppc64le.tar.gz"; \
sha256="${golang_checksum}"; \
;; \
's390x') \
url="https://dl.google.com/go/go${GOLANG_VERSION}.linux-s390x.tar.gz"; \
sha256="${GOLANG_SHA256_S390X}"; \
url="https://dl.google.com/go/go${golang_version}.linux-s390x.tar.gz"; \
sha256="${golang_checksum}"; \
;; \
*) echo >&2 "error: unsupported architecture '${TARGETARCH}'"; exit 1 ;; \
esac; \
Expand Down Expand Up @@ -146,9 +147,11 @@ RUN set -eux; \
RUN curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin $GO_LINT_VERSION

# Install necessary Kubernetes binaries used in tests.
RUN curl -sfL https://dl.k8s.io/${K8S_VERSION}/bin/linux/${TARGETARCH}/kube-apiserver -o /usr/local/bin/kube-apiserver && chmod +x /usr/local/bin/kube-apiserver && \
curl -sfL https://dl.k8s.io/release/${K8S_VERSION}/bin/linux/${TARGETARCH}/kubectl -o /usr/local/bin/kubectl && chmod +x /usr/local/bin/kubectl && \
curl -sfL https://dl.k8s.io/${K8S_VERSION}/bin/linux/${TARGETARCH}/kube-controller-manager -o /usr/local/bin/kube-controller-manager && chmod +x /usr/local/bin/kube-controller-manager
RUN set -eux; \
k8s_version=$(yq -r .kubernetes.version /etc/versions.yaml); \
curl -sfL https://dl.k8s.io/v${k8s_version}/bin/linux/${TARGETARCH}/kube-apiserver -o /usr/local/bin/kube-apiserver && chmod +x /usr/local/bin/kube-apiserver && \
curl -sfL https://dl.k8s.io/release/v${k8s_version}/bin/linux/${TARGETARCH}/kubectl -o /usr/local/bin/kubectl && chmod +x /usr/local/bin/kubectl && \
curl -sfL https://dl.k8s.io/v${k8s_version}/bin/linux/${TARGETARCH}/kube-controller-manager -o /usr/local/bin/kube-controller-manager && chmod +x /usr/local/bin/kube-controller-manager

RUN set -eux; \
case "${TARGETARCH}" in \
Expand All @@ -163,7 +166,9 @@ RUN set -eux; \

# Install go programs that we rely on
# Install ginkgo v2 as ginkgo2 and keep ginkgo v1 as ginkgo
RUN go install github.com/onsi/ginkgo/v2/ginkgo@v2.20.2 && mv /go/bin/ginkgo /go/bin/ginkgo2 && \
RUN set -eux; \
k8s_libs_version=$(yq -r .kubernetes.version /etc/versions.yaml | sed 's/^1/0/'); \
go install github.com/onsi/ginkgo/v2/ginkgo@v2.20.2 && mv /go/bin/ginkgo /go/bin/ginkgo2 && \
go install github.com/onsi/ginkgo/ginkgo@v1.16.5 && \
go install github.com/jstemmer/go-junit-report@v1.0.0 && \
go install github.com/mikefarah/yq/v3@3.4.1 && \
Expand All @@ -175,12 +180,12 @@ RUN go install github.com/onsi/ginkgo/v2/ginkgo@v2.20.2 && mv /go/bin/ginkgo /go
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.5.1 && \
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.34.2 && \
go install gotest.tools/gotestsum@v1.12.0 && \
go install k8s.io/code-generator/cmd/client-gen@${K8S_LIBS_VERSION} && \
go install k8s.io/code-generator/cmd/conversion-gen@${K8S_LIBS_VERSION} && \
go install k8s.io/code-generator/cmd/deepcopy-gen@${K8S_LIBS_VERSION} && \
go install k8s.io/code-generator/cmd/defaulter-gen@${K8S_LIBS_VERSION} && \
go install k8s.io/code-generator/cmd/informer-gen@${K8S_LIBS_VERSION} && \
go install k8s.io/code-generator/cmd/lister-gen@${K8S_LIBS_VERSION} && \
go install k8s.io/code-generator/cmd/client-gen@v${k8s_libs_version} && \
go install k8s.io/code-generator/cmd/conversion-gen@v${k8s_libs_version} && \
go install k8s.io/code-generator/cmd/deepcopy-gen@v${k8s_libs_version} && \
go install k8s.io/code-generator/cmd/defaulter-gen@v${k8s_libs_version} && \
go install k8s.io/code-generator/cmd/informer-gen@v${k8s_libs_version} && \
go install k8s.io/code-generator/cmd/lister-gen@v${k8s_libs_version} && \
go install k8s.io/kube-openapi/cmd/openapi-gen@v0.0.0-20241009091222-67ed5848f094 && \
go install mvdan.cc/gofumpt@v0.7.0

Expand Down
12 changes: 3 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,8 @@ else ifeq ($(ARCH),s390)
override LDSONAME=ld64.so.1
endif


VERSION ?= latest

GOBUILD ?= calico/go-build
GOBUILD_IMAGE ?= $(GOBUILD):$(VERSION)
GOBUILD_IMAGE ?= $(GOBUILD):$(shell ./generate-version-tag.sh)
GOBUILD_ARCH_IMAGE ?= $(GOBUILD_IMAGE)-$(ARCH)

BASE ?= calico/base
Expand Down Expand Up @@ -166,8 +163,5 @@ cd:
ifndef CONFIRM
$(error CONFIRM is undefined - run using make <target> CONFIRM=true)
endif
ifndef BRANCH_NAME
$(error BRANCH_NAME is undefined - run using make <target> BRANCH_NAME=var or set an environment variable)
endif
$(MAKE) push-all VERSION=${BRANCH_NAME}
$(MAKE) push-manifest VERSION=${BRANCH_NAME}
$(MAKE) push-all
$(MAKE) push-manifest
18 changes: 18 additions & 0 deletions generate-version-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -e

ver_file="$1"
if [[ -z $ver_file ]]; then
ver_file=versions.yaml
fi

golang_ver=$(yq -r .golang.version "$ver_file")
k8s_ver=$(yq -r .kubernetes.version "$ver_file")
llvm_ver=$(yq -r .llvm.version "$ver_file")

if [[ -z $golang_ver ]] || [[ -z $k8s_ver ]] || [[ -z $llvm_ver ]]; then
exit 1
fi

echo "${golang_ver}-llvm${llvm_ver}-k8s${k8s_ver}"
12 changes: 12 additions & 0 deletions versions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
golang:
version: 1.23.3
checksum:
sha256:
amd64: a0afb9744c00648bafb1b90b4aba5bdb86f424f02f9275399ce0c20b93a2c3a8
arm64: 1f7cbd7f668ea32a107ecd41b6488aaee1f5d77a66efd885b175494439d4e1ce
ppc64le: e3b926c81e8099d3cee6e6e270b85b39c3bd44263f8d3df29aacb4d7e00507c8
s390x: 6bd72fcef72b046b6282c2d1f2c38f31600e4fe9361fcd8341500c754fb09c38
kubernetes:
version: 1.30.5
llvm:
version: 18.1.8
Loading