From 61d715d07a1ebb1c69b19906a50dc63e9c838317 Mon Sep 17 00:00:00 2001 From: Brad Davidson <brad.davidson@rancher.com> Date: Wed, 25 Sep 2024 22:43:43 +0000 Subject: [PATCH] Re-add arm support and fix target arch for non-amd64 platforms Signed-off-by: Brad Davidson <brad.davidson@rancher.com> --- .github/workflows/pull-request.yaml | 2 +- .github/workflows/release.yaml | 4 ++-- Dockerfile.dapper | 2 +- scripts/build-controller | 2 +- scripts/build-e2e-tests | 2 +- scripts/package-controller | 2 +- scripts/package-e2e-tests | 20 +++++++++++--------- scripts/validate | 4 ++-- 8 files changed, 20 insertions(+), 18 deletions(-) diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index a558406b..b2637cb1 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -17,7 +17,7 @@ jobs: strategy: matrix: os: [linux] - arch: [amd64, arm64] + arch: [amd64, arm64, arm] steps: - name: Add Git run: apk add -U git diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a4586cdc..20a27a6d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -21,7 +21,7 @@ jobs: strategy: matrix: os: [linux] - arch: [amd64, arm64] + arch: [amd64, arm64, arm] steps: - name: Add Git run: apk add -U git @@ -138,4 +138,4 @@ jobs: tags: rancher/system-upgrade-controller:${{ env.TAG }} file: package/Dockerfile target: controller - platforms: linux/amd64, linux/arm64 + platforms: linux/amd64, linux/arm64, linux/arm diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 9fbdd3c1..4225b27d 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -17,7 +17,7 @@ RUN if [ "${ARCH:-$(go env GOARCH)}" = "amd64" ]; then \ chmod +x /usr/local/bin/docker-compose; \ fi RUN mkdir -p /usr/local/lib/docker/cli-plugins; \ - curl -o /usr/local/lib/docker/cli-plugins/docker-buildx -fsSL "https://github.com/docker/buildx/releases/download/v0.16.2/buildx-v0.16.2.linux-${ARCH}"; \ + curl -o /usr/local/lib/docker/cli-plugins/docker-buildx -fsSL "https://github.com/docker/buildx/releases/download/v0.17.1/buildx-v0.17.1.linux-amd64"; \ chmod +x /usr/local/lib/docker/cli-plugins/docker-buildx ENV DAPPER_ENV REPO TAG DRONE_TAG ENV DAPPER_SOURCE /go/src/github.com/rancher/system-upgrade-controller/ diff --git a/scripts/build-controller b/scripts/build-controller index f651bb3b..bb110e7d 100755 --- a/scripts/build-controller +++ b/scripts/build-controller @@ -9,4 +9,4 @@ mkdir -p bin [ "$(uname)" != "Darwin" ] && LINKFLAGS="-extldflags -static -s" echo "Building $PKG ..." VERSIONFLAGS="-X ${PKG}/pkg/version.Version=${VERSION} -X ${PKG}/pkg/version.GitCommit=${COMMIT:0:8}" -CGO_ENABLED=0 go build -ldflags "$VERSIONFLAGS $LINKFLAGS" -o bin/system-upgrade-controller +CGO_ENABLED=0 GOARCH=$ARCH go build -ldflags "$VERSIONFLAGS $LINKFLAGS" -o bin/system-upgrade-controller diff --git a/scripts/build-e2e-tests b/scripts/build-e2e-tests index 8dbac088..dfeff5d5 100755 --- a/scripts/build-e2e-tests +++ b/scripts/build-e2e-tests @@ -9,4 +9,4 @@ mkdir -p bin [ "$(uname)" != "Darwin" ] && LINKFLAGS="-extldflags -static -s" echo "Building $PKG/e2e ..." VERSIONFLAGS="-X ${PKG}/pkg/version.Version=${VERSION} -X ${PKG}/pkg/version.GitCommit=${COMMIT:0:8}" -CGO_ENABLED=0 go test -c -ldflags "$VERSIONFLAGS $LINKFLAGS" -o bin/system-upgrade-controller.test ./e2e/suite/... +CGO_ENABLED=0 GOARCH=$ARCH go test -c -ldflags "$VERSIONFLAGS $LINKFLAGS" -o bin/system-upgrade-controller.test ./e2e/suite/... diff --git a/scripts/package-controller b/scripts/package-controller index 42ce638d..7f992415 100755 --- a/scripts/package-controller +++ b/scripts/package-controller @@ -6,7 +6,7 @@ source $(dirname $0)/version cd $(dirname $0)/.. docker buildx build \ - --build-arg TARGETARCH=${ARCH} \ + --platform linux/${ARCH} \ --build-arg REPO=${REPO} \ --build-arg TAG=${TAG} \ --build-arg VERSION=${VERSION} \ diff --git a/scripts/package-e2e-tests b/scripts/package-e2e-tests index 2dc3142c..3972cd0e 100755 --- a/scripts/package-e2e-tests +++ b/scripts/package-e2e-tests @@ -5,8 +5,12 @@ source $(dirname $0)/version cd $(dirname $0)/.. +if [ "$ARCH" != "amd64" ]; then + exit 0 +fi + docker buildx build \ - --build-arg TARGETARCH=${ARCH} \ + --platform linux/${ARCH} \ --build-arg REPO=${REPO} \ --build-arg TAG=${TAG} \ --build-arg VERSION=${VERSION} \ @@ -24,11 +28,9 @@ docker image save --output ./dist/artifacts/system-upgrade-controller-e2e-tests- echo ${REPO}/system-upgrade-controller:${TAG}-e2e-tests >> ./dist/images.txt echo Built ${REPO}/system-upgrade-controller:${TAG}-e2e-tests -if [ "$ARCH" = "amd64" ]; then - sonobuoy gen plugin \ - --format=junit \ - --image ${REPO}/system-upgrade-controller:${VERSION}-e2e-tests \ - --name system-upgrade-controller \ - --type job \ - > ./dist/artifacts/system-upgrade-controller-e2e-tests.yaml -fi +sonobuoy gen plugin \ + --format=junit \ + --image ${REPO}/system-upgrade-controller:${VERSION}-e2e-tests \ + --name system-upgrade-controller \ + --type job \ +> ./dist/artifacts/system-upgrade-controller-e2e-tests.yaml diff --git a/scripts/validate b/scripts/validate index 850c72f8..f5db1b8e 100755 --- a/scripts/validate +++ b/scripts/validate @@ -3,10 +3,10 @@ set -e cd $(dirname $0)/.. -echo Running validation - PACKAGES="$(go list ./...)" +file bin/* + if ! command -v golangci-lint; then echo Skipping validation: no golangci-lint available exit -- GitLab