From 72408c7d68e01ace1bede53b47eed077cef65859 Mon Sep 17 00:00:00 2001 From: Otto Richter Date: Mon, 26 Aug 2024 21:51:41 +0200 Subject: [PATCH] Cache generated binary across jobs - retrieved by the commit hash - removes bindata tags from integration tests, because it does not seem to be required - due to the missing automatically generated data, the zstd tests fail (they use repo data including node_modules (!) as input to the test, there is no apparent reason for the size constants) --- .forgejo/workflows/testing.yml | 52 ++++++++++++++++++++++++++++------ modules/zstd/zstd_test.go | 4 +-- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/.forgejo/workflows/testing.yml b/.forgejo/workflows/testing.yml index be9808c138..725cd242ee 100644 --- a/.forgejo/workflows/testing.yml +++ b/.forgejo/workflows/testing.yml @@ -25,6 +25,14 @@ jobs: go-version-file: "go.mod" - run: make deps-backend deps-tools - run: make --always-make -j$(nproc) lint-backend tidy-check swagger-check fmt-check swagger-validate # ensure the "go-licenses" make target runs + - run: | + make backend + env: + TAGS: bindata + - uses: actions/cache@v4 + with: + path: '/workspace/forgejo/forgejo/gitea' + key: backend-build-${{ github.sha }} frontend-checks: if: ${{ !startsWith(vars.ROLE, 'forgejo-') }} runs-on: docker @@ -80,7 +88,13 @@ jobs: ./release-notes-assistant.sh test_main - run: | su forgejo -c 'make deps-backend' - - run: | + - uses: actions/cache/restore@v4 + id: cache-backend + with: + path: '/workspace/forgejo/forgejo/gitea' + key: backend-build-${{ github.sha }} + - if: steps.cache-backend.outputs.cache-hit != 'true' + run: | su forgejo -c 'make backend' env: TAGS: bindata @@ -135,7 +149,13 @@ jobs: apt-get update -qq - run: | su forgejo -c 'make deps-backend' - - run: | + - uses: actions/cache/restore@v4 + id: cache-backend + with: + path: '/workspace/forgejo/forgejo/gitea' + key: backend-build-${{ github.sha }} + - if: steps.cache-backend.outputs.cache-hit != 'true' + run: | su forgejo -c 'make backend' env: TAGS: bindata @@ -182,7 +202,13 @@ jobs: chown -R forgejo:forgejo . - run: | su forgejo -c 'make deps-backend' - - run: | + - uses: actions/cache/restore@v4 + id: cache-backend + with: + path: '/workspace/forgejo/forgejo/gitea' + key: backend-build-${{ github.sha }} + - if: steps.cache-backend.outputs.cache-hit != 'true' + run: | su forgejo -c 'make backend' env: TAGS: bindata @@ -190,7 +216,6 @@ jobs: su forgejo -c 'make test-mysql-migration test-mysql' timeout-minutes: 50 env: - TAGS: bindata USE_REPO_TEST_DIR: 1 test-pgsql: if: ${{ !startsWith(vars.ROLE, 'forgejo-') }} @@ -231,7 +256,13 @@ jobs: chown -R forgejo:forgejo . - run: | su forgejo -c 'make deps-backend' - - run: | + - uses: actions/cache/restore@v4 + id: cache-backend + with: + path: '/workspace/forgejo/forgejo/gitea' + key: backend-build-${{ github.sha }} + - if: steps.cache-backend.outputs.cache-hit != 'true' + run: | su forgejo -c 'make backend' env: TAGS: bindata @@ -239,7 +270,6 @@ jobs: su forgejo -c 'make test-pgsql-migration test-pgsql' timeout-minutes: 50 env: - TAGS: bindata RACE_ENABLED: true USE_REPO_TEST_DIR: 1 TEST_LDAP: 1 @@ -269,7 +299,13 @@ jobs: chown -R forgejo:forgejo . - run: | su forgejo -c 'make deps-backend' - - run: | + - uses: actions/cache/restore@v4 + id: cache-backend + with: + path: '/workspace/forgejo/forgejo/gitea' + key: backend-build-${{ github.sha }} + - if: steps.cache-backend.outputs.cache-hit != 'true' + run: | su forgejo -c 'make backend' env: TAGS: bindata sqlite sqlite_unlock_notify @@ -277,7 +313,7 @@ jobs: su forgejo -c 'make test-sqlite-migration test-sqlite' timeout-minutes: 50 env: - TAGS: bindata sqlite sqlite_unlock_notify + TAGS: sqlite sqlite_unlock_notify RACE_ENABLED: true TEST_TAGS: sqlite sqlite_unlock_notify USE_REPO_TEST_DIR: 1 diff --git a/modules/zstd/zstd_test.go b/modules/zstd/zstd_test.go index c3ca8e78f7..9284ab0eb2 100644 --- a/modules/zstd/zstd_test.go +++ b/modules/zstd/zstd_test.go @@ -16,7 +16,7 @@ import ( ) func TestWriterReader(t *testing.T) { - testData := prepareTestData(t, 20_000_000) + testData := prepareTestData(t, 15_000_000) result := bytes.NewBuffer(nil) @@ -64,7 +64,7 @@ func TestWriterReader(t *testing.T) { } func TestSeekableWriterReader(t *testing.T) { - testData := prepareTestData(t, 20_000_000) + testData := prepareTestData(t, 15_000_000) result := bytes.NewBuffer(nil)