diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9ac1e66fa..cb9f82a5c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -272,45 +272,27 @@ jobs: filename: linux-x86_64 - arch: arm64 filename: linux-arm64 - # - arch: ppc64le - # filename: linux-ppc64le - # - arch: s390x - # filename: linux-s390x + - arch: ppc64le + filename: linux-ppc64le + - arch: s390x + filename: linux-s390x runs-on: ubuntu-latest - # k8s codegen requires this to be set - env: - GOPATH: ${{ github.workspace }} - defaults: - run: - ## For us to run the controller-gen generate commands from within - ## github actions the package name MUST match the directory layout - ## (i.e `GOPATH/src/github.com/bpfman/bpfman`). Otherwise when - ## running `make generate` generated code is deposited at - ## `home/runner/work/bpfman/bpfman/bpfman-operator/PKG_NAME` instead - ## of in `home/runner/work/bpfman/bpfman/bpfman-operator/pkg/client/...`. - ## This is annoying and gross but cannot be resolved until - ## https://github.com/kubernetes/kubernetes/issues/86753 is properly - ## addressed. - working-directory: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman/bpfman-operator steps: - name: Checkout bpfman uses: actions/checkout@v4 - with: - path: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman - name: Install go uses: actions/setup-go@v5 with: # prettier-ignore - ## `make verify` failing on 1.22, so leave at 1.21 until issue determined. - go-version: '1.21' # yamllint disable-line rule:quoted-strings + go-version: '1.22' # yamllint disable-line rule:quoted-strings - name: Go mod check # Only need to run go mod once, so just pick one of the arch to run on. if: ${{ matrix.arch.arch == 'amd64' }} run: | go mod tidy - git diff --exit-code ../go.mod ../go.sum + git diff --exit-code go.mod go.sum - name: Lint # Only need to lint the code once, so just pick one of the arch to run on. @@ -318,7 +300,6 @@ jobs: uses: golangci/golangci-lint-action@v6 with: ## https://github.com/golangci/golangci-lint-action/issues/369 - working-directory: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman version: v1.54.2 skip-cache: true skip-save-cache: true @@ -326,27 +307,8 @@ jobs: - name: Build Examples run: | - CGO_ENABLED=0 GOOS=linux GOARCH=${{ matrix.arch.arch }} go build ./... - - - name: Build Operator - run: GOARCH=${{ matrix.arch.arch }} make build - - - name: Verify Autogenerated Code - # Only need to run verify once, so just pick one of the arch to run on. - if: ${{ matrix.arch.arch == 'amd64' }} - run: make verify - - - name: Run Tests - run: make test - - - name: Archive Go code coverage results - # Only need to run the test coverage for once, so just pick one of the arch to run on. - if: ${{ matrix.arch.arch == 'amd64' }} - uses: actions/upload-artifact@v4 - with: - name: coverage-go - path: ${{ env.GOPATH }}/src/github.com/bpfman/bpfman/bpfman-operator/cover.out - if-no-files-found: error + cd examples + GOARCH=${{ matrix.arch.arch }} make build build-docs: runs-on: ubuntu-latest @@ -418,9 +380,6 @@ jobs: - name: Run the bpfman installer run: sudo ./scripts/setup.sh install - - name: Give certs time to be created - run: sleep 5 - - name: Verify the bpfman systemd service is active run: systemctl is-active bpfman.socket @@ -438,109 +397,10 @@ jobs: - name: Run integration tests run: cargo xtask integration-test - kubernetes-integration-tests: - needs: [build, build-go, build-docs] - runs-on: ubuntu-latest - env: - BPFMAN_IMG: quay.io/bpfman/bpfman:int-test - BPFMAN_AGENT_IMG: quay.io/bpfman/bpfman-agent:int-test - BPFMAN_OPERATOR_IMG: quay.io/bpfman/bpfman-operator:int-test - XDP_PASS_PRIVATE_IMAGE_CREDS: ${{ secrets.XDP_PASS_PRIVATE_IMAGE_CREDS }} - steps: - - name: Check disk space - run: df -h - - - name: Free up space - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf /opt/ghc - sudo rm -rf "/usr/local/share/boost" - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - sudo rm -rf /usr/local/lib/android - - # The following are additional commands that could be run to free up - # more space if necessary: - # - # sudo apt-get update - # sudo eatmydata apt-get purge --auto-remove -y \ - # azure-cli aspnetcore-* dotnet-* ghc-* firefox \ - # google-chrome-stable \ - # llvm-* microsoft-edge-stable mono-* \ - # msbuild mysql-server-core-* php-* php7* \ - # powershell temurin-* zulu-* - # sudo apt-get autoremove -y - # sudo apt-get autoclean -y - # sudo docker system prune -a -f --volumes - - - name: Check disk space again - run: df -h - - - name: Install dependencies - run: | - sudo apt-get update - sudo apt-get install -qy \ - git \ - clang \ - llvm \ - gcc-multilib \ - libbpf-dev - - - name: setup golang - uses: actions/setup-go@v5 - with: - # prettier-ignore - go-version: '1.22' # yamllint disable-line rule:quoted-strings - - - name: cache go modules - uses: actions/cache@v4 - with: - path: ~/go/pkg/mod - key: ${{ runner.os }}-build-codegen-${{ hashFiles('**/go.sum') }} - restore-keys: | - ${{ runner.os }}-build-codegen- - - name: checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - ## TODO(astoycos) Currently this is just done to ensure we have coverage - ## on all image builds. Ultimately we should be running the integration - ## tests with these locally built bytecode images. - - name: build example bytecode images - run: | - go install github.com/cilium/ebpf/cmd/bpf2go@v0.14.0 - cd examples - make build-all-images - - - name: build images - run: cd bpfman-operator && make build-images - - - name: run integration tests - run: cd bpfman-operator && make test-integration - - - name: Check disk space - run: df -h - - ## Upload diagnostics if integration test step failed. - - name: upload diagnostics - if: ${{ failure() }} - uses: actions/upload-artifact@v4 - with: - name: kubernetes-integration-test-diag - path: /tmp/ktf-diag* - if-no-files-found: ignore - coverage: needs: [build, build-go] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - - name: Download golang coverage artifacts - uses: actions/download-artifact@v4 - with: - name: coverage-go - - name: Download rust coverage artifacts uses: actions/download-artifact@v4 with: @@ -549,7 +409,7 @@ jobs: - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: - files: ./cover.out,./lcov.info + files: ./lcov.info verbose: true # Creates Release @@ -608,7 +468,6 @@ jobs: build-docs, coverage, basic-integration-tests, - kubernetes-integration-tests, ] runs-on: ubuntu-latest steps: diff --git a/.github/workflows/image-build.yaml b/.github/workflows/image-build.yaml index f25d0b1fc..d3f26f658 100644 --- a/.github/workflows/image-build.yaml +++ b/.github/workflows/image-build.yaml @@ -35,48 +35,6 @@ jobs: # set latest tag for default branch type=raw,value=latest,enable={{is_default_branch}} - - registry: quay.io - # build_language: go - Not building locally, so don't install go tools - repository: bpfman - image: bpfman-agent - dockerfile: ./bpfman-operator/Containerfile.bpfman-agent - context: . - tags: | - type=ref,event=branch - type=ref,event=tag - type=ref,event=pr - type=sha,format=long - # set latest tag for default branch - type=raw,value=latest,enable={{is_default_branch}} - - - registry: quay.io - # build_language: go - Not building locally, so don't install go tools - repository: bpfman - image: bpfman-operator - dockerfile: ./bpfman-operator/Containerfile.bpfman-operator - context: . - tags: | - type=ref,event=branch - type=ref,event=tag - type=ref,event=pr - type=sha,format=long - # set latest tag for default branch - type=raw,value=latest,enable={{is_default_branch}} - - - registry: quay.io - # build_language: go - Not building locally, so don't install go tools - repository: bpfman - image: bpfman-operator-bundle - context: ./bpfman-operator - dockerfile: ./bpfman-operator/Containerfile.bundle - tags: | - type=ref,event=branch - type=ref,event=tag - type=ref,event=pr - type=sha,format=long - # set latest tag for default branch - type=raw,value=latest,enable={{is_default_branch}} - - registry: quay.io # build_language: go - Not building locally, so don't install go tools repository: bpfman-userspace @@ -183,11 +141,6 @@ jobs: - name: Install cosign uses: sigstore/cosign-installer@v3.5.0 - - name: Generate olm bundle on disk - if: ${{ matrix.image.image == 'bpfman-operator-bundle' }} - run: | - cd bpfman-operator && make bundle - - name: Login to quay.io/bpfman uses: redhat-actions/podman-login@v1 if: ${{ github.event_name == 'push' && matrix.image.repository == 'bpfman'}} @@ -204,14 +157,6 @@ jobs: username: ${{ secrets.BPFMAN_USERSPACE_USERNAME }} password: ${{ secrets.BPFMAN_USERSPACE_ROBOT_TOKEN }} - - name: Login to quay.io/bpfman-bytecode - uses: redhat-actions/podman-login@v1 - if: ${{ github.event_name == 'push' && matrix.image.repository == 'bpfman-bytecode' }} - with: - registry: ${{ matrix.image.registry }} - username: ${{ secrets.BPFMAN_BYTECODE_USERNAME }} - password: ${{ secrets.BPFMAN_BYTECODE_ROBOT_TOKEN }} - - name: Extract metadata (tags, labels) for image id: meta uses: docker/metadata-action@v5.5.1 diff --git a/Containerfile.bpfman b/Containerfile.bpfman index 66c64c15b..c1808eff2 100644 --- a/Containerfile.bpfman +++ b/Containerfile.bpfman @@ -5,11 +5,13 @@ FROM --platform=$BUILDPLATFORM rust:1 as bpfman-build ARG BUILDPLATFORM -# The following ARGs are set internally by docker or podman on multiarch builds +# The following ARGs are set internally by docker/build-push-action in github actions ARG TARGETARCH=amd64 ARG TARGETOS=linux ARG TARGETPLATFORM=linux/amd64 +RUN echo "TARGETOS=${TARGETOS} TARGETARCH=${TARGETARCH} BUILDPLATFORM=${BUILDPLATFORM} TARGETPLATFORM=${TARGETPLATFORM}" + RUN apt-get update WORKDIR /usr/src/bpfman diff --git a/bpfman-operator/Containerfile.bpfman-agent b/bpfman-operator/Containerfile.bpfman-agent index caf2c550b..074d1f156 100644 --- a/bpfman-operator/Containerfile.bpfman-agent +++ b/bpfman-operator/Containerfile.bpfman-agent @@ -5,9 +5,12 @@ FROM --platform=$BUILDPLATFORM golang:1.22 as bpfman-agent-build ARG BUILDPLATFORM -# The following ARGs are set internally by docker or podman on multiarch builds +# The following ARGs are set internally by docker/build-push-action in github actions ARG TARGETOS ARG TARGETARCH +ARG TARGETPLATFORM + +RUN echo "TARGETOS=${TARGETOS} TARGETARCH=${TARGETARCH} BUILDPLATFORM=${BUILDPLATFORM} TARGETPLATFORM=${TARGETPLATFORM}" WORKDIR /usr/src/bpfman/ diff --git a/bpfman-operator/Containerfile.bpfman-operator b/bpfman-operator/Containerfile.bpfman-operator index eec84a668..75e1ba86c 100644 --- a/bpfman-operator/Containerfile.bpfman-operator +++ b/bpfman-operator/Containerfile.bpfman-operator @@ -5,9 +5,12 @@ FROM --platform=$BUILDPLATFORM golang:1.22 as bpfman-operator-build ARG BUILDPLATFORM -# The following ARGs are set internally by docker or podman on multiarch builds +# The following ARGs are set internally by docker/build-push-action in github actions ARG TARGETOS ARG TARGETARCH +ARG TARGETPLATFORM + +RUN echo "TARGETOS=${TARGETOS} TARGETARCH=${TARGETARCH} BUILDPLATFORM=${BUILDPLATFORM} TARGETPLATFORM=${TARGETPLATFORM}" WORKDIR /usr/src/bpfman/ diff --git a/bpfman-operator/Makefile b/bpfman-operator/Makefile index 4cb4fc42a..41bbb1ae9 100644 --- a/bpfman-operator/Makefile +++ b/bpfman-operator/Makefile @@ -232,7 +232,6 @@ generate-typed-informers: informer-gen ## Generate typed informers code --versioned-clientset-package "${PKG}/pkg/client/clientset/versioned" \ --listers-package "${PKG}/pkg/client/listers" \ --output-package "${PKG}/pkg/client/informers" \ - ${COMMON_FLAGS} .PHONY: fmt fmt: ## Run go fmt against code. @@ -285,9 +284,21 @@ build: fmt ## Build bpfman-operator and bpfman-agent binaries. # More info: https://docs.docker.com/develop/develop-images/build_enhancements/ .PHONY: build-images build-images: ## Build bpfman, bpfman-agent, and bpfman-operator images. - docker buildx build -t ${BPFMAN_OPERATOR_IMG} --platform ${PLATFORM} --load -f Containerfile.bpfman-operator ../ - docker buildx build -t ${BPFMAN_AGENT_IMG} --platform ${PLATFORM} --load -f Containerfile.bpfman-agent ../ - DOCKER_BUILDKIT=1 docker buildx build -t ${BPFMAN_IMG} --platform ${PLATFORM} --load -f ../Containerfile.bpfman.local ../ + docker buildx build --load -t ${BPFMAN_OPERATOR_IMG} \ + --build-arg TARGETPLATFORM=linux/$(GOARCH) \ + --build-arg TARGETARCH=$(GOARCH) \ + --build-arg BUILDPLATFORM=linux/amd64 \ + -f Containerfile.bpfman-operator ../ + docker buildx build --load -t ${BPFMAN_AGENT_IMG} \ + --build-arg TARGETPLATFORM=linux/$(GOARCH) \ + --build-arg TARGETARCH=$(GOARCH) \ + --build-arg BUILDPLATFORM=linux/amd64 \ + -f Containerfile.bpfman-agent ../ + DOCKER_BUILDKIT=1 docker buildx build --load -t ${BPFMAN_IMG} \ + --build-arg TARGETPLATFORM=linux/$(GOARCH) \ + --build-arg TARGETARCH=$(GOARCH) \ + --build-arg BUILDPLATFORM=linux/amd64 \ + -f ../Containerfile.bpfman.local ../ .PHONY: push-images push-images: ## Push bpfman, bpfman-agent, bpfman-operator images.