0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-10 09:41:52 +02:00

ci: improve cache reuse and drop redundant build work

- e2e and checks-backend: enable build-cache restore so they hit the
  seeded gobuild cache.
- pgsql/sqlite/mysql/mssql: replace `make backend` with
  `make generate-go`. Integration tests build their own test binary
  and never invoke the gitea executable; only bindata generation is
  needed.
- unit-tests-gogit: narrow to packages with gogit/nogogit-tagged
  files via a new `test-backend-gogit` Makefile target. Other
  packages produce identical compiled output regardless of the gogit
  tag, so retesting them was busywork.
- cache-seeder: stop the lint job from competing with the gobuild
  job on the shared non-rotated gobuild key.

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
This commit is contained in:
silverwind 2026-05-09 01:13:29 +02:00
parent a5d81d9ce2
commit ff77a928ae
No known key found for this signature in database
GPG Key ID: 2E62B41C93869443
5 changed files with 13 additions and 11 deletions

View File

@ -64,6 +64,8 @@ jobs:
- uses: ./.github/actions/go-cache
with:
cache-name: ${{ matrix.job }}
# the gobuild job already saves the shared gobuild cache key; let only it win.
build-cache: "false"
lint-cache: "true"
- run: make deps-backend deps-tools
- run: make ${{ matrix.target }}

View File

@ -78,7 +78,6 @@ jobs:
- uses: ./.github/actions/go-cache
with:
cache-name: checks-backend
build-cache: "false"
- run: make deps-backend deps-tools
- run: make --always-make checks-backend # ensure the "go-licenses" make target runs

View File

@ -52,8 +52,7 @@ jobs:
cache-name: pgsql
- name: Add hosts to /etc/hosts
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 pgsql ldap minio" | sudo tee -a /etc/hosts'
- run: make deps-backend
- run: make backend
- run: make deps-backend generate-go
env:
TAGS: bindata
- name: run migration tests
@ -81,8 +80,7 @@ jobs:
- uses: ./.github/actions/go-cache
with:
cache-name: sqlite
- run: make deps-backend
- run: make backend
- run: make deps-backend generate-go
env:
TAGS: bindata gogit
GOEXPERIMENT:
@ -161,7 +159,7 @@ jobs:
TAGS: bindata
GITHUB_READ_TOKEN: ${{ secrets.GITHUB_READ_TOKEN }}
- name: unit-tests-gogit
run: make test-backend test-check
run: make test-backend-gogit test-check
env:
GOTEST_FLAGS: -race -timeout=20m
TAGS: bindata gogit
@ -209,8 +207,7 @@ jobs:
cache-name: mysql
- name: Add hosts to /etc/hosts
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mysql elasticsearch smtpimap" | sudo tee -a /etc/hosts'
- run: make deps-backend
- run: make backend
- run: make deps-backend generate-go
env:
TAGS: bindata
- name: run migration tests
@ -250,8 +247,7 @@ jobs:
cache-name: mssql
- name: Add hosts to /etc/hosts
run: '[ -e "/.dockerenv" ] || [ -e "/run/.containerenv" ] || echo "127.0.0.1 mssql devstoreaccount1.azurite.local" | sudo tee -a /etc/hosts'
- run: make deps-backend
- run: make backend
- run: make deps-backend generate-go
env:
TAGS: bindata
- run: GITEA_TEST_DATABASE=mssql make test-migration

View File

@ -28,7 +28,6 @@ jobs:
- uses: ./.github/actions/go-cache
with:
cache-name: e2e
build-cache: "false"
- uses: pnpm/action-setup@8912a9102ac27614460f54aedde9e1e7f9aec20d # v6.0.5
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:

View File

@ -112,6 +112,7 @@ LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64,linux/r
GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/migrations/...) code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration,$(shell $(GO) list ./... | grep -v /vendor/))
MIGRATE_TEST_PACKAGES ?= $(shell $(GO) list code.gitea.io/gitea/models/migrations/...)
GO_GOGIT_TEST_PACKAGES ?= code.gitea.io/gitea/modules/git/... code.gitea.io/gitea/modules/gitrepo/... code.gitea.io/gitea/modules/lfs/...
FRONTEND_SOURCES := $(shell find web_src/js web_src/css -type f)
FRONTEND_CONFIGS := vite.config.ts tailwind.config.ts
@ -381,6 +382,11 @@ test-backend: ## test backend files
@echo "Running go test with $(GOTEST_FLAGS) -tags '$(TAGS)'..."
@$(GO) test $(GOTEST_FLAGS) -tags='$(TAGS)' $(GO_TEST_PACKAGES)
.PHONY: test-backend-gogit
test-backend-gogit: ## test gogit-affected packages only
@echo "Running go test with $(GOTEST_FLAGS) -tags '$(TAGS)' over gogit-affected packages..."
@$(GO) test $(GOTEST_FLAGS) -tags='$(TAGS)' $(GO_GOGIT_TEST_PACKAGES)
.PHONY: test-frontend
test-frontend: node_modules ## test frontend files
pnpm exec vitest