Files
velero/.github/workflows/push.yml
Parman Mohammadalizadeh c0d13fc51f Reuse cached Go modules across CI jobs
The kind e2e jobs download every module on every run. setup-go restores
its cache from main, but push.yml runs `go clean -modcache` before
setup-go's post step saves, so main holds an empty entry (1568 bytes)
under the key PR jobs ask for. They count it as a hit, so nothing is
ever saved over it.

- push.yml: turn off setup-go's cache, since the job empties it.
- e2e-test-kind.yaml: the build job restores one module cache, downloads
  what the e2e jobs need on a miss (`go mod download` plus the ginkgo
  CLI), and saves it before the job ends. The e2e jobs restore the same
  key. It is keyed on go.mod and go.sum rather than the Go patch version,
  which differed between runner images within one run.
- pr-ci-check.yml: point GOMODCACHE at .go/pkg/mod, which the build
  container mounts, so `go mod tidy` on the host and the containerised
  steps share one download that setup-go caches.

Fixes #10653

Signed-off-by: Parman Mohammadalizadeh <prmma23@gmail.com>
2026-10-14 20:46:42 +02:00

70 lines
2.1 KiB
YAML

name: Main CI
on:
push:
branches:
- 'main'
- 'release-**'
tags:
- '*'
permissions:
contents: read
jobs:
get-go-version:
uses: ./.github/workflows/get-go-version.yaml
with:
ref: ${{ github.ref_name }}
build:
name: Build
runs-on: ubuntu-latest
needs: get-go-version
steps:
- name: Check out the code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Go version
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ needs.get-go-version.outputs.version }}
# The Build step cleans the module cache, so saving it would store an
# empty entry under the key that PR jobs restore.
cache: false
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
with:
version: latest
- name: Build
run: |
make local
# Clean go cache to ease the build environment storage pressure.
go clean -modcache -cache
- name: Test
run: make test
- name: Upload test coverage
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.out
verbose: true
# Only try to publish the container image from the root repo; forks don't have permission to do so and will always get failures.
- name: Publish container image
if: github.repository == 'velero-io/velero'
run: |
sudo swapoff -a
sudo rm -f /mnt/swapfile
docker system prune -a --force
# Build and push Velero image to docker registry
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
./hack/docker-push.sh