From ff77a928ae4146dedec16e0ac3d52878f0d71b38 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 9 May 2026 01:13:29 +0200 Subject: [PATCH] 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) --- .github/workflows/cache-seeder.yml | 2 ++ .github/workflows/pull-compliance.yml | 1 - .github/workflows/pull-db-tests.yml | 14 +++++--------- .github/workflows/pull-e2e-tests.yml | 1 - Makefile | 6 ++++++ 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cache-seeder.yml b/.github/workflows/cache-seeder.yml index 733077cc80..5aa0a98bfc 100644 --- a/.github/workflows/cache-seeder.yml +++ b/.github/workflows/cache-seeder.yml @@ -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 }} diff --git a/.github/workflows/pull-compliance.yml b/.github/workflows/pull-compliance.yml index 51e1c805e6..801c77d56d 100644 --- a/.github/workflows/pull-compliance.yml +++ b/.github/workflows/pull-compliance.yml @@ -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 diff --git a/.github/workflows/pull-db-tests.yml b/.github/workflows/pull-db-tests.yml index a3f4efdc16..a5184baf67 100644 --- a/.github/workflows/pull-db-tests.yml +++ b/.github/workflows/pull-db-tests.yml @@ -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 diff --git a/.github/workflows/pull-e2e-tests.yml b/.github/workflows/pull-e2e-tests.yml index f81026a5ae..0c2a2634f1 100644 --- a/.github/workflows/pull-e2e-tests.yml +++ b/.github/workflows/pull-e2e-tests.yml @@ -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: diff --git a/Makefile b/Makefile index 27b2c30295..e16a31399f 100644 --- a/Makefile +++ b/Makefile @@ -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