From f81732a192207bc966d1602cb868a4ce6bca43e3 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Fri, 26 Jan 2024 15:36:13 +0100 Subject: [PATCH 1/4] Add multiarch Signed-off-by: Carlos Eduardo Arango Gutierrez --- .github/workflows/images.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/images.yaml b/.github/workflows/images.yaml index 901856c2..e71e4c3d 100644 --- a/.github/workflows/images.yaml +++ b/.github/workflows/images.yaml @@ -65,7 +65,8 @@ jobs: CONTROLLER_GEN_VERSION: "v0.9.2" CLIENT_GEN_VERSION: "v0.26.1" run: | - docker build --build-arg GOLANG_VERSION=${GOLANG_VERSION} \ + docker build --platform=linux/amd64,linux/arm64 \ + --build-arg GOLANG_VERSION=${GOLANG_VERSION} \ --build-arg GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION} \ --build-arg MOQ_VERSION=${MOQ_VERSION} \ --build-arg CONTROLLER_GEN_VERSION=${CONTROLLER_GEN_VERSION} \ From 0b327388c48d6bfb0de2174d1295596083efc76e Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Fri, 26 Jan 2024 15:43:40 +0100 Subject: [PATCH 2/4] Fix github action file Signed-off-by: Carlos Eduardo Arango Gutierrez --- .github/workflows/images.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/images.yaml b/.github/workflows/images.yaml index e71e4c3d..7f0a2ab0 100644 --- a/.github/workflows/images.yaml +++ b/.github/workflows/images.yaml @@ -33,7 +33,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go-version: ["1.21"," 1.21.5","1.20",""1.20".4","1.20.5"] + go-version: ["1.21","1.21.5","1.20","1.20.4","1.20.5"] steps: - uses: actions/checkout@v4 - name: Calculate build vars From 3230975a13e262c19181604b9628f6d8df109665 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Fri, 26 Jan 2024 15:45:14 +0100 Subject: [PATCH 3/4] Fix github action file Signed-off-by: Carlos Eduardo Arango Gutierrez --- .github/workflows/images.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/images.yaml b/.github/workflows/images.yaml index 7f0a2ab0..52bfa4b8 100644 --- a/.github/workflows/images.yaml +++ b/.github/workflows/images.yaml @@ -49,6 +49,8 @@ jobs: else echo "PUSH_ON_BUILD=true" >> $GITHUB_ENV fi + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to GitHub Container Registry From 0d2f3e9eb1b0c39cfd75e61e598ac811bd106f49 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Fri, 26 Jan 2024 16:21:02 +0100 Subject: [PATCH 4/4] Separate build and push jobs Signed-off-by: Carlos Eduardo Arango Gutierrez --- .github/workflows/build.yaml | 57 +++++++++++++++++++++++ .github/workflows/images.yaml | 85 ----------------------------------- .github/workflows/push.yaml | 55 +++++++++++++++++++++++ images/devel/Dockerfile | 7 +-- 4 files changed, 116 insertions(+), 88 deletions(-) create mode 100644 .github/workflows/build.yaml delete mode 100644 .github/workflows/images.yaml create mode 100644 .github/workflows/push.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 00000000..b48a345b --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,57 @@ +# Copyright 2024 NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Run this workflow on pull requests +name: build + +on: + pull_request: + types: + - opened + - synchronize + branches: + - main + - release-* + +jobs: + devel-image: + runs-on: ubuntu-latest + strategy: + matrix: + go-version: ["1.21","1.20"] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build + uses: docker/build-push-action@v5 + with: + push: false + context: . + file: ./images/devel/Dockerfile + outputs: type=docker,dest=/tmp/k8s-test-infra-image.tar + build-args: | + CLIENT_GEN_VERSION=v0.26.1 + CONTROLLER_GEN_VERSION=v0.9.2 + GOLANGCI_LINT_VERSION=v1.42.1 + GOLANG_VERSION=${{ matrix.go-version }} + MOQ_VERSION=v0.3.3 + tags: ghcr.io/nvidia/k8s-test-infra:devel-go${{ matrix.go-version }} diff --git a/.github/workflows/images.yaml b/.github/workflows/images.yaml deleted file mode 100644 index 52bfa4b8..00000000 --- a/.github/workflows/images.yaml +++ /dev/null @@ -1,85 +0,0 @@ -# Copyright 2024 NVIDIA CORPORATION -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Run this workflow on pull requests -name: images - -on: - pull_request: - types: - - opened - - synchronize - branches: - - main - - release-* - push: - branches: - - main - - release-* - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - go-version: ["1.21","1.21.5","1.20","1.20.4","1.20.5"] - steps: - - uses: actions/checkout@v4 - - name: Calculate build vars - id: vars - run: | - echo "COMMIT_SHORT_SHA=${GITHUB_SHA:0:8}" >> $GITHUB_ENV - echo "LOWERCASE_REPO_OWNER=$(echo "${GITHUB_REPOSITORY_OWNER}" | awk '{print tolower($0)}')" >> $GITHUB_ENV - REPO_FULL_NAME="${{ github.event.pull_request.head.repo.full_name }}" - echo "${REPO_FULL_NAME}" - echo "LABEL_IMAGE_SOURCE=https://github.com/${REPO_FULL_NAME}" >> $GITHUB_ENV - if [[ "${{ github.actor }}" == "dependabot[bot]" ]]; then - echo "PUSH_ON_BUILD=false" >> $GITHUB_ENV - else - echo "PUSH_ON_BUILD=true" >> $GITHUB_ENV - fi - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Login to GitHub Container Registry - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Build image - env: - GOLANG_VERSION: ${{ matrix.go-version }} - GOLANGCI_LINT_VERSION: "v1.42.1" - MOQ_VERSION: "v0.3.3" - CONTROLLER_GEN_VERSION: "v0.9.2" - CLIENT_GEN_VERSION: "v0.26.1" - run: | - docker build --platform=linux/amd64,linux/arm64 \ - --build-arg GOLANG_VERSION=${GOLANG_VERSION} \ - --build-arg GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION} \ - --build-arg MOQ_VERSION=${MOQ_VERSION} \ - --build-arg CONTROLLER_GEN_VERSION=${CONTROLLER_GEN_VERSION} \ - --build-arg CLIENT_GEN_VERSION=${CLIENT_GEN_VERSION} \ - -f ./images/devel/Dockerfile \ - --tag ghcr.io/${LOWERCASE_REPO_OWNER}/k8s-test-infra:devel-go${GOLANG_VERSION} \ - . - - name: Push image - env: - GOLANG_VERSION: ${{ matrix.go-version }} - run: | - if [[ "${PUSH_ON_BUILD}" == "true" ]]; then - docker push ghcr.io/${LOWERCASE_REPO_OWNER}/k8s-test-infra:devel-go${GOLANG_VERSION} - fi diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml new file mode 100644 index 00000000..0383809f --- /dev/null +++ b/.github/workflows/push.yaml @@ -0,0 +1,55 @@ +# Copyright 2024 NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Run this workflow on pull requests +name: push + +on: + push: + branches: + - main + - release-* + +jobs: + devel-image: + runs-on: ubuntu-latest + strategy: + matrix: + go-version: ["1.21","1.21.5","1.20","1.20.4","1.20.5"] + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and Push + uses: docker/build-push-action@v5 + with: + push: true + context: . + outputs: "type=registry,push=true" + file: ./images/devel/Dockerfile + platforms: linux/amd64,linux/arm64 + build-args: | + CLIENT_GEN_VERSION=v0.26.1 + CONTROLLER_GEN_VERSION=v0.9.2 + GOLANGCI_LINT_VERSION=v1.42.1 + GOLANG_VERSION=${{ matrix.go-version }} + MOQ_VERSION=v0.3.3 + tags: ghcr.io/nvidia/k8s-test-infra:devel-go${{ matrix.go-version }} diff --git a/images/devel/Dockerfile b/images/devel/Dockerfile index a9d29281..0c624450 100644 --- a/images/devel/Dockerfile +++ b/images/devel/Dockerfile @@ -13,11 +13,12 @@ # limitations under the License. ARG GOLANG_VERSION=x.x.x +FROM golang:${GOLANG_VERSION} + +ARG CLIENT_GEN_VERSION=v0.26.1 +ARG CONTROLLER_GEN_VERSION=v0.9.2 ARG GOLANGCI_LINT_VERSION=v1.52.0 ARG MOQ_VERSION=latest -ARG CONTROLLER_GEN_VERSION=v0.9.2 -ARG CLIENT_GEN_VERSION=v0.26.1 -FROM golang:${GOLANG_VERSION} RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION} \ && go install github.com/matryer/moq@${MOQ_VERSION} \